eLabSDK2.Inventory.Sample.SampleDetail

Hierarchy

Methods

addSection

Static addSection(section): void

Add a custom section to the sample detail page's overview tab.

This allows you to inject custom HTML content into the sample overview tab at a specified
position. Sections can include any HTML content and can be conditionally shown based on
sample properties. Use this to display sample-specific information, custom widgets, charts,
calculations, or any additional data relevant to the sample.

Parameters

NameTypeDescription
sectionunknown{ id: string, isVisible?: (sampleId: number) => boolean, onRendered?: () => void, position?: string, contents: string, header?: { title: string, icon?: string } }

Returns

void

Example

// Add custom calculations section
eLabSDK2.Inventory.Sample.SampleDetail.addSection({
  id: 'molarity-calculator',
  position: 'bottom',
  header: {
    title: 'Molarity Calculator',
    icon: 'fas fa-calculator'
  },
  contents: '<div id="calculator-widget"></div>',
  isVisible: (sampleId) => sampleId > 0,
  onRendered: () => {
    const sample = eLabSDK2.Inventory.Sample.SampleDetail.getSample();
    initializeMolarityCalculator(sample);
  }
});

Example

// Add external system integration section
eLabSDK2.Inventory.Sample.SampleDetail.addSection({
  id: 'external-lims-data',
  position: 'top',
  header: {
    title: 'External LIMS Data',
    icon: 'fas fa-link'
  },
  contents: '<div class="loading">Loading external data...</div>',
  isVisible: (sampleId) => true,
  onRendered: async () => {
    const sample = eLabSDK2.Inventory.Sample.SampleDetail.getSample();
    const externalData = await fetchFromLIMS(sample.barcode);
    document.querySelector('.loading').innerHTML = renderExternalData(externalData);
  }
});

addStorageUnitTreeNodeAddition

Static addStorageUnitTreeNodeAddition(treeNodeAddition): void

Add custom HTML content to sample nodes in the inventory tree navigator.

This allows you to inject additional content (HTML) that will be rendered alongside
sample nodes in the inventory browser's tree view. The content can be conditionally
displayed using the optional isVisible function. This is useful for adding badges,
status indicators, custom icons, quantity alerts, or other contextual information
to sample nodes in the tree.

Parameters

NameTypeDescription
treeNodeAdditionTreeNodeAddition{ id: string, html: string, toolTip: string, isVisible?: (storageLayer: StorageLayerDetail) => boolean }

Returns

void

Example

// Add low stock badge to sample tree nodes
eLabSDK2.Inventory.Sample.SampleDetail.addStorageUnitTreeNodeAddition({
  id: 'low-stock-badge',
  html: '<span class="badge badge-warning">Low</span>',
  toolTip: 'Low stock warning',
  isVisible: (storageLayer) => {
    // Check if storage layer has samples with low quantity
    return storageLayer.samples?.some(s => s.quantity?.amount < 20);
  }
});

Example

// Add capacity indicator to tree nodes
eLabSDK2.Inventory.Sample.SampleDetail.addStorageUnitTreeNodeAddition({
  id: 'capacity-indicator',
  html: '<i class="fas fa-exclamation-triangle text-warning"></i>',
  toolTip: 'Storage layer is near capacity',
  isVisible: (storageLayer) => {
    if (!storageLayer.capacity) return false;
    const occupancy = (storageLayer.occupiedPositions / storageLayer.capacity) * 100;
    return occupancy > 90;
  }
});

Example

// Add custom status indicator
eLabSDK2.Inventory.Sample.SampleDetail.addStorageUnitTreeNodeAddition({
  id: 'storage-status',
  html: '<span class="status-dot"></span>',
  toolTip: 'Storage layer status',
  isVisible: (storageLayer) => storageLayer.status === 'ACTIVE'
});

addTab

Static addTab(tabConfig): void

Add a custom tab to the sample detail page.

This creates a new tab in the sample detail page where you can display custom content.
Tabs can be of type 'table' for tabular data with built-in paging, or 'custom' for
any HTML content. Use this to show related data, external integrations, analysis results,
or any sample-specific information that warrants its own dedicated view. If a tab with
the given ID already exists, it will be updated rather than creating a duplicate.

Parameters

