eLabSDK2.Journal.Experiment.ExperimentDetail

Hierarchy

Methods

onExperimentPageReady

Static onExperimentPageReady(callback): void

Register a callback to execute when the experiment detail page UI is fully rendered.

This event fires after the experiment detail page has completed rendering all sections,
including the experiment header, sections, comments, and sidebar. Use this to perform
actions that require the DOM to be fully available, such as attaching event listeners,
manipulating page elements, initializing third-party libraries, or triggering workflows
based on the rendered experiment content.

Parameters

NameTypeDescription
callback() => voidFunction to execute when the experiment page is rendered.

Returns

void

Example

// Initialize custom features after page render
eLabSDK2.Journal.Experiment.ExperimentDetail.onExperimentPageReady(() => {
  console.log('Experiment page rendered');
  initializeCustomSectionFeatures();
  highlightImportantSections();
});

Example

// Attach event listeners after render
eLabSDK2.Journal.Experiment.ExperimentDetail.onExperimentPageReady(() => {
  document.querySelectorAll('.experiment-section').forEach(section => {
    section.addEventListener('click', handleSectionClick);
  });
});

Example

// Display notification after page loads
eLabSDK2.Journal.Experiment.ExperimentDetail.onExperimentPageReady(() => {
  const experimentStatus = window.Experiment.status;
  if (experimentStatus === 'REVIEW_PENDING') {
    eLabSDK2.UI.Toast.showToast('This experiment is pending review', 3000);
  }
});

Overrides

Experiment.onExperimentPageReady


registerAction

Static registerAction(action): void

Register a custom action button in the experiment detail page.

This adds a custom action button to the experiment detail page, typically in the actions
toolbar or menu. Actions can be used to perform operations on the experiment, trigger
custom workflows, open dialogs, export data, or integrate with external systems. The action
visibility can be controlled conditionally using the showCondition function.

Parameters

NameTypeDescription
actionAction{ id: string, label: string, onClick?: () => void, icon?: string, isVisible?: () => boolean, showCondition?: () => boolean }

Returns

void

Example

// Register a custom export action
eLabSDK2.Journal.Experiment.ExperimentDetail.registerAction({
  id: 'export-custom',
  label: 'Export to LIMS',
  icon: 'fas fa-file-export',
  onClick: async () => {
    const experimentId = window.Experiment.experimentID;
    await exportToExternalLIMS(experimentId);
    eLabSDK2.UI.Toast.showToast('Exported successfully', 2000);
  },
  showCondition: () => {
    return window.Experiment.status === 'COMPLETED';
  }
});

Example

// Register action with visibility control
eLabSDK2.Journal.Experiment.ExperimentDetail.registerAction({
  id: 'generate-report',
  label: 'Generate Report',
  icon: 'fas fa-file-pdf',
  onClick: () => {
    generateExperimentReport();
  },
  isVisible: () => {
    return eLabSDK2.System.User.hasPermissions('journal', ['EXPORT_EXPERIMENTS']);
  }
});

© 2023 eLabNext