7604 |
25 Feb 19 |
nicklas |
/* $Id $ |
7604 |
25 Feb 19 |
nicklas |
2 |
------------------------------------------------------------------ |
7604 |
25 Feb 19 |
nicklas |
Copyright (C) 2013 Nicklas Nordborg |
7604 |
25 Feb 19 |
nicklas |
4 |
|
7604 |
25 Feb 19 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
7604 |
25 Feb 19 |
nicklas |
Available at http://base.thep.lu.se/ |
7604 |
25 Feb 19 |
nicklas |
7 |
|
7604 |
25 Feb 19 |
nicklas |
BASE is free software; you can redistribute it and/or |
7604 |
25 Feb 19 |
nicklas |
modify it under the terms of the GNU General Public License |
7604 |
25 Feb 19 |
nicklas |
as published by the Free Software Foundation; either version 3 |
7604 |
25 Feb 19 |
nicklas |
of the License, or (at your option) any later version. |
7604 |
25 Feb 19 |
nicklas |
12 |
|
7604 |
25 Feb 19 |
nicklas |
BASE is distributed in the hope that it will be useful, |
7604 |
25 Feb 19 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
7604 |
25 Feb 19 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
7604 |
25 Feb 19 |
nicklas |
GNU General Public License for more details. |
7604 |
25 Feb 19 |
nicklas |
17 |
|
7604 |
25 Feb 19 |
nicklas |
You should have received a copy of the GNU General Public License |
7604 |
25 Feb 19 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
7604 |
25 Feb 19 |
nicklas |
20 |
------------------------------------------------------------------ |
7604 |
25 Feb 19 |
nicklas |
21 |
|
7604 |
25 Feb 19 |
nicklas |
@author Nicklas |
7604 |
25 Feb 19 |
nicklas |
23 |
*/ |
7604 |
25 Feb 19 |
nicklas |
'use strict'; |
7604 |
25 Feb 19 |
nicklas |
25 |
|
7604 |
25 Feb 19 |
nicklas |
var Samples = function() |
7604 |
25 Feb 19 |
nicklas |
27 |
{ |
7604 |
25 Feb 19 |
nicklas |
var samples = {}; |
7604 |
25 Feb 19 |
nicklas |
29 |
|
7604 |
25 Feb 19 |
nicklas |
30 |
/** |
7604 |
25 Feb 19 |
nicklas |
Initialize the page. |
7604 |
25 Feb 19 |
nicklas |
32 |
*/ |
7604 |
25 Feb 19 |
nicklas |
samples.initPage = function() |
7604 |
25 Feb 19 |
nicklas |
34 |
{ |
7604 |
25 Feb 19 |
nicklas |
var pageId = Doc.getPageId(); |
7604 |
25 Feb 19 |
nicklas |
if (pageId == 'edit-page') |
7604 |
25 Feb 19 |
nicklas |
37 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Save + Close buttons |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnSave', samples.save); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
7604 |
25 Feb 19 |
nicklas |
41 |
|
7604 |
25 Feb 19 |
nicklas |
// Tab validation |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('settings.annotations', samples.loadAnnotationsFrame); |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabValidator('settings.info', samples.validateSample); |
7604 |
25 Feb 19 |
nicklas |
45 |
|
7604 |
25 Feb 19 |
nicklas |
// Quantity |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('original_quantity', 'keypress', Events.numberOnly); |
7604 |
25 Feb 19 |
nicklas |
48 |
|
7604 |
25 Feb 19 |
nicklas |
// Protocol |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('protocol_id.select', samples.selectProtocol); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('protocol_id', 'base-selected', Items.onItemSelected); |
7604 |
25 Feb 19 |
nicklas |
// Kit |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('kit_id.select', samples.selectKit); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('kit_id', 'base-selected', Items.onItemSelected); |
7604 |
25 Feb 19 |
nicklas |
// Subtype |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('subtype_id', 'change', samples.subtypeOnChange); |
7604 |
25 Feb 19 |
nicklas |
57 |
|
7604 |
25 Feb 19 |
nicklas |
// Bioplate and biowell |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('bioplate_id.select', samples.selectBioPlate); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('bioplate_id', 'base-selected', Items.onItemSelected); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('bioplate_id', 'change', samples.bioPlateOnChange); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('biowell_id.select', samples.selectBioWell); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('biowell_id', 'base-selected', Items.onItemSelected); |
7604 |
25 Feb 19 |
nicklas |
samples.initBioWell(); |
7604 |
25 Feb 19 |
nicklas |
65 |
|
7604 |
25 Feb 19 |
nicklas |
// Parent items |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('parentType.biosource', 'click', samples.parentTypeOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('parentType.sample', 'click', samples.parentTypeOnClick); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('biosource_id.select', samples.selectBioSource); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('biosource_id', 'base-selected', Items.onItemSelected); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('biosource_id', 'base-selected', samples.bioSourceOnChange); |
7604 |
25 Feb 19 |
nicklas |
72 |
|
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('samples', 'change', samples.samplesOnChange); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnAddSamples', samples.addSamplesOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('btnAddSamples', 'base-selected', samples.addSampleCallback); |
7604 |
25 Feb 19 |
nicklas |
76 |
|
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('used_quantity', 'keypress', Events.numberOnly); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('used_quantity', 'keyup', samples.usedQuantityOnChange); |
7604 |
25 Feb 19 |
nicklas |
79 |
|
7604 |
25 Feb 19 |
nicklas |
samples.parentTypeOnClick(); |
7604 |
25 Feb 19 |
nicklas |
81 |
|
7604 |
25 Feb 19 |
nicklas |
82 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (pageId == 'view-page') |
7604 |
25 Feb 19 |
nicklas |
84 |
{ |
7604 |
25 Feb 19 |
nicklas |
var itemId = Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
var attributes = {'item-type': 'SAMPLE', 'item-id': itemId}; |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnEdit', Buttons.editItem, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnDelete', Buttons.deleteItem, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnRestore', Buttons.restoreItem, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnUsingItems', Buttons.showUsingItems, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnDeletePermanently', Buttons.deleteItemPermanently, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnShare', Buttons.shareItem, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnSetOwner', Buttons.setOwner, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnNewSample', samples.newSample, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnNewExtract', samples.newExtract, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnExport', Buttons.runPlugin, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnImport', Buttons.runPlugin, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnRunPlugin', Buttons.runPlugin, attributes); |
7604 |
25 Feb 19 |
nicklas |
99 |
|
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('main.events', samples.viewEvents); |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('main.annotations', AnnotationsList.loadOnce); |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('main.overview', Overview.loadOnce); |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('main.history', History.loadOnce); |
7604 |
25 Feb 19 |
nicklas |
104 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (pageId == 'list-page') |
7604 |
25 Feb 19 |
nicklas |
106 |
{ |
7604 |
25 Feb 19 |
nicklas |
var attributes = {'item-type': 'SAMPLE'}; |
7604 |
25 Feb 19 |
nicklas |
var tableAttributes = {'table-id': 'samples'}; |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnNewItem', Buttons.newItem, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnDeleteItems', Buttons.deleteItems, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnRestoreItems', Buttons.restoreItems, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnShareItems', Buttons.shareItems, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnSetOwner', Buttons.setOwnerOfItems, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnColumns', Buttons.configureColumns, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnInheritAnnotations', Buttons.inheritAnnotations, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnExport', Buttons.runListPlugin, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnImport', Buttons.runListPlugin, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnRunPlugin', Buttons.runListPlugin, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnNewItemList', samples.newItemListOnClick); |
7813 |
19 May 20 |
nicklas |
Buttons.addClickHandler('btnAddToItemList', samples.addToItemListOnClick); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnPlaceOnPlate', samples.placeOnPlateOnClick); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnNewPooledItem', samples.newPooledItemOnClick); |
7604 |
25 Feb 19 |
nicklas |
123 |
|
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnOk', Buttons.returnSelected, tableAttributes); |
7604 |
25 Feb 19 |
nicklas |
126 |
} |
7604 |
25 Feb 19 |
nicklas |
127 |
} |
7604 |
25 Feb 19 |
nicklas |
128 |
|
7604 |
25 Feb 19 |
nicklas |
// Add event handlers to the 'new sample' icons |
7604 |
25 Feb 19 |
nicklas |
samples.initElements = function(element, autoInit) |
7604 |
25 Feb 19 |
nicklas |
131 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (autoInit == 'new-sample') |
7604 |
25 Feb 19 |
nicklas |
133 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler(element, samples.newSample); |
7604 |
25 Feb 19 |
nicklas |
135 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (autoInit == 'new-extract') |
7604 |
25 Feb 19 |
nicklas |
137 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler(element, samples.newExtract); |
7604 |
25 Feb 19 |
nicklas |
139 |
} |
7604 |
25 Feb 19 |
nicklas |
140 |
} |
7604 |
25 Feb 19 |
nicklas |
141 |
|
7604 |
25 Feb 19 |
nicklas |
142 |
/* |
7604 |
25 Feb 19 |
nicklas |
Create a new sample with the current sample as the parent |
7604 |
25 Feb 19 |
nicklas |
144 |
*/ |
7604 |
25 Feb 19 |
nicklas |
samples.newSample = function(event) |
7604 |
25 Feb 19 |
nicklas |
146 |
{ |
7604 |
25 Feb 19 |
nicklas |
var sampleId = Data.int(event.currentTarget, 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
Items.newItem('SAMPLE', '&sample_id='+sampleId); |
7604 |
25 Feb 19 |
nicklas |
149 |
} |
7604 |
25 Feb 19 |
nicklas |
150 |
|
7604 |
25 Feb 19 |
nicklas |
151 |
/* |
7604 |
25 Feb 19 |
nicklas |
Create a new extract with the current sample as the parent |
7604 |
25 Feb 19 |
nicklas |
153 |
*/ |
7604 |
25 Feb 19 |
nicklas |
samples.newExtract = function(event) |
7604 |
25 Feb 19 |
nicklas |
155 |
{ |
7604 |
25 Feb 19 |
nicklas |
var sampleId = Data.int(event.currentTarget, 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
Items.newItem('EXTRACT', '&sample_id='+sampleId); |
7604 |
25 Feb 19 |
nicklas |
158 |
} |
7604 |
25 Feb 19 |
nicklas |
159 |
|
7604 |
25 Feb 19 |
nicklas |
// Create a new item list with the selected items as members |
7604 |
25 Feb 19 |
nicklas |
samples.newItemListOnClick = function() |
7604 |
25 Feb 19 |
nicklas |
162 |
{ |
7604 |
25 Feb 19 |
nicklas |
var controller = Items.getController('ITEMLIST'); |
7604 |
25 Feb 19 |
nicklas |
Table.submitToPopup('samples', 'CreateItemList', controller.width, controller.height); |
7604 |
25 Feb 19 |
nicklas |
165 |
} |
7604 |
25 Feb 19 |
nicklas |
166 |
|
7813 |
19 May 20 |
nicklas |
// Add selected samples to an existing item list |
7813 |
19 May 20 |
nicklas |
samples.addToItemListOnClick = function() |
7813 |
19 May 20 |
nicklas |
169 |
{ |
7813 |
19 May 20 |
nicklas |
Table.submitToPopup('samples', 'AddItemsToList', 450, 300); |
7813 |
19 May 20 |
nicklas |
171 |
} |
7813 |
19 May 20 |
nicklas |
172 |
|
7604 |
25 Feb 19 |
nicklas |
samples.placeOnPlateOnClick = function() |
7604 |
25 Feb 19 |
nicklas |
174 |
{ |
7604 |
25 Feb 19 |
nicklas |
Table.submitToPopup('samples', 'PlaceOnPlate', 900, 600); |
7604 |
25 Feb 19 |
nicklas |
176 |
} |
7604 |
25 Feb 19 |
nicklas |
177 |
|
7604 |
25 Feb 19 |
nicklas |
samples.newPooledItemOnClick = function() |
7604 |
25 Feb 19 |
nicklas |
179 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (!Table.checkIfSelected('samples')) |
7604 |
25 Feb 19 |
nicklas |
181 |
{ |
7604 |
25 Feb 19 |
nicklas |
return; |
7604 |
25 Feb 19 |
nicklas |
183 |
} |
7604 |
25 Feb 19 |
nicklas |
Table.submitToPopup('samples', 'NewPooledItem', 750, 500); |
7604 |
25 Feb 19 |
nicklas |
185 |
} |
7604 |
25 Feb 19 |
nicklas |
186 |
|
7604 |
25 Feb 19 |
nicklas |
samples.viewEvents = function() |
7604 |
25 Feb 19 |
nicklas |
188 |
{ |
7604 |
25 Feb 19 |
nicklas |
var sampleId = Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
var url = '../events/index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=List&biomaterial_id='+sampleId; |
7604 |
25 Feb 19 |
nicklas |
url += '&biomaterial_type=SAMPLE'; |
7604 |
25 Feb 19 |
nicklas |
location.replace(url); |
7604 |
25 Feb 19 |
nicklas |
194 |
} |
7604 |
25 Feb 19 |
nicklas |
195 |
|
7604 |
25 Feb 19 |
nicklas |
samples.validateSample = function() |
7604 |
25 Feb 19 |
nicklas |
197 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['sample']; |
7604 |
25 Feb 19 |
nicklas |
if (Strings.trim(frm.name.value) == '') |
7604 |
25 Feb 19 |
nicklas |
200 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.showNotification(frm.name, 'You must enter a name'); |
7604 |
25 Feb 19 |
nicklas |
return false; |
7604 |
25 Feb 19 |
nicklas |
203 |
} |
7604 |
25 Feb 19 |
nicklas |
if (Strings.trim(frm.bioplate_id.value) != 0 && Strings.trim(frm.biowell_id.value) == 0) |
7604 |
25 Feb 19 |
nicklas |
205 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.showNotification('biowell_id.select', 'You must choose a biowell from the bioplate'); |
7604 |
25 Feb 19 |
nicklas |
return false; |
7604 |
25 Feb 19 |
nicklas |
208 |
} |
7604 |
25 Feb 19 |
nicklas |
return true; |
7604 |
25 Feb 19 |
nicklas |
210 |
} |
7604 |
25 Feb 19 |
nicklas |
211 |
|
7604 |
25 Feb 19 |
nicklas |
samples.save = function() |
7604 |
25 Feb 19 |
nicklas |
213 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['sample']; |
7604 |
25 Feb 19 |
nicklas |
if (TabControl.validateActiveTab('settings')) |
7604 |
25 Feb 19 |
nicklas |
216 |
{ |
7604 |
25 Feb 19 |
nicklas |
Annotations.saveModifiedAnnotationsToForm(frm); |
7604 |
25 Feb 19 |
nicklas |
Link.exportActions('samples'); |
7604 |
25 Feb 19 |
nicklas |
frm.submit(); |
7604 |
25 Feb 19 |
nicklas |
220 |
} |
7604 |
25 Feb 19 |
nicklas |
221 |
} |
7604 |
25 Feb 19 |
nicklas |
222 |
|
7604 |
25 Feb 19 |
nicklas |
samples.selectBioPlate = function() |
7604 |
25 Feb 19 |
nicklas |
224 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['sample']; |
7604 |
25 Feb 19 |
nicklas |
var url = '&resetTemporary=1'; |
7604 |
25 Feb 19 |
nicklas |
url += '&tmpfilter:INT:bioPlateType.bioMaterialType='+encodeURIComponent('|'+Data.get('page-data', 'sample-type')); |
7604 |
25 Feb 19 |
nicklas |
var subtypeId = ItemSubtype.getSubtypeId('subtype_id'); |
7604 |
25 Feb 19 |
nicklas |
// Restrict to plates with the given subtype |
7604 |
25 Feb 19 |
nicklas |
url += '&tmpfilter:INT:bioPlateType.itemSubtype='+encodeURIComponent(subtypeId ? '|' + subtypeId : '='); |
7604 |
25 Feb 19 |
nicklas |
url += '&tmpfilter:BOOLEAN:destroyed=false'; |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('BIOPLATE', 'bioplate_id', 0, url); |
7604 |
25 Feb 19 |
nicklas |
233 |
} |
7604 |
25 Feb 19 |
nicklas |
234 |
|
7604 |
25 Feb 19 |
nicklas |
235 |
|
7604 |
25 Feb 19 |
nicklas |
samples.bioPlateOnChange = function() |
7604 |
25 Feb 19 |
nicklas |
237 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['sample']; |
7604 |
25 Feb 19 |
nicklas |
var list = frm.bioplate_id; |
7604 |
25 Feb 19 |
nicklas |
frm.biowell_id.selectedIndex=0; |
7604 |
25 Feb 19 |
nicklas |
frm.biowell_id.remove(1); |
7604 |
25 Feb 19 |
nicklas |
242 |
} |
7604 |
25 Feb 19 |
nicklas |
243 |
|
7604 |
25 Feb 19 |
nicklas |
samples.initBioWell = function() |
7604 |
25 Feb 19 |
nicklas |
245 |
{ |
7604 |
25 Feb 19 |
nicklas |
var biowell = JSON.parse(Data.get('page-data', 'biowell')); |
7604 |
25 Feb 19 |
nicklas |
if (biowell) |
7604 |
25 Feb 19 |
nicklas |
248 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['sample']; |
7604 |
25 Feb 19 |
nicklas |
var option = new Option(biowell.location, -biowell.id, true, true); |
7604 |
25 Feb 19 |
nicklas |
frm.biowell_id[1] = option; |
7604 |
25 Feb 19 |
nicklas |
252 |
} |
7604 |
25 Feb 19 |
nicklas |
253 |
} |
7604 |
25 Feb 19 |
nicklas |
254 |
|
7604 |
25 Feb 19 |
nicklas |
samples.selectBioWell = function() |
7604 |
25 Feb 19 |
nicklas |
256 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['sample']; |
7604 |
25 Feb 19 |
nicklas |
var bioplateId = Math.abs(parseInt(frm.bioplate_id.value)) |
7604 |
25 Feb 19 |
nicklas |
if (bioplateId == 0) |
7604 |
25 Feb 19 |
nicklas |
260 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.showNotification('bioplate_id.select', 'You must first select a bioplate', null, 'pointer-below'); |
7604 |
25 Feb 19 |
nicklas |
return; |
7604 |
25 Feb 19 |
nicklas |
263 |
} |
7604 |
25 Feb 19 |
nicklas |
264 |
|
7604 |
25 Feb 19 |
nicklas |
var url = '&bioplate_id='+bioplateId; |
7604 |
25 Feb 19 |
nicklas |
url += '&resetTemporary=1&tmpfilter:STRING:$mbm.name='+escape('='); |
7604 |
25 Feb 19 |
nicklas |
url += '&tmpfilter:STRING:originalBioMaterial.name='+escape('='); |
7604 |
25 Feb 19 |
nicklas |
url += '&columns=row,column'; |
7604 |
25 Feb 19 |
nicklas |
269 |
|
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('BIOWELL', 'biowell_id', 0, url); |
7604 |
25 Feb 19 |
nicklas |
271 |
} |
7604 |
25 Feb 19 |
nicklas |
272 |
|
7604 |
25 Feb 19 |
nicklas |
samples.loadAnnotationsFrame = function() |
7604 |
25 Feb 19 |
nicklas |
274 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['sample']; |
7604 |
25 Feb 19 |
nicklas |
var protocolId = 0; |
7604 |
25 Feb 19 |
nicklas |
if (frm.protocol_id.length > 0 && !frm.protocol_id.disabled) |
7604 |
25 Feb 19 |
nicklas |
278 |
{ |
7604 |
25 Feb 19 |
nicklas |
protocolId = Math.abs(parseInt(frm.protocol_id.value)); |
7604 |
25 Feb 19 |
nicklas |
280 |
} |
7604 |
25 Feb 19 |
nicklas |
Annotations.autoLoadEditFrame(protocolId, ItemSubtype.getSubtypeId('subtype_id'), samples.getParents()); |
7604 |
25 Feb 19 |
nicklas |
282 |
} |
7604 |
25 Feb 19 |
nicklas |
283 |
|
7604 |
25 Feb 19 |
nicklas |
samples.getParents = function() |
7604 |
25 Feb 19 |
nicklas |
285 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['sample']; |
7604 |
25 Feb 19 |
nicklas |
var parents = []; |
7604 |
25 Feb 19 |
nicklas |
if (frm.parentType[0].checked) |
7604 |
25 Feb 19 |
nicklas |
289 |
{ |
7604 |
25 Feb 19 |
nicklas |
var bioSourceId = Math.abs(parseInt(frm.biosource_id.value)); |
7604 |
25 Feb 19 |
nicklas |
if (bioSourceId > 0) parents[parents.length] = 'BIOSOURCE:'+bioSourceId; |
7604 |
25 Feb 19 |
nicklas |
292 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
294 |
{ |
7604 |
25 Feb 19 |
nicklas |
var ids = Link.getIdsInList(frm.samples, 'SAMPLE'); |
7604 |
25 Feb 19 |
nicklas |
if (ids.length > 0) |
7604 |
25 Feb 19 |
nicklas |
297 |
{ |
7604 |
25 Feb 19 |
nicklas |
parents[parents.length] = 'SAMPLE:'+ids.join(':'); |
7604 |
25 Feb 19 |
nicklas |
299 |
} |
7604 |
25 Feb 19 |
nicklas |
300 |
} |
7604 |
25 Feb 19 |
nicklas |
var protocolId = Math.abs(parseInt(frm.protocol_id.value)); |
7604 |
25 Feb 19 |
nicklas |
if (protocolId > 0) parents[parents.length] = 'PROTOCOL:'+protocolId; |
7604 |
25 Feb 19 |
nicklas |
var kitId = Math.abs(parseInt(frm.kit_id.value)); |
7604 |
25 Feb 19 |
nicklas |
if (kitId > 0) parents[parents.length] = 'KIT:'+kitId; |
7604 |
25 Feb 19 |
nicklas |
305 |
|
7604 |
25 Feb 19 |
nicklas |
return parents; |
7604 |
25 Feb 19 |
nicklas |
307 |
} |
7604 |
25 Feb 19 |
nicklas |
308 |
|
7604 |
25 Feb 19 |
nicklas |
samples.selectProtocol = function() |
7604 |
25 Feb 19 |
nicklas |
310 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['sample']; |
7604 |
25 Feb 19 |
nicklas |
var url = '&resetTemporary=1'; |
7604 |
25 Feb 19 |
nicklas |
url += ItemSubtype.createRelatedFilter('subtype_id', 'PROTOCOL', Data.int('page-data', 'sampling-protocoltype-id')); |
7604 |
25 Feb 19 |
nicklas |
if (frm.protocol_id.length > 1) |
7604 |
25 Feb 19 |
nicklas |
315 |
{ |
7604 |
25 Feb 19 |
nicklas |
var id = Math.abs(parseInt(frm.protocol_id[1].value)); |
7604 |
25 Feb 19 |
nicklas |
url += '&item_id='+id; |
7604 |
25 Feb 19 |
nicklas |
318 |
} |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('PROTOCOL', 'protocol_id', 0, url); |
7604 |
25 Feb 19 |
nicklas |
320 |
} |
7604 |
25 Feb 19 |
nicklas |
321 |
|
7604 |
25 Feb 19 |
nicklas |
samples.selectKit = function() |
7604 |
25 Feb 19 |
nicklas |
323 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['sample']; |
7604 |
25 Feb 19 |
nicklas |
var url = '&resetTemporary=1'; |
7604 |
25 Feb 19 |
nicklas |
url += '&tmpfilter:BOOLEAN:inactive=0'; |
7604 |
25 Feb 19 |
nicklas |
url += ItemSubtype.createRelatedFilter('subtype_id', 'KIT', Data.int('page-data', 'sampling-kittype-id')); |
7604 |
25 Feb 19 |
nicklas |
if (frm.kit_id.length > 1) |
7604 |
25 Feb 19 |
nicklas |
329 |
{ |
7604 |
25 Feb 19 |
nicklas |
var id = Math.abs(parseInt(frm.kit_id[1].value)); |
7604 |
25 Feb 19 |
nicklas |
url += '&item_id='+id; |
7604 |
25 Feb 19 |
nicklas |
332 |
} |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('KIT', 'kit_id', 0, url); |
7604 |
25 Feb 19 |
nicklas |
334 |
} |
7604 |
25 Feb 19 |
nicklas |
335 |
|
7604 |
25 Feb 19 |
nicklas |
samples.subtypeOnChange = function() |
7604 |
25 Feb 19 |
nicklas |
337 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['sample']; |
7604 |
25 Feb 19 |
nicklas |
var subtypeId = ItemSubtype.getSubtypeId('subtype_id'); |
7604 |
25 Feb 19 |
nicklas |
var recentInfo = ItemSubtype.getRelatedProjectDefaultAndRecentItems('SAMPLE', subtypeId, ['PROTOCOL', 'KIT', 'BIOPLATE', 'BIOSOURCE', 'SAMPLE']); |
7604 |
25 Feb 19 |
nicklas |
ItemSubtype.updateSelectionList(frm.protocol_id, recentInfo.PROTOCOL['recent'], recentInfo.PROTOCOL['default']); |
7604 |
25 Feb 19 |
nicklas |
ItemSubtype.updateSelectionList(frm.kit_id, recentInfo.KIT['recent']); |
7604 |
25 Feb 19 |
nicklas |
ItemSubtype.updateSelectionList(frm.bioplate_id, recentInfo.BIOPLATE['recent']); |
7604 |
25 Feb 19 |
nicklas |
344 |
} |
7604 |
25 Feb 19 |
nicklas |
345 |
|
7604 |
25 Feb 19 |
nicklas |
samples.parentTypeOnClick = function() |
7604 |
25 Feb 19 |
nicklas |
347 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['sample']; |
7604 |
25 Feb 19 |
nicklas |
var useSamples = frm.parentType[1].checked; |
7604 |
25 Feb 19 |
nicklas |
frm.biosource_id.disabled = useSamples; |
7604 |
25 Feb 19 |
nicklas |
frm.samples.disabled = !useSamples; |
7604 |
25 Feb 19 |
nicklas |
frm.used_quantity.disabled = !useSamples; |
7604 |
25 Feb 19 |
nicklas |
353 |
} |
7604 |
25 Feb 19 |
nicklas |
354 |
|
7604 |
25 Feb 19 |
nicklas |
samples.selectBioSource = function() |
7604 |
25 Feb 19 |
nicklas |
356 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['sample']; |
7604 |
25 Feb 19 |
nicklas |
var url = '&resetTemporary=1'; |
7604 |
25 Feb 19 |
nicklas |
url += ItemSubtype.createRelatedFilter('subtype_id', 'BIOSOURCE'); |
7604 |
25 Feb 19 |
nicklas |
if (frm.biosource_id.length > 1) |
7604 |
25 Feb 19 |
nicklas |
361 |
{ |
7604 |
25 Feb 19 |
nicklas |
var id = Math.abs(parseInt(frm.biosource_id[1].value)); |
7604 |
25 Feb 19 |
nicklas |
url += '&item_id='+id; |
7604 |
25 Feb 19 |
nicklas |
364 |
} |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('BIOSOURCE', 'biosource_id', 0, url); |
7604 |
25 Feb 19 |
nicklas |
366 |
} |
7604 |
25 Feb 19 |
nicklas |
367 |
|
7604 |
25 Feb 19 |
nicklas |
samples.bioSourceOnChange = function(event) |
7604 |
25 Feb 19 |
nicklas |
369 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['sample']; |
7604 |
25 Feb 19 |
nicklas |
frm.parentType[0].checked = true; |
7604 |
25 Feb 19 |
nicklas |
frm.parentType[1].checked = false; |
7604 |
25 Feb 19 |
nicklas |
samples.parentTypeOnClick(); |
7604 |
25 Feb 19 |
nicklas |
374 |
} |
7604 |
25 Feb 19 |
nicklas |
375 |
|
7604 |
25 Feb 19 |
nicklas |
samples.addSamplesOnClick = function(event) |
7604 |
25 Feb 19 |
nicklas |
377 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['sample']; |
7604 |
25 Feb 19 |
nicklas |
var currentSamples = Link.getIdsInList(frm.samples, 'SAMPLE'); |
7604 |
25 Feb 19 |
nicklas |
var url = "&resetTemporary=1&exclude="+currentSamples.join(','); |
7604 |
25 Feb 19 |
nicklas |
url += ItemSubtype.createRelatedFilter('subtype_id', 'SAMPLE'); |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('SAMPLE', event.currentTarget.id, 1, url); |
7604 |
25 Feb 19 |
nicklas |
383 |
} |
7604 |
25 Feb 19 |
nicklas |
384 |
|
7604 |
25 Feb 19 |
nicklas |
samples.addSampleCallback = function(event) |
7604 |
25 Feb 19 |
nicklas |
386 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['sample']; |
7604 |
25 Feb 19 |
nicklas |
event.detail.name += ' [-]'; |
7604 |
25 Feb 19 |
nicklas |
Link.addItem('samples', 'SAMPLE', event.detail); |
7604 |
25 Feb 19 |
nicklas |
if (event.detail.remaining == 0) |
7604 |
25 Feb 19 |
nicklas |
391 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm.parentType[0].checked = false; |
7604 |
25 Feb 19 |
nicklas |
frm.parentType[1].checked = true; |
7604 |
25 Feb 19 |
nicklas |
samples.parentTypeOnClick(); |
7604 |
25 Feb 19 |
nicklas |
395 |
} |
7604 |
25 Feb 19 |
nicklas |
396 |
} |
7604 |
25 Feb 19 |
nicklas |
397 |
|
7604 |
25 Feb 19 |
nicklas |
samples.usedQuantityOnChange = function() |
7604 |
25 Feb 19 |
nicklas |
399 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['sample']; |
7604 |
25 Feb 19 |
nicklas |
var usedQuantity = frm.used_quantity.value; |
7604 |
25 Feb 19 |
nicklas |
var displayQuantity = usedQuantity == '' ? '-' : usedQuantity+' µg'; |
7604 |
25 Feb 19 |
nicklas |
for (var i = 0; i < frm.samples.length; i++) |
7604 |
25 Feb 19 |
nicklas |
404 |
{ |
7604 |
25 Feb 19 |
nicklas |
var option = frm.samples[i]; |
7604 |
25 Feb 19 |
nicklas |
if (option.selected && option.item.id) |
7604 |
25 Feb 19 |
nicklas |
407 |
{ |
7604 |
25 Feb 19 |
nicklas |
option.item.value = usedQuantity; |
7604 |
25 Feb 19 |
nicklas |
var text = option.text.replace(/\[.*\]/, '['+displayQuantity+']'); |
7604 |
25 Feb 19 |
nicklas |
option.text = text; |
7604 |
25 Feb 19 |
nicklas |
411 |
} |
7604 |
25 Feb 19 |
nicklas |
412 |
} |
7604 |
25 Feb 19 |
nicklas |
413 |
} |
7604 |
25 Feb 19 |
nicklas |
414 |
|
7604 |
25 Feb 19 |
nicklas |
samples.samplesOnChange = function() |
7604 |
25 Feb 19 |
nicklas |
416 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['sample']; |
7604 |
25 Feb 19 |
nicklas |
var item = frm.samples[frm.samples.selectedIndex].item; |
7604 |
25 Feb 19 |
nicklas |
if (item && item.id && item.value != undefined) |
7604 |
25 Feb 19 |
nicklas |
420 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm.used_quantity.value = item.value; |
7604 |
25 Feb 19 |
nicklas |
422 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
424 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm.used_quantity.value = ''; |
7604 |
25 Feb 19 |
nicklas |
426 |
} |
7604 |
25 Feb 19 |
nicklas |
frm.used_quantity.focus(); |
7604 |
25 Feb 19 |
nicklas |
428 |
} |
7604 |
25 Feb 19 |
nicklas |
429 |
|
7604 |
25 Feb 19 |
nicklas |
return samples; |
7604 |
25 Feb 19 |
nicklas |
431 |
}(); |
7604 |
25 Feb 19 |
nicklas |
432 |
|
7604 |
25 Feb 19 |
nicklas |
Doc.addElementInitializer(Samples.initElements); |
7604 |
25 Feb 19 |
nicklas |
Doc.onLoad(Samples.initPage); |