NameTypeDescription
tabConfigCustomTab{ id: string, title: string, type: 'table' | 'custom', content: string | SDKTableConfig, isVisible?: () => boolean, onLoad?: () => void }

Returns

void

Example

// Add custom HTML tab
eLabSDK2.Inventory.Sample.SampleDetail.addTab({
  id: 'external-data',
  title: 'External System Data',
  type: 'custom',
  content: '<div id="external-content">Loading...</div>',
  onLoad: async () => {
    const sample = eLabSDK2.Inventory.Sample.SampleDetail.getSample();
    const data = await fetchExternalData(sample.barcode);
    document.getElementById('external-content').innerHTML = renderData(data);
  }
});

Example

// Add table tab with paging
eLabSDK2.Inventory.Sample.SampleDetail.addTab({
  id: 'related-samples',
  title: 'Related Samples',
  type: 'table',
  content: {
    columns: ['ID', 'Name', 'Status', 'Location'],
    data: [
      [1, 'Sample A', 'Active', 'Freezer 1'],
      [2, 'Sample B', 'Archived', 'Freezer 2']
    ],
    paging: {
      showPager: true,
      currentPage: 1,
      recordCount: 20,
      totalCount: 150,
      handlePage: async (recordsPerPage, currentPage) => {
        const data = await fetchRelatedSamples(currentPage, recordsPerPage);
        updateTableData(data);
      }
    }
  }
});

Example

// Add conditional tab (only visible for certain sample types)
eLabSDK2.Inventory.Sample.SampleDetail.addTab({
  id: 'antibody-validation',
  title: 'Validation Data',
  type: 'custom',
  content: '<div class="validation-data"></div>',
  isVisible: () => {
    const sampleType = eLabSDK2.Inventory.Sample.SampleDetail.getSampleTypeDetail();
    return sampleType?.name === 'Antibody';
  },
  onLoad: () => loadValidationData()
});

addTopNotice

Static addTopNotice(notice): void

Add a notification banner to the top of the sample detail page.

This displays an informational, warning, error, or success notice at the top of the
sample detail page. Notices are useful for alerting users to important information
about the sample, such as low stock warnings, expiration alerts, hazard information,
or custom status messages. The notice visibility can be conditionally controlled.

Parameters

NameTypeDescription
noticeBoxNotice{ id: string, type: 'info' | 'warning' | 'error' | 'success', contents: string, icon: string, title?: string, isVisible?: (sample: Sample) => boolean }

Returns

void

Example

// Add low stock warning
eLabSDK2.Inventory.Sample.SampleDetail.addTopNotice({
  id: 'low-stock-warning',
  type: 'warning',
  title: 'Low Stock Alert',
  contents: 'This sample is running low. Consider reordering.',
  icon: 'fas fa-exclamation-triangle',
  isVisible: (sample) => {
    if (!sample.quantity) return false;
    const percentRemaining = (sample.quantity.amount / sample.quantity.fullAmount) * 100;
    return percentRemaining < 20;
  }
});

Example

// Add expiration notice
eLabSDK2.Inventory.Sample.SampleDetail.addTopNotice({
  id: 'expiration-alert',
  type: 'error',
  title: 'Sample Expired',
  contents: 'This sample has passed its expiration date and should not be used.',
  icon: 'fas fa-ban',
  isVisible: (sample) => {
    if (!sample.meta?.expirationDate) return false;
    return new Date(sample.meta.expirationDate) < new Date();
  }
});

Example

// Add hazard warning
eLabSDK2.Inventory.Sample.SampleDetail.addTopNotice({
  id: 'hazard-warning',
  type: 'error',
  title: 'Hazardous Material',
  contents: 'This sample contains hazardous materials. Follow safety protocols.',
  icon: 'fas fa-skull-crossbones',
  isVisible: (sample) => sample.meta?.hazardous === 'Yes'
});

getCurrentTabTitle

Static getCurrentTabTitle(): string

Get the title of the currently active tab in the sample/series detail page.

This retrieves the title/identifier of the tab that the user is currently viewing
in the sample detail page (e.g., 'overview', 'experiments', 'audit-trail', or custom
tab IDs). Use this to implement tab-specific logic, conditional rendering, or to
track user navigation within the sample detail page.

Returns

string

The string identifier of the currently active tab.

Example

