eLabSDK.Page.EquipmentList
setAddEquipmentButtonVisibility(visibility)
Show or hide the "Add Equipment" button on the equipment list page.
This controls the visibility of the standard "Add Equipment" button that appears on the
equipment list page. Use this to conditionally show or hide the add button based on user
permissions, custom business logic, or integration requirements. Useful for restricting
equipment creation to specific users or conditions.
Kind: global function
| Param | Type | Description |
|---|---|---|
| visibility | boolean | True to show the button, false to hide it |
Example
// Hide add button for read-only users
eLabSDK.ready(function() {
var equipmentListPage = new eLabSDK.Page.EquipmentList();
var userPermissions = getCurrentUserPermissions();
if (!userPermissions.canAddEquipment) {
equipmentListPage.setAddEquipmentButtonVisibility(false);
}
});
Example
// Show/hide based on group settings
eLabSDK.ready(function() {
var equipmentListPage = new eLabSDK.Page.EquipmentList();
$.get('/api/v1/groups/current/settings', function(settings) {
var canAdd = settings.allowEquipmentCreation;
equipmentListPage.setAddEquipmentButtonVisibility(canAdd);
if (!canAdd) {
console.log('Equipment creation disabled for this group');
}
});
});
Example
// Conditionally show based on license
eLabSDK.ready(function() {
var equipmentListPage = new eLabSDK.Page.EquipmentList();
$.get('/api/v1/license/check', function(license) {
if (license.equipmentModuleEnabled) {
equipmentListPage.setAddEquipmentButtonVisibility(true);
} else {
equipmentListPage.setAddEquipmentButtonVisibility(false);
alert('Equipment module not available in your license');
}
});
});
© 2023 eLabNext
Updated about 17 hours ago