eLabSDK.Page.StorageConfiguration

Functions

NameDescription
ready(fn)Execute a callback when the storage configuration page is fully loaded and ready.

This ensures your callback is executed only after the storage unit edit page has finished
loading all data and is ready for interaction. If the data is already loaded when this
is called, the callback executes immediately. Otherwise, it waits for the data load event.
The callback receives the page instance and storage unit ID as parameters. Use this to
ensure form elements exist and data is loaded before manipulating them.
getDepartmentField() | Get the department form field jQuery object.

This returns the jQuery-wrapped input field for the department location property. Use this
to read, set, or validate the department value programmatically in the storage configuration
form.
getBuildingField() | Get the building form field jQuery object.

This returns the jQuery-wrapped input field for the building location property. Use this
to read, set, or validate the building value programmatically in the storage configuration
form.
getFloorField() | Get the floor form field jQuery object.

This returns the jQuery-wrapped input field for the floor location property. Use this
to read, set, or validate the floor value programmatically in the storage configuration
form.
getRoomField() | Get the room form field jQuery object.

This returns the jQuery-wrapped input field for the room location property. Use this
to read, set, or validate the room value programmatically in the storage configuration
form.

ready(fn)

Execute a callback when the storage configuration page is fully loaded and ready.

This ensures your callback is executed only after the storage unit edit page has finished
loading all data and is ready for interaction. If the data is already loaded when this
is called, the callback executes immediately. Otherwise, it waits for the data load event.
The callback receives the page instance and storage unit ID as parameters. Use this to
ensure form elements exist and data is loaded before manipulating them.

Kind: global function

ParamTypeDescription
fnfunctionCallback function to execute when page is ready
fn.pageInstanceStorageConfigurationThe page instance
[fn.storageUnitID]numberThe storage unit ID being edited

Example

// Add custom logic after page loads
eLabSDK.ready(function() {
  var storagePage = new eLabSDK.Page.StorageConfiguration({
    onReady: function(pageInstance, storageUnitID) {
      console.log('Storage config page ready for unit: ' + storageUnitID);
      
      // Customize form fields
      var $building = pageInstance.getBuildingField();
      $building.val('Building A');
      
      var $room = pageInstance.getRoomField();
      $room.val('Room 101');
    }
  });
});

Example

// Validate location fields
eLabSDK.ready(function() {
  var storagePage = new eLabSDK.Page.StorageConfiguration({
    onReady: function(page, unitID) {
      var $dept = page.getDepartmentField();
      var $building = page.getBuildingField();
      
      // Ensure required fields are filled
      $dept.on('blur', function() {
        if (!$(this).val()) {
          alert('Department is required');
        }
      });
    }
  });
});

getDepartmentField()

Get the department form field jQuery object.

This returns the jQuery-wrapped input field for the department location property. Use this
to read, set, or validate the department value programmatically in the storage configuration
form.

Kind: global function
Returns: jQuery - jQuery object for the department input field
Example

// Set default department
eLabSDK.ready(function() {
  var storagePage = new eLabSDK.Page.StorageConfiguration({
    onReady: function() {
      var $dept = this.getDepartmentField();
      $dept.val('Chemistry Department');
    }
  });
});

getBuildingField()

Get the building form field jQuery object.

This returns the jQuery-wrapped input field for the building location property. Use this
to read, set, or validate the building value programmatically in the storage configuration
form.

Kind: global function
Returns: jQuery - jQuery object for the building input field
Example

// Populate building based on department
eLabSDK.ready(function() {
  var storagePage = new eLabSDK.Page.StorageConfiguration({
    onReady: function() {
      var $dept = this.getDepartmentField();
      var $building = this.getBuildingField();
      
      $dept.on('change', function() {
        var dept = $(this).val();
        if (dept === 'Chemistry') {
          $building.val('Science Building A');
        }
      });
    }
  });
});

getFloorField()

Get the floor form field jQuery object.

This returns the jQuery-wrapped input field for the floor location property. Use this
to read, set, or validate the floor value programmatically in the storage configuration
form.

Kind: global function
Returns: jQuery - jQuery object for the floor input field
Example

// Set floor based on building selection
eLabSDK.ready(function() {
  var storagePage = new eLabSDK.Page.StorageConfiguration({
    onReady: function() {
      var $floor = this.getFloorField();
      $floor.val('2');
    }
  });
});

getRoomField()

Get the room form field jQuery object.

This returns the jQuery-wrapped input field for the room location property. Use this
to read, set, or validate the room value programmatically in the storage configuration
form.

Kind: global function
Returns: jQuery - jQuery object for the room input field
Example

// Auto-populate all location fields
eLabSDK.ready(function() {
  var storagePage = new eLabSDK.Page.StorageConfiguration({
    onReady: function(page, storageUnitID) {
      $.get('/api/locations/default', function(location) {
        page.getDepartmentField().val(location.department);
        page.getBuildingField().val(location.building);
        page.getFloorField().val(location.floor);
        page.getRoomField().val(location.room);
        
        console.log('Auto-populated location fields');
      });
    }
  });
});

© 2023 eLabNext