// Check which tab is active
const activeTab = eLabSDK2.Inventory.Sample.SampleDetail.getCurrentTabTitle();
console.log(`Current tab: ${activeTab}`);

Example

// Perform action based on active tab
const activeTab = eLabSDK2.Inventory.Sample.SampleDetail.getCurrentTabTitle();
if (activeTab === 'experiments') {
  loadExperimentData();
} else if (activeTab === 'audit-trail') {
  loadAuditData();
}

Example

// Track tab navigation
eLabSDK2.Inventory.Sample.SampleDetail.registerAction({
  id: 'track-tab-views',
  label: 'Track View',
  onClick: () => {
    const currentTab = eLabSDK2.Inventory.Sample.SampleDetail.getCurrentTabTitle();
    trackAnalytics('sample_tab_viewed', { tab: currentTab });
  }
});

getParentSampleID

Static getParentSampleID(): number

Get the parent sample ID of the currently displayed sample.

This retrieves the ID of the parent sample if the current sample has a parent-child
relationship established. Parent samples are used to track sample lineage and derivation
(e.g., aliquots from a stock solution, derivatives from a parent compound). Returns null
if the sample has no parent.

Returns

number

The numeric parent sample ID if set, or null if the sample has no parent.

Example

// Check if sample has a parent
const parentId = eLabSDK2.Inventory.Sample.SampleDetail.getParentSampleID();
if (parentId) {
  console.log(`This sample is derived from sample ${parentId}`);
  // Fetch and display parent sample information
  const parent = await eLabSDK2.Inventory.Sample.getSampleByID(parentId);
  console.log(`Parent sample: ${parent.name}`);
} else {
  console.log('This is a root sample with no parent');
}

Example

// Navigate to parent sample
const parentId = eLabSDK2.Inventory.Sample.SampleDetail.getParentSampleID();
if (parentId) {
  window.location.href = `/inventory/samples/${parentId}`;
}

Example

// Display sample lineage
async function displayLineage() {
  const currentSample = eLabSDK2.Inventory.Sample.SampleDetail.getSample();
  const lineage = [currentSample];

  let parentId = eLabSDK2.Inventory.Sample.SampleDetail.getParentSampleID();
  while (parentId) {
    const parent = await eLabSDK2.Inventory.Sample.getSampleByID(parentId);
    lineage.unshift(parent);
    parentId = parent.parentSampleID;
  }

  console.log('Sample lineage:', lineage.map(s => s.name).join(' → '));
}

getSample

Static getSample(): SampleInterface

Get the complete sample object for the currently displayed sample.

This retrieves the full sample object with all its properties including basic information
(name, barcode, status), metadata fields, quantity data, location, and timestamps.
This is the primary method to access sample data when building custom functionality
in the sample detail page context.

Returns

SampleInterface

A SampleInterface object containing all sample properties and metadata.

Example

// Access sample properties
const sample = eLabSDK2.Inventory.Sample.SampleDetail.getSample();
console.log(`Name: ${sample.name}`);
console.log(`Barcode: ${sample.barcode}`);
console.log(`Sample Type ID: ${sample.sampleTypeID}`);
console.log(`Location: ${sample.storageLayerName}`);

Example

// Access sample metadata
const sample = eLabSDK2.Inventory.Sample.SampleDetail.getSample();
if (sample.meta) {
  console.log(`Concentration: ${sample.meta.concentration}`);
  console.log(`Buffer: ${sample.meta.buffer}`);
}

Example

// Use in custom action
eLabSDK2.Inventory.Sample.SampleDetail.registerAction({
  id: 'export-sample',
  label: 'Export Sample',
  onClick: () => {
    const sample = eLabSDK2.Inventory.Sample.SampleDetail.getSample();
    exportToJSON(sample);
  }
});

getSampleDetail

Static getSampleDetail(): SampleDetailInterface

Get the complete details of the currently selected sample in the detail view.

This retrieves the full state object for the sample currently loaded in the sample
detail page, including the sample object itself, related data like experiments and orders,
and UI state information. Use this to access comprehensive sample information when
building custom features or integrations in the sample detail context.

Returns

SampleDetailInterface

A SampleDetailInterface object containing the sample object, related entities (experiments, orders, children), and UI state.

Example

