eLabSDK2.Inventory.Equipment.EquipmentList
Hierarchy
-
↳
EquipmentList
Methods
getSelectedEquipment
Static getSelectedEquipment(): StorageUnit[]
Get the currently selected equipment items from the equipment list page.
This retrieves an array of equipment objects that the user has selected (checked)
in the equipment list view. Each equipment object contains comprehensive information
including name, location, status, device type, and metadata. Use this in conjunction
with bulk actions to perform operations on multiple selected equipment items.
Returns an empty array if no equipment is selected.
Returns
StorageUnit[]
An array of StorageUnit objects representing the selected equipment. Each object contains properties such as name, storageLayerID, location details, device type, status, and more.
Example
// Get selected equipment and log their names
const selected = eLabSDK2.Inventory.Equipment.EquipmentList.getSelectedEquipment();
console.log(`${selected.length} equipment items selected`);
selected.forEach(equipment => {
console.log(`- ${equipment.name} (${equipment.barcode})`);
});
Example
// Check if any equipment is selected before performing action
const selected = eLabSDK2.Inventory.Equipment.EquipmentList.getSelectedEquipment();
if (selected.length === 0) {
eLabSDK2.UI.Toast.showToast('Please select at least one equipment item');
return;
}
// Perform bulk operation
performBulkOperation(selected);
Example
// Filter selected equipment by status
const selected = eLabSDK2.Inventory.Equipment.EquipmentList.getSelectedEquipment();
const activeEquipment = selected.filter(eq => eq.status === 'ACTIVE');
const maintenanceEquipment = selected.filter(eq => eq.status === 'MAINTENANCE');
console.log(`Active: ${activeEquipment.length}, Maintenance: ${maintenanceEquipment.length}`);
Example
// Extract IDs for API call
const selected = eLabSDK2.Inventory.Equipment.EquipmentList.getSelectedEquipment();
const equipmentIds = selected.map(eq => eq.storageLayerID);
await api.updateEquipment(equipmentIds, { status: 'MAINTENANCE' });
registerAction
Static registerAction(action): void
Register a custom bulk action button in the equipment list page.
This adds a custom action button that appears when one or more equipment items are selected
in the equipment list. Bulk actions allow you to perform operations on multiple equipment
items at once, such as exporting data, updating statuses, or triggering custom workflows.
The action visibility can be controlled using the showCondition function.
Parameters
| Name | Type | Description |
|---|---|---|
action | Action | { id: string, title?: string, label: string, icon?: string, onClick: () => void, showCondition?: () => boolean } |
Returns
void
Example
// Add bulk export action for selected equipment
const exportAction = {
id: 'bulk-export-equipment',
title: 'Export selected equipment to CSV',
label: 'Export to CSV',
icon: 'fas fa-file-csv',
onClick: () => {
const selected = eLabSDK2.Inventory.Equipment.EquipmentList.getSelectedEquipment();
const csvData = convertToCSV(selected);
downloadFile(csvData, 'equipment.csv');
},
showCondition: () => {
return eLabSDK2.Inventory.Equipment.EquipmentList.getSelectedEquipment().length > 0;
}
};
eLabSDK2.Inventory.Equipment.EquipmentList.registerAction(exportAction);
Example
// Add bulk status update action
const updateStatusAction = {
id: 'bulk-update-status',
title: 'Update status of selected equipment',
label: 'Mark as Maintenance',
icon: 'fas fa-wrench',
onClick: async () => {
const selected = eLabSDK2.Inventory.Equipment.EquipmentList.getSelectedEquipment();
const equipmentIds = selected.map(eq => eq.storageLayerID);
await updateEquipmentStatus(equipmentIds, 'MAINTENANCE');
eLabSDK2.UI.Toast.showToast('Equipment status updated', 3000);
},
showCondition: () => {
const selected = eLabSDK2.Inventory.Equipment.EquipmentList.getSelectedEquipment();
return selected.length > 0 && selected.every(eq => eq.status !== 'MAINTENANCE');
}
};
eLabSDK2.Inventory.Equipment.EquipmentList.registerAction(updateStatusAction);
setAddEquipmentButtonVisibility
Static setAddEquipmentButtonVisibility(visibility): void
Configure whether the 'Add Equipment' button should be displayed on the equipment list page.
This controls the visibility of the 'Add Equipment' button in the equipment overview/list page.
Use this to hide the button when you want to restrict equipment creation or when implementing
custom equipment creation workflows. By default, the button is visible if the user has
appropriate permissions.
Parameters
| Name | Type | Description |
|---|---|---|
visibility | boolean | Boolean indicating whether the 'Add Equipment' button should be visible (true) or hidden (false). |
Returns
void
Example
// Hide the 'Add Equipment' button
eLabSDK2.Inventory.Equipment.EquipmentList.setAddEquipmentButtonVisibility(false);
Example
// Show the 'Add Equipment' button
eLabSDK2.Inventory.Equipment.EquipmentList.setAddEquipmentButtonVisibility(true);
Example
// Conditionally show button based on user role
const isAdmin = checkUserRole('admin');
eLabSDK2.Inventory.Equipment.EquipmentList.setAddEquipmentButtonVisibility(isAdmin);
© 2023 eLabNext
Updated about 11 hours ago