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 Extracts = function() |
7604 |
25 Feb 19 |
nicklas |
27 |
{ |
7604 |
25 Feb 19 |
nicklas |
var extracts = {}; |
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 |
extracts.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', extracts.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', extracts.loadAnnotationsFrame); |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabValidator('settings.info', extracts.validateExtract); |
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 |
// Tag |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('tag_id.select', extracts.selectTag); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('tag_id', 'base-selected', Items.onItemSelected); |
7604 |
25 Feb 19 |
nicklas |
52 |
|
7604 |
25 Feb 19 |
nicklas |
// Protocol |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('protocol_id.select', extracts.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', extracts.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', extracts.subtypeOnChange); |
7604 |
25 Feb 19 |
nicklas |
61 |
|
7604 |
25 Feb 19 |
nicklas |
// Bioplate and biowell |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('bioplate_id.select', extracts.selectBioPlate); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('bioplate_id', 'base-selected', Items.onItemSelected); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('bioplate_id', 'change', extracts.bioPlateOnChange); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('biowell_id.select', extracts.selectBioWell); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('biowell_id', 'base-selected', Items.onItemSelected); |
7604 |
25 Feb 19 |
nicklas |
extracts.initBioWell(); |
7604 |
25 Feb 19 |
nicklas |
69 |
|
7604 |
25 Feb 19 |
nicklas |
// Parent items |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('parentType.sample', 'click', extracts.parentTypeOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('parentType.extract', 'click', extracts.parentTypeOnClick); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('sample_id.select', extracts.selectSample); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('sample_id', 'base-selected', Items.onItemSelected); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('sample_id', 'base-selected', extracts.sampleOnChange); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('used_from_sample', 'keypress', Events.numberOnly); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('used_from_sample', 'blur', extracts.usedFromSampleOnBlur); |
7604 |
25 Feb 19 |
nicklas |
78 |
|
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('extracts', 'change', extracts.extractsOnChange); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnAddExtracts', extracts.addExtractsOnClick); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('btnAddExtracts', 'base-selected', extracts.addExtractCallback); |
7604 |
25 Feb 19 |
nicklas |
82 |
|
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('used_quantity', 'keypress', Events.numberOnly); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('used_quantity', 'keyup', extracts.usedQuantityOnChange); |
7604 |
25 Feb 19 |
nicklas |
85 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.parentTypeOnClick(); |
7604 |
25 Feb 19 |
nicklas |
87 |
|
7604 |
25 Feb 19 |
nicklas |
88 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (pageId == 'view-page') |
7604 |
25 Feb 19 |
nicklas |
90 |
{ |
7604 |
25 Feb 19 |
nicklas |
var itemId = Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
var attributes = {'item-type': 'EXTRACT', '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('btnNewExtract', extracts.newExtract, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnNewPhysicalBioAssay', extracts.newPhysicalBioAssay, attributes); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnNewRawBioAssay', extracts.newRawBioAssay, 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 |
106 |
|
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('main.events', extracts.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 |
111 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (pageId == 'list-page') |
7604 |
25 Feb 19 |
nicklas |
113 |
{ |
7604 |
25 Feb 19 |
nicklas |
var attributes = {'item-type': 'EXTRACT'}; |
7604 |
25 Feb 19 |
nicklas |
var tableAttributes = {'table-id': 'extracts'}; |
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', extracts.newItemListOnClick); |
7813 |
19 May 20 |
nicklas |
Buttons.addClickHandler('btnAddToItemList', extracts.addToItemListOnClick); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnPlaceOnPlate', extracts.placeOnPlateOnClick); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnNewPooledItem', extracts.newPooledItemOnClick); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnNewPhysicalBioAssay', extracts.newPhysicalBioAssayFromTable); |
7604 |
25 Feb 19 |
nicklas |
131 |
|
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 |
134 |
} |
7604 |
25 Feb 19 |
nicklas |
135 |
} |
7604 |
25 Feb 19 |
nicklas |
136 |
|
7604 |
25 Feb 19 |
nicklas |
// Add event handlers to the 'new sample' icons |
7604 |
25 Feb 19 |
nicklas |
extracts.initElements = function(element, autoInit) |
7604 |
25 Feb 19 |
nicklas |
139 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (autoInit == 'new-extract') |
7604 |
25 Feb 19 |
nicklas |
141 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler(element, extracts.newExtract); |
7604 |
25 Feb 19 |
nicklas |
143 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (autoInit == 'new-derived-bioassay') |
7604 |
25 Feb 19 |
nicklas |
145 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler(element, extracts.newDerivedBioAssay); |
7604 |
25 Feb 19 |
nicklas |
147 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (autoInit == 'new-raw-bioassay') |
7604 |
25 Feb 19 |
nicklas |
149 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler(element, extracts.newRawBioAssay); |
7604 |
25 Feb 19 |
nicklas |
151 |
} |
7604 |
25 Feb 19 |
nicklas |
152 |
} |
7604 |
25 Feb 19 |
nicklas |
153 |
|
7604 |
25 Feb 19 |
nicklas |
154 |
/* |
7604 |
25 Feb 19 |
nicklas |
Create a new extract with the current extract as the parent |
7604 |
25 Feb 19 |
nicklas |
156 |
*/ |
7604 |
25 Feb 19 |
nicklas |
extracts.newExtract = function(event) |
7604 |
25 Feb 19 |
nicklas |
158 |
{ |
7604 |
25 Feb 19 |
nicklas |
var extractId = Data.int(event.currentTarget, 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
Items.newItem('EXTRACT', '&extract_id='+extractId); |
7604 |
25 Feb 19 |
nicklas |
161 |
} |
7604 |
25 Feb 19 |
nicklas |
162 |
|
7604 |
25 Feb 19 |
nicklas |
163 |
/* |
7604 |
25 Feb 19 |
nicklas |
Create a new derived bioassay with the current extract as the parent |
7604 |
25 Feb 19 |
nicklas |
165 |
*/ |
7604 |
25 Feb 19 |
nicklas |
extracts.newDerivedBioAssay = function(event) |
7604 |
25 Feb 19 |
nicklas |
167 |
{ |
7604 |
25 Feb 19 |
nicklas |
var extractId = Data.int(event.currentTarget, 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
Items.newItem('DERIVEDBIOASSAY', '&extract_id='+extractId); |
7604 |
25 Feb 19 |
nicklas |
170 |
} |
7604 |
25 Feb 19 |
nicklas |
171 |
|
7604 |
25 Feb 19 |
nicklas |
172 |
|
7604 |
25 Feb 19 |
nicklas |
173 |
/* |
7604 |
25 Feb 19 |
nicklas |
Create a new raw bioassay with the current extract as the parent |
7604 |
25 Feb 19 |
nicklas |
175 |
*/ |
7604 |
25 Feb 19 |
nicklas |
extracts.newRawBioAssay = function(event) |
7604 |
25 Feb 19 |
nicklas |
177 |
{ |
7604 |
25 Feb 19 |
nicklas |
var extractId = Data.int(event.currentTarget, 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
Items.newItem('RAWBIOASSAY', '&extract_id='+extractId); |
7604 |
25 Feb 19 |
nicklas |
180 |
} |
7604 |
25 Feb 19 |
nicklas |
181 |
|
7604 |
25 Feb 19 |
nicklas |
182 |
/* |
7604 |
25 Feb 19 |
nicklas |
Create a new physical bioassay with the current extract as the parent |
7604 |
25 Feb 19 |
nicklas |
184 |
*/ |
7604 |
25 Feb 19 |
nicklas |
extracts.newPhysicalBioAssay = function(event) |
7604 |
25 Feb 19 |
nicklas |
186 |
{ |
7604 |
25 Feb 19 |
nicklas |
var extractId = Data.int(event.currentTarget, 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
Items.newItem('PHYSICALBIOASSAY', '&extract_id='+extractId); |
7604 |
25 Feb 19 |
nicklas |
189 |
} |
7604 |
25 Feb 19 |
nicklas |
190 |
|
7604 |
25 Feb 19 |
nicklas |
// Create a new item list with the selected items as members |
7604 |
25 Feb 19 |
nicklas |
extracts.newItemListOnClick = function() |
7604 |
25 Feb 19 |
nicklas |
193 |
{ |
7604 |
25 Feb 19 |
nicklas |
var controller = Items.getController('ITEMLIST'); |
7604 |
25 Feb 19 |
nicklas |
Table.submitToPopup('extracts', 'CreateItemList', controller.width, controller.height); |
7604 |
25 Feb 19 |
nicklas |
196 |
} |
7604 |
25 Feb 19 |
nicklas |
197 |
|
7813 |
19 May 20 |
nicklas |
// Add selected extracts to an existing item list |
7813 |
19 May 20 |
nicklas |
extracts.addToItemListOnClick = function() |
7813 |
19 May 20 |
nicklas |
200 |
{ |
7813 |
19 May 20 |
nicklas |
Table.submitToPopup('extracts', 'AddItemsToList', 450, 300); |
7813 |
19 May 20 |
nicklas |
202 |
} |
7813 |
19 May 20 |
nicklas |
203 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.placeOnPlateOnClick = function() |
7604 |
25 Feb 19 |
nicklas |
205 |
{ |
7604 |
25 Feb 19 |
nicklas |
Table.submitToPopup('extracts', 'PlaceOnPlate', 900, 600); |
7604 |
25 Feb 19 |
nicklas |
207 |
} |
7604 |
25 Feb 19 |
nicklas |
208 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.newPooledItemOnClick = function() |
7604 |
25 Feb 19 |
nicklas |
210 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (!Table.checkIfSelected('extracts')) |
7604 |
25 Feb 19 |
nicklas |
212 |
{ |
7604 |
25 Feb 19 |
nicklas |
return; |
7604 |
25 Feb 19 |
nicklas |
214 |
} |
7604 |
25 Feb 19 |
nicklas |
Table.submitToPopup('extracts', 'NewPooledItem', 750, 500); |
7604 |
25 Feb 19 |
nicklas |
216 |
} |
7604 |
25 Feb 19 |
nicklas |
217 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.newPhysicalBioAssayFromTable = function() |
7604 |
25 Feb 19 |
nicklas |
219 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (!Table.checkIfSelected('extracts')) |
7604 |
25 Feb 19 |
nicklas |
221 |
{ |
7604 |
25 Feb 19 |
nicklas |
return; |
7604 |
25 Feb 19 |
nicklas |
223 |
} |
7604 |
25 Feb 19 |
nicklas |
Table.submitToPopup('extracts', 'NewPhysicalBioAssay', 750, 500); |
7604 |
25 Feb 19 |
nicklas |
225 |
} |
7604 |
25 Feb 19 |
nicklas |
226 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.viewEvents = function() |
7604 |
25 Feb 19 |
nicklas |
228 |
{ |
7604 |
25 Feb 19 |
nicklas |
var extractId = 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='+extractId; |
7604 |
25 Feb 19 |
nicklas |
url += '&biomaterial_type=EXTRACT'; |
7604 |
25 Feb 19 |
nicklas |
location.replace(url); |
7604 |
25 Feb 19 |
nicklas |
234 |
} |
7604 |
25 Feb 19 |
nicklas |
235 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.validateExtract = function() |
7604 |
25 Feb 19 |
nicklas |
237 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['extract']; |
7604 |
25 Feb 19 |
nicklas |
if (Strings.trim(frm.name.value) == '') |
7604 |
25 Feb 19 |
nicklas |
240 |
{ |
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 |
243 |
} |
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 |
245 |
{ |
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 |
248 |
} |
7604 |
25 Feb 19 |
nicklas |
return true; |
7604 |
25 Feb 19 |
nicklas |
250 |
} |
7604 |
25 Feb 19 |
nicklas |
251 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.save = function() |
7604 |
25 Feb 19 |
nicklas |
253 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['extract']; |
7604 |
25 Feb 19 |
nicklas |
if (TabControl.validateActiveTab('settings')) |
7604 |
25 Feb 19 |
nicklas |
256 |
{ |
7604 |
25 Feb 19 |
nicklas |
Annotations.saveModifiedAnnotationsToForm(frm); |
7604 |
25 Feb 19 |
nicklas |
Link.exportActions('extracts'); |
7604 |
25 Feb 19 |
nicklas |
frm.submit(); |
7604 |
25 Feb 19 |
nicklas |
260 |
} |
7604 |
25 Feb 19 |
nicklas |
261 |
} |
7604 |
25 Feb 19 |
nicklas |
262 |
|
7604 |
25 Feb 19 |
nicklas |
263 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.loadAnnotationsFrame = function() |
7604 |
25 Feb 19 |
nicklas |
265 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['extract']; |
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 |
269 |
{ |
7604 |
25 Feb 19 |
nicklas |
protocolId = Math.abs(parseInt(frm.protocol_id.value)); |
7604 |
25 Feb 19 |
nicklas |
271 |
} |
7604 |
25 Feb 19 |
nicklas |
Annotations.autoLoadEditFrame(protocolId, ItemSubtype.getSubtypeId('subtype_id'), extracts.getParents()); |
7604 |
25 Feb 19 |
nicklas |
273 |
} |
7604 |
25 Feb 19 |
nicklas |
274 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.getParents = function() |
7604 |
25 Feb 19 |
nicklas |
276 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['extract']; |
7604 |
25 Feb 19 |
nicklas |
var parents = []; |
7604 |
25 Feb 19 |
nicklas |
if (frm.parentType[0].checked) |
7604 |
25 Feb 19 |
nicklas |
280 |
{ |
7604 |
25 Feb 19 |
nicklas |
var sampleId = Math.abs(parseInt(frm.sample_id.value)); |
7604 |
25 Feb 19 |
nicklas |
if (sampleId > 0) parents[parents.length] = 'SAMPLE:'+sampleId; |
7604 |
25 Feb 19 |
nicklas |
283 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
285 |
{ |
7604 |
25 Feb 19 |
nicklas |
var ids = Link.getIdsInList(frm.extracts, 'EXTRACT'); |
7604 |
25 Feb 19 |
nicklas |
if (ids.length > 0) |
7604 |
25 Feb 19 |
nicklas |
288 |
{ |
7604 |
25 Feb 19 |
nicklas |
parents[parents.length] = 'EXTRACT:'+ids.join(':'); |
7604 |
25 Feb 19 |
nicklas |
290 |
} |
7604 |
25 Feb 19 |
nicklas |
291 |
} |
7604 |
25 Feb 19 |
nicklas |
var tagId = Math.abs(parseInt(frm.tag_id.value)); |
7604 |
25 Feb 19 |
nicklas |
if (tagId > 0) parents[parents.length] = 'TAG:'+tagId; |
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 |
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 |
return parents; |
7604 |
25 Feb 19 |
nicklas |
299 |
} |
7604 |
25 Feb 19 |
nicklas |
300 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.subtypeOnChange = function() |
7604 |
25 Feb 19 |
nicklas |
302 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['extract']; |
7604 |
25 Feb 19 |
nicklas |
var subtypeId = ItemSubtype.getSubtypeId('subtype_id'); |
7604 |
25 Feb 19 |
nicklas |
var recentInfo = ItemSubtype.getRelatedProjectDefaultAndRecentItems('EXTRACT', subtypeId, ['PROTOCOL', 'KIT', 'BIOPLATE', 'TAG', 'SAMPLE', 'EXTRACT']); |
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.tag_id, recentInfo.TAG['recent']); |
7604 |
25 Feb 19 |
nicklas |
ItemSubtype.updateSelectionList(frm.bioplate_id, recentInfo.BIOPLATE['recent']); |
7604 |
25 Feb 19 |
nicklas |
310 |
} |
7604 |
25 Feb 19 |
nicklas |
311 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.selectTag = function() |
7604 |
25 Feb 19 |
nicklas |
313 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['extract']; |
7604 |
25 Feb 19 |
nicklas |
var url = '&resetTemporary=1'; |
7604 |
25 Feb 19 |
nicklas |
url += ItemSubtype.createRelatedFilter('subtype_id', 'TAG'); |
7604 |
25 Feb 19 |
nicklas |
if (frm.tag_id.length > 1) |
7604 |
25 Feb 19 |
nicklas |
318 |
{ |
7604 |
25 Feb 19 |
nicklas |
var id = Math.abs(parseInt(frm.tag_id[1].value)); |
7604 |
25 Feb 19 |
nicklas |
url += '&item_id='+id; |
7604 |
25 Feb 19 |
nicklas |
321 |
} |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('TAG', 'tag_id', 0, url); |
7604 |
25 Feb 19 |
nicklas |
323 |
} |
7604 |
25 Feb 19 |
nicklas |
324 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.selectProtocol = function() |
7604 |
25 Feb 19 |
nicklas |
326 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['extract']; |
7604 |
25 Feb 19 |
nicklas |
var url = '&resetTemporary=1'; |
7604 |
25 Feb 19 |
nicklas |
url += ItemSubtype.createRelatedFilter('subtype_id', 'PROTOCOL', Data.int('page-data', 'extraction-protocoltype-id')); |
7604 |
25 Feb 19 |
nicklas |
if (frm.protocol_id.length > 1) |
7604 |
25 Feb 19 |
nicklas |
331 |
{ |
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 |
334 |
} |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('PROTOCOL', 'protocol_id', 0, url); |
7604 |
25 Feb 19 |
nicklas |
336 |
} |
7604 |
25 Feb 19 |
nicklas |
337 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.selectKit = function() |
7604 |
25 Feb 19 |
nicklas |
339 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['extract']; |
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', 'extraction-kittype-id')); |
7604 |
25 Feb 19 |
nicklas |
if (frm.kit_id.length > 1) |
7604 |
25 Feb 19 |
nicklas |
345 |
{ |
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 |
348 |
} |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('KIT', 'kit_id', 0, url); |
7604 |
25 Feb 19 |
nicklas |
350 |
} |
7604 |
25 Feb 19 |
nicklas |
351 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.selectBioPlate = function() |
7604 |
25 Feb 19 |
nicklas |
353 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['extract']; |
7604 |
25 Feb 19 |
nicklas |
var url = '&resetTemporary=1'; |
7604 |
25 Feb 19 |
nicklas |
url += '&tmpfilter:INT:bioPlateType.bioMaterialType='+encodeURIComponent('|'+Data.get('page-data', 'extract-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 |
362 |
} |
7604 |
25 Feb 19 |
nicklas |
363 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.bioPlateOnChange = function() |
7604 |
25 Feb 19 |
nicklas |
365 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['extract']; |
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 |
370 |
} |
7604 |
25 Feb 19 |
nicklas |
371 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.initBioWell = function() |
7604 |
25 Feb 19 |
nicklas |
373 |
{ |
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 |
376 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['extract']; |
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 |
380 |
} |
7604 |
25 Feb 19 |
nicklas |
381 |
} |
7604 |
25 Feb 19 |
nicklas |
382 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.selectBioWell = function() |
7604 |
25 Feb 19 |
nicklas |
384 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['extract']; |
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 |
388 |
{ |
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 |
391 |
} |
7604 |
25 Feb 19 |
nicklas |
392 |
|
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 |
397 |
|
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('BIOWELL', 'biowell_id', 0, url); |
7604 |
25 Feb 19 |
nicklas |
399 |
} |
7604 |
25 Feb 19 |
nicklas |
400 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.parentTypeOnClick = function() |
7604 |
25 Feb 19 |
nicklas |
402 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['extract']; |
7604 |
25 Feb 19 |
nicklas |
var useExtracts = frm.parentType[1].checked; |
7604 |
25 Feb 19 |
nicklas |
frm.sample_id.disabled = useExtracts; |
7604 |
25 Feb 19 |
nicklas |
frm.used_from_sample.disabled = useExtracts; |
7604 |
25 Feb 19 |
nicklas |
frm.extracts.disabled = !useExtracts; |
7604 |
25 Feb 19 |
nicklas |
frm.used_quantity.disabled = !useExtracts; |
7604 |
25 Feb 19 |
nicklas |
409 |
} |
7604 |
25 Feb 19 |
nicklas |
410 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.selectSample = function() |
7604 |
25 Feb 19 |
nicklas |
412 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['extract']; |
7604 |
25 Feb 19 |
nicklas |
var url = '&resetTemporary=1'; |
7604 |
25 Feb 19 |
nicklas |
url += ItemSubtype.createRelatedFilter('subtype_id', 'SAMPLE'); |
7604 |
25 Feb 19 |
nicklas |
if (frm.sample_id.length > 1) |
7604 |
25 Feb 19 |
nicklas |
417 |
{ |
7604 |
25 Feb 19 |
nicklas |
var id = Math.abs(parseInt(frm.sample_id[1].value)); |
7604 |
25 Feb 19 |
nicklas |
url += '&item_id='+id; |
7604 |
25 Feb 19 |
nicklas |
420 |
} |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('SAMPLE', 'sample_id', 0, url); |
7604 |
25 Feb 19 |
nicklas |
422 |
} |
7604 |
25 Feb 19 |
nicklas |
423 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.sampleOnChange = function(event) |
7604 |
25 Feb 19 |
nicklas |
425 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['extract']; |
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 |
extracts.parentTypeOnClick(); |
7604 |
25 Feb 19 |
nicklas |
430 |
} |
7604 |
25 Feb 19 |
nicklas |
431 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.usedFromSampleOnBlur = function() |
7604 |
25 Feb 19 |
nicklas |
433 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['extract']; |
7604 |
25 Feb 19 |
nicklas |
var sampleId = parseInt(frm.sample_id.value); |
7604 |
25 Feb 19 |
nicklas |
if (sampleId < 0) |
7604 |
25 Feb 19 |
nicklas |
437 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm.sample_id[frm.sample_id.selectedIndex].value = -sampleId; |
7604 |
25 Feb 19 |
nicklas |
439 |
} |
7604 |
25 Feb 19 |
nicklas |
440 |
} |
7604 |
25 Feb 19 |
nicklas |
441 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.addExtractsOnClick = function(event) |
7604 |
25 Feb 19 |
nicklas |
443 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['extract']; |
7604 |
25 Feb 19 |
nicklas |
var currentExtracts = Link.getIdsInList(frm.extracts, 'EXTRACT'); |
7604 |
25 Feb 19 |
nicklas |
var url = '&resetTemporary=1&exclude='+currentExtracts.join(','); |
7604 |
25 Feb 19 |
nicklas |
url += ItemSubtype.createRelatedFilter('subtype_id', 'EXTRACT'); |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('EXTRACT', event.currentTarget.id, 1, url); |
7604 |
25 Feb 19 |
nicklas |
449 |
} |
7604 |
25 Feb 19 |
nicklas |
450 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.addExtractCallback = function(event) |
7604 |
25 Feb 19 |
nicklas |
452 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['extract']; |
7604 |
25 Feb 19 |
nicklas |
event.detail.name += ' [-]'; |
7604 |
25 Feb 19 |
nicklas |
Link.addItem('extracts', 'EXTRACT', event.detail); |
7604 |
25 Feb 19 |
nicklas |
if (event.detail.remaining == 0) |
7604 |
25 Feb 19 |
nicklas |
457 |
{ |
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 |
extracts.parentTypeOnClick(); |
7604 |
25 Feb 19 |
nicklas |
461 |
} |
7604 |
25 Feb 19 |
nicklas |
462 |
} |
7604 |
25 Feb 19 |
nicklas |
463 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.usedQuantityOnChange = function() |
7604 |
25 Feb 19 |
nicklas |
465 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['extract']; |
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.extracts.length; i++) |
7604 |
25 Feb 19 |
nicklas |
470 |
{ |
7604 |
25 Feb 19 |
nicklas |
var option = frm.extracts[i]; |
7604 |
25 Feb 19 |
nicklas |
if (option.selected && option.item.id) |
7604 |
25 Feb 19 |
nicklas |
473 |
{ |
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 |
477 |
} |
7604 |
25 Feb 19 |
nicklas |
478 |
} |
7604 |
25 Feb 19 |
nicklas |
479 |
} |
7604 |
25 Feb 19 |
nicklas |
480 |
|
7604 |
25 Feb 19 |
nicklas |
extracts.extractsOnChange = function() |
7604 |
25 Feb 19 |
nicklas |
482 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['extract']; |
7604 |
25 Feb 19 |
nicklas |
var item = frm.extracts[frm.extracts.selectedIndex].item; |
7604 |
25 Feb 19 |
nicklas |
if (item && item.id && item.value != undefined) |
7604 |
25 Feb 19 |
nicklas |
486 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm.used_quantity.value = item.value; |
7604 |
25 Feb 19 |
nicklas |
488 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
490 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm.used_quantity.value = ''; |
7604 |
25 Feb 19 |
nicklas |
492 |
} |
7604 |
25 Feb 19 |
nicklas |
frm.used_quantity.focus(); |
7604 |
25 Feb 19 |
nicklas |
494 |
} |
7604 |
25 Feb 19 |
nicklas |
495 |
|
7604 |
25 Feb 19 |
nicklas |
return extracts; |
7604 |
25 Feb 19 |
nicklas |
497 |
}(); |
7604 |
25 Feb 19 |
nicklas |
498 |
|
7604 |
25 Feb 19 |
nicklas |
Doc.addElementInitializer(Extracts.initElements); |
7604 |
25 Feb 19 |
nicklas |
Doc.onLoad(Extracts.initPage); |