// Get current sample details
const details = eLabSDK2.Inventory.Sample.SampleDetail.getSampleDetail();
console.log(`Sample: ${details.sample.name}`);
console.log(`Experiments: ${details.experiments?.length || 0}`);
console.log(`Child samples: ${details.children?.length || 0}`);

Example

// Access sample metadata
const details = eLabSDK2.Inventory.Sample.SampleDetail.getSampleDetail();
if (details.sample.meta) {
  Object.entries(details.sample.meta).forEach(([key, value]) => {
    console.log(`${key}: ${value}`);
  });
}

Example

// Check if sample has related experiments
const details = eLabSDK2.Inventory.Sample.SampleDetail.getSampleDetail();
if (details.experiments && details.experiments.length > 0) {
  console.log('This sample is used in experiments');
}

getSampleID

Static getSampleID(): number

Get the sample ID of the currently displayed sample in the detail view.

This is a convenience method to quickly retrieve just the sample ID without
accessing the full sample detail object. Returns null if no sample is currently
loaded in the detail view. Use this for API calls, tracking, or conditional logic
that needs to know which sample is being viewed.

Returns

number

The numeric sample ID of the currently displayed sample, or null if no sample is loaded.

Example

// Get current sample ID
const sampleId = eLabSDK2.Inventory.Sample.SampleDetail.getSampleID();
if (sampleId) {
  console.log(`Viewing sample ID: ${sampleId}`);
} else {
  console.log('No sample currently loaded');
}

Example

// Use sample ID in API call
const sampleId = eLabSDK2.Inventory.Sample.SampleDetail.getSampleID();
if (sampleId) {
  const history = await fetchSampleHistory(sampleId);
  displayHistory(history);
}

Example

// Track which sample user is viewing
const sampleId = eLabSDK2.Inventory.Sample.SampleDetail.getSampleID();
if (sampleId) {
  trackAnalytics('sample_viewed', { sampleId: sampleId });
}

getSampleSeriesID

Static getSampleSeriesID(): number

Get the series ID if the currently displayed sample belongs to a series.

This retrieves the series ID for samples that are part of a sample series (a collection
of related samples such as replicates, time series, or batch samples). Returns null if
the current sample is not part of any series. Use this to identify series membership
and access series-level operations.

Returns

number

The numeric series ID if the sample belongs to a series, or null if it's not part of any series.

Example

// Check if sample is in a series
const seriesId = eLabSDK2.Inventory.Sample.SampleDetail.getSampleSeriesID();
if (seriesId) {
  console.log(`Sample belongs to series ${seriesId}`);
  // Fetch other samples in the series
  const seriesData = await fetchSeriesSamples(seriesId);
  console.log(`Series contains ${seriesData.length} samples`);
} else {
  console.log('Sample is not part of a series');
}

Example

// Navigate to series view
const seriesId = eLabSDK2.Inventory.Sample.SampleDetail.getSampleSeriesID();
if (seriesId) {
  window.location.href = `/inventory/series/${seriesId}`;
}

Example

// Add series-specific action
eLabSDK2.Inventory.Sample.SampleDetail.registerAction({
  id: 'view-series',
  label: 'View Full Series',
  onClick: () => {
    const seriesId = eLabSDK2.Inventory.Sample.SampleDetail.getSampleSeriesID();
    if (seriesId) {
      navigateToSeries(seriesId);
    }
  },
  showOnTabs: 'all',
  isVisible: () => eLabSDK2.Inventory.Sample.SampleDetail.getSampleSeriesID() !== null
});

getSampleTypeDetail

Static getSampleTypeDetail(): any

Get the sample type details for the currently selected sample.

This retrieves the complete sample type configuration for the sample currently displayed
in the detail view. The sample type defines the structure, fields, and behavior for
samples of this type. Use this to understand the sample's type configuration, available
metadata fields, or to perform type-specific operations.

Returns

any

A SampleType object containing all sample type metadata and configuration, or undefined if no sample is selected or the type is not found.

Example

// Get sample type information
const sampleType = eLabSDK2.Inventory.Sample.SampleDetail.getSampleTypeDetail();
if (sampleType) {
  console.log(`Sample Type: ${sampleType.name}`);
  console.log(`Type ID: ${sampleType.sampleTypeID}`);
  console.log(`Fields: ${sampleType.fields?.length || 0}`);
}

