eLabSDK.Inventory.SampleSeries
Functions
| Name | Description |
|---|---|
| _create() | Creates the sampleSeries |
| addSamples(sampleIDs, [fnWhenReady]) | Add samples to this sample series. |
This adds one or more samples to the current sample series. Samples can be specified as
individual sample IDs, an array of IDs, or a comma-separated string of IDs. The series is
automatically reloaded after adding samples to reflect the changes. Use this to build or
expand sample series for clones, replicates, or related samples that should be grouped
together.
removeSamples(sampleIDs, [fnWhenReady]) | Remove samples from this sample series.
This removes one or more samples from the current sample series. Samples can be specified
as individual sample IDs, an array of IDs, or a comma-separated string of IDs. The series
is automatically reloaded after removing samples to reflect the changes. Note that this
removes samples from the series but does not delete the samples themselves - they continue
to exist independently.
getSamples() | Get all samples in this sample series.
This retrieves the array of sample objects that belong to this series. Each sample object
contains sample details including ID, name, type, quantity, location, and other properties.
Use this to access information about all members of the series, display them in UI, or
perform operations on the entire series.
remove([fnWhenReady]) | Delete this sample series.
This permanently deletes the sample series from the system. The samples themselves are NOT
deleted - they continue to exist as individual samples. Only the series grouping is removed.
This operation cannot be undone. Use this when a series is no longer needed or was created
in error.
setName(name) | Set a new name for this sample series.
This updates the series name in the local data object. The new name is NOT saved to the
database until you call save(). Use this to prepare changes before saving them. Set the
desired name, then call save() to persist the change to the database.
save([fnWhenReady]) | Save changes to this sample series.
This persists any changes made to the series (such as name changes via setName()) to the
database. The series is updated via PATCH request with the current data. Use this after
making changes with setter methods like setName() to commit those changes to the database.
_create()
Creates the sampleSeries
Kind: global function
Returns: object - JQuery Object
addSamples(sampleIDs, [fnWhenReady])
Add samples to this sample series.
This adds one or more samples to the current sample series. Samples can be specified as
individual sample IDs, an array of IDs, or a comma-separated string of IDs. The series is
automatically reloaded after adding samples to reflect the changes. Use this to build or
expand sample series for clones, replicates, or related samples that should be grouped
together.
Kind: global function
| Param | Type | Description |
|---|---|---|
| sampleIDs | number | Array.<number> | string | Sample ID(s) to add: single ID, array of IDs, or comma-separated string |
| [fnWhenReady] | function | Optional callback executed when samples are added successfully |
Example
// Add single sample to series
var series = new eLabSDK.Inventory.SampleSeries({
seriesID: 123,
onLoaded: function() {
this.addSamples(456, function() {
console.log('Sample 456 added to series');
});
}
});
Example
// Add multiple samples as array
var series = new eLabSDK.Inventory.SampleSeries({
seriesID: 123,
onLoaded: function() {
var samplesToAdd = [456, 457, 458];
this.addSamples(samplesToAdd, function() {
console.log('Added ' + samplesToAdd.length + ' samples to series');
var allSamples = this.getSamples();
console.log('Series now contains: ' + allSamples.length + ' samples');
});
}
});
Example
// Add samples as comma-separated string
var series = new eLabSDK.Inventory.SampleSeries({
seriesID: 123,
onLoaded: function() {
var sampleIds = '789,790,791';
this.addSamples(sampleIds, function() {
console.log('Samples added successfully');
});
}
});
removeSamples(sampleIDs, [fnWhenReady])
Remove samples from this sample series.
This removes one or more samples from the current sample series. Samples can be specified
as individual sample IDs, an array of IDs, or a comma-separated string of IDs. The series
is automatically reloaded after removing samples to reflect the changes. Note that this
removes samples from the series but does not delete the samples themselves - they continue
to exist independently.
Kind: global function
| Param | Type | Description |
|---|---|---|
| sampleIDs | number | Array.<number> | string | Sample ID(s) to remove: single ID, array of IDs, or comma-separated string |
| [fnWhenReady] | function | Optional callback executed when samples are removed successfully |
Example
// Remove single sample from series
var series = new eLabSDK.Inventory.SampleSeries({
seriesID: 123,
onLoaded: function() {
this.removeSamples(456, function() {
console.log('Sample 456 removed from series');
var remaining = this.getSamples();
console.log('Remaining samples: ' + remaining.length);
});
}
});
Example
// Remove multiple samples as array
var series = new eLabSDK.Inventory.SampleSeries({
seriesID: 123,
onLoaded: function() {
var samplesToRemove = [456, 457, 458];
this.removeSamples(samplesToRemove, function() {
console.log('Removed ' + samplesToRemove.length + ' samples from series');
});
}
});
Example
// Remove samples based on condition
var series = new eLabSDK.Inventory.SampleSeries({
seriesID: 123,
onLoaded: function() {
var samples = this.getSamples();
var toRemove = samples.filter(function(s) {
return s.quantity < 10; // Remove low-quantity samples
}).map(function(s) {
return s.sampleID;
});
if (toRemove.length > 0) {
this.removeSamples(toRemove, function() {
console.log('Removed ' + toRemove.length + ' low-quantity samples');
});
}
}
});
getSamples()
Get all samples in this sample series.
This retrieves the array of sample objects that belong to this series. Each sample object
contains sample details including ID, name, type, quantity, location, and other properties.
Use this to access information about all members of the series, display them in UI, or
perform operations on the entire series.
Kind: global function
Returns: Array.<Object> - Array of sample objects belonging to this series
Example
// Get and display all samples in series
var series = new eLabSDK.Inventory.SampleSeries({
seriesID: 123,
onLoaded: function() {
var samples = this.getSamples();
console.log('Series contains ' + samples.length + ' samples');
samples.forEach(function(sample) {
console.log('- ' + sample.name + ' (ID: ' + sample.sampleID + ')');
});
}
});
Example
// Calculate total quantity in series
var series = new eLabSDK.Inventory.SampleSeries({
seriesID: 456,
onLoaded: function() {
var samples = this.getSamples();
var totalQuantity = samples.reduce(function(sum, sample) {
return sum + (sample.quantity || 0);
}, 0);
console.log('Total quantity in series: ' + totalQuantity);
}
});
Example
// Filter samples by condition
var series = new eLabSDK.Inventory.SampleSeries({
seriesID: 789,
onLoaded: function() {
var samples = this.getSamples();
var activeSamples = samples.filter(function(s) {
return s.archived === false;
});
console.log('Active samples: ' + activeSamples.length);
}
});
remove([fnWhenReady])
Delete this sample series.
This permanently deletes the sample series from the system. The samples themselves are NOT
deleted - they continue to exist as individual samples. Only the series grouping is removed.
This operation cannot be undone. Use this when a series is no longer needed or was created
in error.
Kind: global function
| Param | Type | Description |
|---|---|---|
| [fnWhenReady] | function | Optional callback executed when series is deleted successfully |
Example
// Delete a sample series
var series = new eLabSDK.Inventory.SampleSeries({
seriesID: 123,
onLoaded: function() {
if (confirm('Delete this series? Samples will not be deleted.')) {
this.remove(function() {
console.log('Series deleted successfully');
alert('Series removed');
});
}
}
});
Example
// Delete series with confirmation
var series = new eLabSDK.Inventory.SampleSeries({
seriesID: 456,
onLoaded: function() {
var samples = this.getSamples();
var message = 'Delete series with ' + samples.length + ' samples?';
if (confirm(message)) {
this.remove(function() {
console.log('Series deleted. Samples remain intact.');
window.location.href = '/members/inventory/samples/';
});
}
}
});
setName(name)
Set a new name for this sample series.
This updates the series name in the local data object. The new name is NOT saved to the
database until you call save(). Use this to prepare changes before saving them. Set the
desired name, then call save() to persist the change to the database.
Kind: global function
| Param | Type | Description |
|---|---|---|
| name | string | The new name for the sample series |
Example
// Rename a sample series
var series = new eLabSDK.Inventory.SampleSeries({
seriesID: 123,
onLoaded: function() {
console.log('Current name: ' + this.data.name);
this.setName('Updated Series Name');
this.save(function() {
console.log('Series renamed successfully');
});
}
});
Example
// Interactive rename
var series = new eLabSDK.Inventory.SampleSeries({
seriesID: 456,
onLoaded: function() {
var currentName = this.data.name;
var newName = prompt('Enter new series name:', currentName);
if (newName && newName !== currentName) {
this.setName(newName);
this.save(function() {
alert('Series renamed to: ' + newName);
});
}
}
});
save([fnWhenReady])
Save changes to this sample series.
This persists any changes made to the series (such as name changes via setName()) to the
database. The series is updated via PATCH request with the current data. Use this after
making changes with setter methods like setName() to commit those changes to the database.
Kind: global function
| Param | Type | Description |
|---|---|---|
| [fnWhenReady] | function | Optional callback executed when save completes successfully |
Example
// Rename and save series
var series = new eLabSDK.Inventory.SampleSeries({
seriesID: 123,
onLoaded: function() {
this.setName('New Series Name');
this.save(function() {
console.log('Series saved successfully');
alert('Changes saved');
});
}
});
Example
// Update multiple properties and save
var series = new eLabSDK.Inventory.SampleSeries({
seriesID: 456,
onLoaded: function() {
// Update name
this.setName('Clone Series A - Updated');
// Save changes
this.save(function(response) {
console.log('Save response:', response);
console.log('Series updated successfully');
});
}
});
Example
// Save with error handling
var series = new eLabSDK.Inventory.SampleSeries({
seriesID: 789,
onLoaded: function() {
this.setName('Updated Name');
this.save(function(response) {
if (response.success) {
alert('Series saved');
} else {
alert('Save failed');
}
});
}
});
.create(config)
Create a new sample series with the specified samples.
This static method creates a new sample series and adds the specified samples to it. The series
can be given a name and must include at least one sample ID. Samples can be specified as an array,
comma-separated string, or single ID. Use this to group related samples (clones, replicates, etc.)
into a series for easier management and tracking.
Kind: static function
Returns: eLabSDK.Inventory.SampleSeries - New SampleSeries instance
| Param | Type | Default | Description |
|---|---|---|---|
| config | Object | Configuration object for the new series | |
| [config.name] | string | '''' | Optional name for the series |
| config.sampleID | number | Array.<number> | string | Sample ID(s) to include: single ID, array of IDs, or comma-separated string | |
| [config.fnWhenReady] | function | Optional callback executed when series is created. Receives response with seriesID. |
Example
// Create series with multiple samples
eLabSDK.Inventory.SampleSeries.create({
name: 'Clone Series A',
sampleID: [123, 124, 125],
fnWhenReady: function(response) {
console.log('Series created with ID: ' + response.sampleSeriesId);
alert('Series created successfully');
}
});
Example
// Create series with single sample
eLabSDK.Inventory.SampleSeries.create({
name: 'Replicate Set 1',
sampleID: 456,
fnWhenReady: function(response) {
var seriesID = response.sampleSeriesId;
console.log('Created series: ' + seriesID);
// Load the series to add more samples
var series = new eLabSDK.Inventory.SampleSeries({
seriesID: seriesID,
onLoaded: function() {
this.addSamples([457, 458]);
}
});
}
});
Example
// Create series with comma-separated IDs
eLabSDK.Inventory.SampleSeries.create({
name: 'Batch Production',
sampleID: '789,790,791,792',
fnWhenReady: function(response) {
console.log('Series ID: ' + response.sampleSeriesId);
window.location.href = '/members/inventory/samples/#viewSeries/' + response.sampleSeriesId;
}
});
Example
// Create series and immediately manipulate it
eLabSDK.Inventory.SampleSeries.create({
name: 'Experiment Samples',
sampleID: [100, 101, 102],
fnWhenReady: function(response) {
var series = new eLabSDK.Inventory.SampleSeries({
seriesID: response.sampleSeriesId,
onLoaded: function() {
console.log('Series has ' + this.getSamples().length + ' samples');
}
});
}
});
© 2023 eLabNext
Updated about 3 hours ago