Example

// Check sample type before performing action
const sampleType = eLabSDK2.Inventory.Sample.SampleDetail.getSampleTypeDetail();
if (sampleType && sampleType.name === 'Antibody') {
  // Show antibody-specific actions
  displayAntibodyActions();
}

Example

// Get available metadata fields for the sample type
const sampleType = eLabSDK2.Inventory.Sample.SampleDetail.getSampleTypeDetail();
if (sampleType && sampleType.fields) {
  sampleType.fields.forEach(field => {
    console.log(`Field: ${field.name}, Type: ${field.fieldType}`);
  });
}

getSeriesDetail

Static getSeriesDetail(): SeriesDetailInterface

Get the complete details of the currently selected sample series in the detail view.

This retrieves the full state object for the series currently loaded in the series
detail page. A series is a collection of related samples (e.g., time series, replicates).
Use this when working with series samples to access series-specific information and
the member samples within the series.

Returns

SeriesDetailInterface

A SeriesDetailInterface object containing the series ID and related series information.

Example

// Get current series details
const seriesDetails = eLabSDK2.Inventory.Sample.SampleDetail.getSeriesDetail();
console.log(`Series ID: ${seriesDetails.seriesID}`);

Example

// Check if viewing a series
if (eLabSDK2.Inventory.Sample.SampleDetail.isSeries()) {
  const seriesDetails = eLabSDK2.Inventory.Sample.SampleDetail.getSeriesDetail();
  console.log(`Viewing series ${seriesDetails.seriesID}`);
}

Example

// Use series ID for API calls
const seriesDetails = eLabSDK2.Inventory.Sample.SampleDetail.getSeriesDetail();
if (seriesDetails.seriesID) {
  const seriesData = await fetchSeriesData(seriesDetails.seriesID);
  displaySeriesAnalysis(seriesData);
}

getSeriesID

Static getSeriesID(): any

Get the series ID when viewing a series detail page.

This retrieves the series ID when the user is on a series detail page (as opposed to
an individual sample within a series). Use this method specifically in the series detail
context. For checking if an individual sample belongs to a series, use getSampleSeriesID() instead.

Returns

any

The numeric series ID if viewing a series detail page, or null if not in series context.

Example

// Get series ID in series detail context
if (eLabSDK2.Inventory.Sample.SampleDetail.isSeries()) {
  const seriesId = eLabSDK2.Inventory.Sample.SampleDetail.getSeriesID();
  console.log(`Viewing series: ${seriesId}`);
}

Example

// Fetch series-level data
const seriesId = eLabSDK2.Inventory.Sample.SampleDetail.getSeriesID();
if (seriesId) {
  const seriesData = await fetchSeriesAnalytics(seriesId);
  displaySeriesChart(seriesData);
}

Example

// Difference between getSampleSeriesID and getSeriesID
// When viewing individual sample that's in a series:
const sampleSeriesId = eLabSDK2.Inventory.Sample.SampleDetail.getSampleSeriesID(); // Returns series ID
const seriesId = eLabSDK2.Inventory.Sample.SampleDetail.getSeriesID(); // Returns null

// When viewing series detail page:
const seriesId = eLabSDK2.Inventory.Sample.SampleDetail.getSeriesID(); // Returns series ID

isSeries

Static isSeries(): boolean

Check if the currently displayed sample is part of a sample series.

This determines whether the user is currently viewing a sample that belongs to a series
(a collection of related samples). Series samples have special handling and may display
additional information or functionality. Use this to conditionally show series-specific
features, customize UI elements, or apply series-specific business logic.

Returns

boolean

True if the current sample is part of a series, false otherwise.

Example

// Check if viewing a series sample
if (eLabSDK2.Inventory.Sample.SampleDetail.isSeries()) {
  console.log('This sample is part of a series');
  const seriesDetails = eLabSDK2.Inventory.Sample.SampleDetail.getSeriesDetail();
  console.log(`Series ID: ${seriesDetails.seriesID}`);
} else {
  console.log('This is an individual sample');
}

Example

// Show series navigation if applicable
if (eLabSDK2.Inventory.Sample.SampleDetail.isSeries()) {
  displaySeriesNavigationControls();
}

Example

// Conditional action visibility
eLabSDK2.Inventory.Sample.SampleDetail.registerAction({
  id: 'series-analysis',
  label: 'Analyze Series',
  onClick: () => performSeriesAnalysis(),
  showCondition: () => eLabSDK2.Inventory.Sample.SampleDetail.isSeries()
});

onSampleDetailReady

Static onSampleDetailReady(callback, id): void

Register a callback to execute when the sample detail page is fully loaded and ready.

This event fires after the sample detail page has completed loading all sample data,
related entities, and rendering the complete DOM. The callback receives comprehensive
sample information including the sample object, experiments, orders, children, and more.
Use this to perform actions that depend on all sample data being available, such as
custom visualizations, data processing, or external integrations.

Parameters

NameTypeDescription
callback(event: CustomEvent<SampleDetailInterface>) => voidFunction to execute when the page is ready. Receives a CustomEvent with SampleDetailInterface containing all sample details.
idstringUnique identifier for this callback registration.

Returns

void

Example

// Log sample details when ready
eLabSDK2.Inventory.Sample.SampleDetail.onSampleDetailReady((event) => {
  const details = event.detail;
  console.log(`Sample ready: ${details.sample.name}`);
  console.log(`Related experiments: ${details.experiments?.length || 0}`);
}, 'log-sample-ready');

Example

// Fetch and display additional data when sample loads
eLabSDK2.Inventory.Sample.SampleDetail.onSampleDetailReady(async (event) => {
  const sampleId = event.detail.sample.sampleID;
  const additionalData = await fetchExternalData(sampleId);
  displayCustomSection(additionalData);
}, 'fetch-external-data');

Example

// Add custom UI elements based on sample data
eLabSDK2.Inventory.Sample.SampleDetail.onSampleDetailReady((event) => {
  const sample = event.detail.sample;
  if (sample.meta?.hazardous === 'Yes') {
    addHazardWarningBanner();
  }
}, 'hazard-warning');

registerAction

Static registerAction(action): void

Register a custom action on a single sample.

Parameters

NameTypeDescription
actionActionThe custom action to register. It must conform to the Action interface.

Returns

void

Example

// Register a custom action to log a message when clicked
SampleDetail.registerAction({
  id: 'logAction',
  label: 'Log Message',
  title: 'Log a custom message',
  icon: 'fas fa-info-circle',
  onClick: () => console.log('Custom action clicked!'),
  isVisible: (context) => {
    console.log(`Sample ID: ${context.sampleId}, Tab: ${context.tab}`);
    return true; // Always visible
  },
  showOnTabs: ['Sample Overview', 'Audit Trail'], // Active on specific tabs
});

reloadSample

Static reloadSample(sampleId): Promise<SampleDetail>

Reload the currently displayed sample with fresh data from the server.

This fetches the latest sample data including all expanded related data (quantity, metadata,
parent/child relationships, experiments, orders, location, and more). It also automatically
reloads related data such as shopping items, children, and series information. Use this
after making changes to the sample to ensure the display reflects the current state. If no
sample ID is provided, it reloads the currently displayed sample.

Parameters

NameTypeDescription
sampleIdnumberOptional sample ID to reload. If null or not provided, reloads the currently active sample.

Returns

Promise<SampleDetail>

A Promise that resolves to the reloaded SampleDetail object, or null if no sample could be loaded.

Example

// Reload current sample after making changes
await eLabSDK2.Inventory.Sample.SampleDetail.reloadSample();
eLabSDK2.UI.Toast.showToast('Sample data refreshed', 2000);

Example

// Reload after updating quantity
async function consumeSample(amount) {
  await api.updateSampleQuantity(currentSampleId, { consumed: amount });
  await eLabSDK2.Inventory.Sample.SampleDetail.reloadSample();
  console.log('Sample quantity updated and reloaded');
}

Example

// Reload specific sample by ID
await eLabSDK2.Inventory.Sample.SampleDetail.reloadSample(12345);

Example

// Use in custom action
eLabSDK2.Inventory.Sample.SampleDetail.registerAction({
  id: 'refresh-data',
  label: 'Refresh',
  icon: 'fas fa-sync',
  onClick: async () => {
    await eLabSDK2.Inventory.Sample.SampleDetail.reloadSample();
    eLabSDK2.UI.Toast.showToast('Data refreshed', 2000);
  }
});

reloadSampleChildren

Static reloadSampleChildren(): void

Reload the child samples of the currently displayed sample.

This refreshes the list of child samples (samples derived from the current sample) in
the sample detail view. Child samples are displayed in the "Children" section and represent
aliquots, derivatives, or samples created from the current sample. Use this after creating
new child samples or when child sample data may have changed.

Returns

void

Example

// Reload children after creating an aliquot
async function createAliquot(parentSampleId, aliquotData) {
  await api.createSample({ ...aliquotData, parentSampleID: parentSampleId });
  eLabSDK2.Inventory.Sample.SampleDetail.reloadSampleChildren();
  eLabSDK2.UI.Toast.showToast('Aliquot created', 2000);
}

Example

// Refresh children display in custom action
eLabSDK2.Inventory.Sample.SampleDetail.registerAction({
  id: 'refresh-children',
  label: 'Refresh Child Samples',
  onClick: () => {
    eLabSDK2.Inventory.Sample.SampleDetail.reloadSampleChildren();
  },
  showOnTabs: ['Sample Overview']
});

reloadSampleMeta

Static reloadSampleMeta(): Promise<SampleInterface>

Reload the metadata fields for the currently displayed sample.

This refreshes only the metadata (custom fields) of the current sample without reloading
the entire sample object. Metadata includes sample-type-specific fields like concentration,
buffer, storage conditions, and any other custom fields defined for the sample type. Use
this after updating metadata values to refresh the display without a full page reload.

Returns

Promise<SampleInterface>

A Promise that resolves to the updated SampleInterface object with fresh metadata.

Example

// Reload metadata after update
async function updateConcentration(sampleId, newConcentration) {
  await api.updateSampleMeta(sampleId, { concentration: newConcentration });
  await eLabSDK2.Inventory.Sample.SampleDetail.reloadSampleMeta();
  eLabSDK2.UI.Toast.showToast('Metadata updated', 2000);
}

Example

// Use in custom action
eLabSDK2.Inventory.Sample.SampleDetail.registerAction({
  id: 'refresh-metadata',
  label: 'Refresh Metadata',
  onClick: async () => {
    const updatedSample = await eLabSDK2.Inventory.Sample.SampleDetail.reloadSampleMeta();
    console.log('Updated metadata:', updatedSample.meta);
  }
});

Example

// Reload after bulk metadata update
async function updateMultipleFields(sampleId, metaUpdates) {
  await api.updateSampleMeta(sampleId, metaUpdates);
  const refreshedSample = await eLabSDK2.Inventory.Sample.SampleDetail.reloadSampleMeta();
  displayUpdatedMetadata(refreshedSample.meta);
}

reloadSampleQuantity

Static reloadSampleQuantity(): Promise<SampleInterface>

Reload the quantity information for the currently displayed sample.

This refreshes only the quantity data of the current sample without reloading the entire
sample object. Quantity information includes current amount, unit, full amount, threshold,
and low stock status. Use this after updating quantity (e.g., after consuming, adding,
or adjusting stock) to update the display without a full page reload.

Returns

Promise<SampleInterface>

A Promise that resolves to the updated SampleInterface object with fresh quantity data.

Example

// Reload quantity after consumption
async function consumeSample(sampleId, amount) {
  await api.consumeSample(sampleId, { amount: amount });
  await eLabSDK2.Inventory.Sample.SampleDetail.reloadSampleQuantity();
  eLabSDK2.UI.Toast.showToast('Quantity updated', 2000);
}

Example

// Use in custom action
eLabSDK2.Inventory.Sample.SampleDetail.registerAction({
  id: 'refresh-quantity',
  label: 'Refresh Stock',
  icon: 'fas fa-sync',
  onClick: async () => {
    const updatedSample = await eLabSDK2.Inventory.Sample.SampleDetail.reloadSampleQuantity();
    if (updatedSample.quantity) {
      const display = eLabSDK2.Inventory.Sample.displaySampleQuantity(updatedSample.quantity);
      console.log(`Current quantity: ${display}`);
    }
  }
});

Example

// Reload after stock adjustment
async function adjustStock(sampleId, adjustment) {
  await api.adjustSampleQuantity(sampleId, adjustment);
  const refreshedSample = await eLabSDK2.Inventory.Sample.SampleDetail.reloadSampleQuantity();
  checkLowStockStatus(refreshedSample.quantity);
}

reloadSampleSeries

Static reloadSampleSeries(): void

Reload the series information if the currently displayed sample belongs to a series.

This refreshes the series data for samples that are part of a sample series. A series
is a collection of related samples (e.g., replicates, time points, batch samples). If
the current sample is not part of a series, this method has no effect. Use this after
making changes to the series or its member samples.

Returns

void

Example

// Reload series after adding a sample to it
async function addToSeries(sampleId, seriesId) {
  await api.addSampleToSeries(sampleId, seriesId);
  eLabSDK2.Inventory.Sample.SampleDetail.reloadSampleSeries();
  eLabSDK2.UI.Toast.showToast('Sample added to series', 2000);
}

Example

// Refresh series data in custom action
eLabSDK2.Inventory.Sample.SampleDetail.registerAction({
  id: 'refresh-series',
  label: 'Refresh Series',
  onClick: () => {
    eLabSDK2.Inventory.Sample.SampleDetail.reloadSampleSeries();
  },
  isVisible: () => eLabSDK2.Inventory.Sample.SampleDetail.getSampleSeriesID() !== null
});

Example

// Check and reload if in series
if (eLabSDK2.Inventory.Sample.SampleDetail.getSampleSeriesID()) {
  eLabSDK2.Inventory.Sample.SampleDetail.reloadSampleSeries();
  console.log('Series data reloaded');
}

reloadSampleShoppingItem

Static reloadSampleShoppingItem(): void

Reload the shopping/order item information for the currently displayed sample.

This refreshes order and purchasing information associated with the current sample.
Shopping items represent orders, requisitions, or procurement records linked to the sample.
Use this after updating order information or when the shopping item status may have changed.

Returns

void

Example

// Reload after updating order status
async function updateOrderStatus(sampleId, status) {
  await api.updateSampleOrder(sampleId, { status: status });
  eLabSDK2.Inventory.Sample.SampleDetail.reloadSampleShoppingItem();
}

Example

// Refresh order information in custom tab
eLabSDK2.Inventory.Sample.SampleDetail.addTab({
  id: 'ordering-info',
  title: 'Orders',
  type: 'custom',
  content: '<div id="order-details"></div>',
  onLoad: () => {
    eLabSDK2.Inventory.Sample.SampleDetail.reloadSampleShoppingItem();
  }
});

updateCustomList

Static updateCustomList(): void

Trigger an update for custom lists displayed in sample detail tabs.

This dispatches a global event that triggers the handlePage callback in custom tab
configurations. Use this when you've added a custom table tab (type: 'table') and need
to refresh its data without completely reloading the tab. The event causes the tab's
pagination handler to be called, allowing you to fetch and display updated data.

Returns

void

Example

// Refresh custom table after data change
eLabSDK2.Inventory.Sample.SampleDetail.addTab({
  id: 'related-experiments',
  title: 'Related Experiments',
  type: 'table',
  content: {
    columns: ['ID', 'Title', 'Date'],
    data: [],
    paging: {
      showPager: true,
      currentPage: 1,
      recordCount: 10,
      totalCount: 50,
      handlePage: async (recordsPerPage, currentPage) => {
        const sampleId = eLabSDK2.Inventory.Sample.SampleDetail.getSampleID();
        const experiments = await fetchRelatedExperiments(sampleId, currentPage, recordsPerPage);
        updateTableData(experiments);
      }
    }
  }
});

// Trigger update after linking experiment
async function linkExperiment(sampleId, experimentId) {
  await api.linkSampleToExperiment(sampleId, experimentId);
  eLabSDK2.Inventory.Sample.SampleDetail.updateCustomList();
}

Example

// Use in custom action button
eLabSDK2.Inventory.Sample.SampleDetail.registerAction({
  id: 'refresh-table',
  label: 'Refresh Data',
  onClick: () => {
    eLabSDK2.Inventory.Sample.SampleDetail.updateCustomList();
    eLabSDK2.UI.Toast.showToast('Table refreshed', 2000);
  },
  showOnTabs: ['related-experiments']
});

© 2023 eLabNext