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 BioAssays = function() |
7604 |
25 Feb 19 |
nicklas |
27 |
{ |
7604 |
25 Feb 19 |
nicklas |
var bioassays = {}; |
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 |
bioassays.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', bioassays.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', bioassays.loadAnnotationsFrame); |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabValidator('settings.info', bioassays.validatePhysicalBioAssay); |
7604 |
25 Feb 19 |
nicklas |
45 |
|
7604 |
25 Feb 19 |
nicklas |
// Size |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('size', 'keypress', Events.integerOnly); |
7604 |
25 Feb 19 |
nicklas |
48 |
|
7604 |
25 Feb 19 |
nicklas |
// Protocol |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('protocol_id.select', bioassays.selectProtocol); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('protocol_id', 'base-selected', Items.onItemSelected); |
7604 |
25 Feb 19 |
nicklas |
52 |
|
7604 |
25 Feb 19 |
nicklas |
// Subtype |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('subtype_id', 'change', bioassays.subtypeOnChange); |
7604 |
25 Feb 19 |
nicklas |
55 |
|
7604 |
25 Feb 19 |
nicklas |
// Hardware |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('hardware_id.select', bioassays.selectHardware); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('hardware_id', 'base-selected', Items.onItemSelected); |
7604 |
25 Feb 19 |
nicklas |
59 |
|
7604 |
25 Feb 19 |
nicklas |
// Kit |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('kit_id.select', bioassays.selectKit); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('kit_id', 'base-selected', Items.onItemSelected); |
7604 |
25 Feb 19 |
nicklas |
63 |
|
7604 |
25 Feb 19 |
nicklas |
// Array slide |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('arrayslide_id.select', bioassays.selectArraySlide); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('arrayslide_id', 'base-selected', Items.onItemSelected); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('arrayslide_id', 'change', bioassays.arraySlideOnChange); |
7604 |
25 Feb 19 |
nicklas |
68 |
|
7604 |
25 Feb 19 |
nicklas |
// Parent extracts |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('extracts', 'change', bioassays.extractsOnChange); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnAddExtracts', bioassays.addExtracts); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('btnAddExtracts', 'base-selected', bioassays.addExtractCallback); |
7604 |
25 Feb 19 |
nicklas |
73 |
|
7604 |
25 Feb 19 |
nicklas |
// Used quantity and position |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('used_quantity', 'keypress', Events.numberOnly); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('used_quantity', 'keyup', bioassays.usedQuantityOnBlur); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('position', 'keypress', Events.integerOnly); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('position', 'keyup', bioassays.usedQuantityOnBlur); |
7604 |
25 Feb 19 |
nicklas |
79 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (pageId == 'view-page') |
7604 |
25 Feb 19 |
nicklas |
81 |
{ |
7604 |
25 Feb 19 |
nicklas |
var itemId = Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
var attributes = {'item-type': 'PHYSICALBIOASSAY', 'item-id': itemId}; |
7604 |
25 Feb 19 |
nicklas |
84 |
|
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('btnNewDerivedBioAssay', bioassays.newDerivedBioAssay, 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 |
96 |
|
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 |
100 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (pageId == 'list-page') |
7604 |
25 Feb 19 |
nicklas |
102 |
{ |
7604 |
25 Feb 19 |
nicklas |
var attributes = {'item-type': 'PHYSICALBIOASSAY'}; |
7604 |
25 Feb 19 |
nicklas |
var tableAttributes = {'table-id': 'bioassays'}; |
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('btnNewMergedDerivedBioAssay', bioassays.newMergedDerivedBioAssay); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnNewItemList', bioassays.newItemListOnClick); |
7813 |
19 May 20 |
nicklas |
Buttons.addClickHandler('btnAddToItemList', bioassays.addToItemListOnClick); |
7604 |
25 Feb 19 |
nicklas |
118 |
|
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 |
121 |
} |
7604 |
25 Feb 19 |
nicklas |
122 |
} |
7604 |
25 Feb 19 |
nicklas |
123 |
|
7604 |
25 Feb 19 |
nicklas |
bioassays.initElements = function(element, autoInit) |
7604 |
25 Feb 19 |
nicklas |
125 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (autoInit == 'new-derived-bioassay') |
7604 |
25 Feb 19 |
nicklas |
127 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler(element, bioassays.newDerivedBioAssay); |
7604 |
25 Feb 19 |
nicklas |
129 |
} |
7604 |
25 Feb 19 |
nicklas |
130 |
} |
7604 |
25 Feb 19 |
nicklas |
131 |
|
7604 |
25 Feb 19 |
nicklas |
bioassays.newMergedDerivedBioAssay = function() |
7604 |
25 Feb 19 |
nicklas |
133 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (!Table.checkIfSelected('bioassays')) |
7604 |
25 Feb 19 |
nicklas |
135 |
{ |
7604 |
25 Feb 19 |
nicklas |
return; |
7604 |
25 Feb 19 |
nicklas |
137 |
} |
7604 |
25 Feb 19 |
nicklas |
Table.submitToPopup('bioassays', 'NewMergedDerivedBioAssay', 750, 500); |
7604 |
25 Feb 19 |
nicklas |
139 |
} |
7604 |
25 Feb 19 |
nicklas |
140 |
|
7604 |
25 Feb 19 |
nicklas |
bioassays.newDerivedBioAssay = function(event) |
7604 |
25 Feb 19 |
nicklas |
142 |
{ |
7604 |
25 Feb 19 |
nicklas |
var parentId = Data.int(event.currentTarget, 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
Items.newItem('DERIVEDBIOASSAY', '&physicalbioassay_id='+parentId); |
7604 |
25 Feb 19 |
nicklas |
145 |
} |
7813 |
19 May 20 |
nicklas |
// Add selected bioassays to an existing item list |
7813 |
19 May 20 |
nicklas |
bioassays.addToItemListOnClick = function() |
7813 |
19 May 20 |
nicklas |
148 |
{ |
7813 |
19 May 20 |
nicklas |
Table.submitToPopup('bioassays', 'AddItemsToList', 450, 300); |
7813 |
19 May 20 |
nicklas |
150 |
} |
7604 |
25 Feb 19 |
nicklas |
151 |
|
7604 |
25 Feb 19 |
nicklas |
// Create a new item list with the selected items as members |
7604 |
25 Feb 19 |
nicklas |
bioassays.newItemListOnClick = function() |
7604 |
25 Feb 19 |
nicklas |
154 |
{ |
7604 |
25 Feb 19 |
nicklas |
var controller = Items.getController('ITEMLIST'); |
7604 |
25 Feb 19 |
nicklas |
Table.submitToPopup('bioassays', 'CreateItemList', controller.width, controller.height); |
7604 |
25 Feb 19 |
nicklas |
157 |
} |
7604 |
25 Feb 19 |
nicklas |
158 |
|
7604 |
25 Feb 19 |
nicklas |
bioassays.validatePhysicalBioAssay = function() |
7604 |
25 Feb 19 |
nicklas |
160 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioassay']; |
7604 |
25 Feb 19 |
nicklas |
if (Strings.trim(frm.name.value) == '') |
7604 |
25 Feb 19 |
nicklas |
163 |
{ |
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 |
166 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (!Numbers.isInteger(frm.size.value)) |
7604 |
25 Feb 19 |
nicklas |
168 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.showNotification(frm.size, "'" + frm.size.value + "' is not a valid number"); |
7604 |
25 Feb 19 |
nicklas |
return false; |
7604 |
25 Feb 19 |
nicklas |
171 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (parseInt(frm.size.value) <= 0) |
7604 |
25 Feb 19 |
nicklas |
173 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.showNotification(frm.size, "Size must be >0"); |
7604 |
25 Feb 19 |
nicklas |
return false; |
7604 |
25 Feb 19 |
nicklas |
176 |
} |
7604 |
25 Feb 19 |
nicklas |
return true; |
7604 |
25 Feb 19 |
nicklas |
178 |
} |
7604 |
25 Feb 19 |
nicklas |
179 |
|
7604 |
25 Feb 19 |
nicklas |
bioassays.save = function() |
7604 |
25 Feb 19 |
nicklas |
181 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioassay']; |
7604 |
25 Feb 19 |
nicklas |
if (TabControl.validateActiveTab('settings')) |
7604 |
25 Feb 19 |
nicklas |
184 |
{ |
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 |
188 |
} |
7604 |
25 Feb 19 |
nicklas |
189 |
} |
7604 |
25 Feb 19 |
nicklas |
190 |
|
7604 |
25 Feb 19 |
nicklas |
bioassays.loadAnnotationsFrame = function() |
7604 |
25 Feb 19 |
nicklas |
192 |
{ |
7604 |
25 Feb 19 |
nicklas |
Annotations.autoLoadEditFrame(bioassays.getProtocolId(), ItemSubtype.getSubtypeId('subtype_id'), bioassays.getParents()); |
7604 |
25 Feb 19 |
nicklas |
194 |
} |
7604 |
25 Feb 19 |
nicklas |
195 |
|
7604 |
25 Feb 19 |
nicklas |
bioassays.getProtocolId = function() |
7604 |
25 Feb 19 |
nicklas |
197 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioassay']; |
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 |
201 |
{ |
7604 |
25 Feb 19 |
nicklas |
protocolId = Math.abs(parseInt(frm.protocol_id.value)); |
7604 |
25 Feb 19 |
nicklas |
203 |
} |
7604 |
25 Feb 19 |
nicklas |
return protocolId; |
7604 |
25 Feb 19 |
nicklas |
205 |
} |
7604 |
25 Feb 19 |
nicklas |
206 |
|
7604 |
25 Feb 19 |
nicklas |
bioassays.getParents = function() |
7604 |
25 Feb 19 |
nicklas |
208 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioassay']; |
7604 |
25 Feb 19 |
nicklas |
var parents = []; |
7604 |
25 Feb 19 |
nicklas |
211 |
|
7604 |
25 Feb 19 |
nicklas |
var arraySlideId = Math.abs(parseInt(frm.arrayslide_id.value)); |
7604 |
25 Feb 19 |
nicklas |
if (arraySlideId > 0) parents[parents.length] = 'ARRAYSLIDE:'+arraySlideId; |
7604 |
25 Feb 19 |
nicklas |
var hardwareId = Math.abs(parseInt(frm.hardware_id.value)); |
7604 |
25 Feb 19 |
nicklas |
if (hardwareId > 0) parents[parents.length] = 'HARDWARE:'+hardwareId; |
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 |
220 |
|
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 |
223 |
{ |
7604 |
25 Feb 19 |
nicklas |
parents[parents.length] = 'EXTRACT:'+ids.join(':'); |
7604 |
25 Feb 19 |
nicklas |
225 |
} |
7604 |
25 Feb 19 |
nicklas |
return parents; |
7604 |
25 Feb 19 |
nicklas |
227 |
} |
7604 |
25 Feb 19 |
nicklas |
228 |
|
7604 |
25 Feb 19 |
nicklas |
bioassays.selectProtocol = function() |
7604 |
25 Feb 19 |
nicklas |
230 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioassay']; |
7604 |
25 Feb 19 |
nicklas |
var url = '&resetTemporary=1'; |
7604 |
25 Feb 19 |
nicklas |
url += ItemSubtype.createRelatedFilter('subtype_id', 'PROTOCOL'); |
7604 |
25 Feb 19 |
nicklas |
if (frm.protocol_id.length > 1) |
7604 |
25 Feb 19 |
nicklas |
235 |
{ |
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 |
238 |
} |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('PROTOCOL', 'protocol_id', 0, url); |
7604 |
25 Feb 19 |
nicklas |
240 |
} |
7604 |
25 Feb 19 |
nicklas |
241 |
|
7604 |
25 Feb 19 |
nicklas |
bioassays.selectKit = function() |
7604 |
25 Feb 19 |
nicklas |
243 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioassay']; |
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'); |
7604 |
25 Feb 19 |
nicklas |
if (frm.kit_id.length > 1) |
7604 |
25 Feb 19 |
nicklas |
249 |
{ |
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 |
252 |
} |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('KIT', 'kit_id', 0, url); |
7604 |
25 Feb 19 |
nicklas |
254 |
} |
7604 |
25 Feb 19 |
nicklas |
255 |
|
7604 |
25 Feb 19 |
nicklas |
bioassays.subtypeOnChange = function() |
7604 |
25 Feb 19 |
nicklas |
257 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioassay']; |
7604 |
25 Feb 19 |
nicklas |
var subtypeId = ItemSubtype.getSubtypeId('subtype_id'); |
7604 |
25 Feb 19 |
nicklas |
var recentInfo = ItemSubtype.getRelatedProjectDefaultAndRecentItems('PHYSICALBIOASSAY', subtypeId, ['PROTOCOL', 'HARDWARE', 'KIT']); |
7604 |
25 Feb 19 |
nicklas |
261 |
|
7604 |
25 Feb 19 |
nicklas |
ItemSubtype.updateSelectionList(frm.protocol_id, recentInfo.PROTOCOL['recent'], recentInfo.PROTOCOL['default']); |
7604 |
25 Feb 19 |
nicklas |
ItemSubtype.updateSelectionList(frm.hardware_id, recentInfo.HARDWARE['recent'], recentInfo.HARDWARE['default']); |
7604 |
25 Feb 19 |
nicklas |
ItemSubtype.updateSelectionList(frm.kit_id, recentInfo.KIT['recent']); |
7604 |
25 Feb 19 |
nicklas |
265 |
} |
7604 |
25 Feb 19 |
nicklas |
266 |
|
7604 |
25 Feb 19 |
nicklas |
bioassays.selectHardware = function() |
7604 |
25 Feb 19 |
nicklas |
268 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioassay']; |
7604 |
25 Feb 19 |
nicklas |
var url = '&resetTemporary=1'; |
7604 |
25 Feb 19 |
nicklas |
url += ItemSubtype.createRelatedFilter('subtype_id', 'HARDWARE'); |
7604 |
25 Feb 19 |
nicklas |
if (frm.hardware_id.length > 1) |
7604 |
25 Feb 19 |
nicklas |
273 |
{ |
7604 |
25 Feb 19 |
nicklas |
var id = Math.abs(parseInt(frm.hardware_id[1].value)); |
7604 |
25 Feb 19 |
nicklas |
url += '&item_id='+id; |
7604 |
25 Feb 19 |
nicklas |
276 |
} |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('HARDWARE', 'hardware_id', 0, url); |
7604 |
25 Feb 19 |
nicklas |
278 |
} |
7604 |
25 Feb 19 |
nicklas |
279 |
|
7604 |
25 Feb 19 |
nicklas |
bioassays.selectArraySlide = function() |
7604 |
25 Feb 19 |
nicklas |
281 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioassay']; |
7604 |
25 Feb 19 |
nicklas |
var url = ''; |
7604 |
25 Feb 19 |
nicklas |
if (frm.arrayslide_id.length > 1) |
7604 |
25 Feb 19 |
nicklas |
285 |
{ |
7604 |
25 Feb 19 |
nicklas |
var id = Math.abs(parseInt(frm.arrayslide_id[1].value)); |
7604 |
25 Feb 19 |
nicklas |
url += '&item_id='+id; |
7604 |
25 Feb 19 |
nicklas |
288 |
} |
7604 |
25 Feb 19 |
nicklas |
url += '&resetTemporary=1&tmpfilter:STRING:physicalBioAssay.name=='; |
7604 |
25 Feb 19 |
nicklas |
url += '&tmpfilter:BOOLEAN:destroyed=false'; |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('ARRAYSLIDE', 'arrayslide_id', 0, url); |
7604 |
25 Feb 19 |
nicklas |
292 |
} |
7604 |
25 Feb 19 |
nicklas |
293 |
|
7604 |
25 Feb 19 |
nicklas |
bioassays.arraySlideOnChange = function() |
7604 |
25 Feb 19 |
nicklas |
295 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioassay']; |
7604 |
25 Feb 19 |
nicklas |
var arraySlideId = frm.arrayslide_id.value; |
7604 |
25 Feb 19 |
nicklas |
if (arraySlideId > 0) |
7604 |
25 Feb 19 |
nicklas |
299 |
{ |
7604 |
25 Feb 19 |
nicklas |
bioassays.updateSize(arraySlideId); |
7604 |
25 Feb 19 |
nicklas |
301 |
} |
7604 |
25 Feb 19 |
nicklas |
302 |
} |
7604 |
25 Feb 19 |
nicklas |
303 |
|
7604 |
25 Feb 19 |
nicklas |
bioassays.updateSize = function(arraySlideId) |
7604 |
25 Feb 19 |
nicklas |
305 |
{ |
7604 |
25 Feb 19 |
nicklas |
var request = Ajax.getXmlHttpRequest(); |
7604 |
25 Feb 19 |
nicklas |
if (request != null) |
7604 |
25 Feb 19 |
nicklas |
308 |
{ |
7604 |
25 Feb 19 |
nicklas |
var url = '../../lims/arrayslides/ajax.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=GetArrayDesign&item_id=' + arraySlideId; |
7604 |
25 Feb 19 |
nicklas |
request.open("GET", url, true); |
7604 |
25 Feb 19 |
nicklas |
Ajax.setReadyStateHandler(request, bioassays.updateSizeCallback); |
7604 |
25 Feb 19 |
nicklas |
request.send(null); |
7604 |
25 Feb 19 |
nicklas |
314 |
} |
7604 |
25 Feb 19 |
nicklas |
return request != null; |
7604 |
25 Feb 19 |
nicklas |
316 |
} |
7604 |
25 Feb 19 |
nicklas |
317 |
|
7604 |
25 Feb 19 |
nicklas |
bioassays.updateSizeCallback = function(request) |
7604 |
25 Feb 19 |
nicklas |
319 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioassay']; |
7604 |
25 Feb 19 |
nicklas |
var response = JSON.parse(request.responseText); |
7604 |
25 Feb 19 |
nicklas |
if (response.status != 'ok') |
7604 |
25 Feb 19 |
nicklas |
323 |
{ |
7604 |
25 Feb 19 |
nicklas |
alert(response.message); |
7604 |
25 Feb 19 |
nicklas |
return false; |
7604 |
25 Feb 19 |
nicklas |
326 |
} |
7604 |
25 Feb 19 |
nicklas |
327 |
|
7604 |
25 Feb 19 |
nicklas |
if (response.numArrays) |
7604 |
25 Feb 19 |
nicklas |
329 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm.size.value = response.numArrays; |
7604 |
25 Feb 19 |
nicklas |
331 |
} |
7604 |
25 Feb 19 |
nicklas |
332 |
} |
7604 |
25 Feb 19 |
nicklas |
333 |
|
7604 |
25 Feb 19 |
nicklas |
bioassays.addExtracts = function(event) |
7604 |
25 Feb 19 |
nicklas |
335 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioassay']; |
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 |
341 |
} |
7604 |
25 Feb 19 |
nicklas |
342 |
|
7604 |
25 Feb 19 |
nicklas |
bioassays.addExtractCallback = function(event) |
7604 |
25 Feb 19 |
nicklas |
344 |
{ |
7604 |
25 Feb 19 |
nicklas |
event.detail.name += ' [-]'; |
7604 |
25 Feb 19 |
nicklas |
event.detail.value = ':1'; |
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 |
349 |
{ |
7604 |
25 Feb 19 |
nicklas |
bioassays.extractsOnChange(); |
7604 |
25 Feb 19 |
nicklas |
351 |
} |
7604 |
25 Feb 19 |
nicklas |
352 |
} |
7604 |
25 Feb 19 |
nicklas |
353 |
|
7604 |
25 Feb 19 |
nicklas |
bioassays.extractsOnChange = function() |
7604 |
25 Feb 19 |
nicklas |
355 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioassay']; |
7604 |
25 Feb 19 |
nicklas |
var item = frm.extracts[frm.extracts.selectedIndex].item; |
7604 |
25 Feb 19 |
nicklas |
if (item && item.id) |
7604 |
25 Feb 19 |
nicklas |
359 |
{ |
7604 |
25 Feb 19 |
nicklas |
var i = item.value ? item.value.indexOf(':') : -1; |
7604 |
25 Feb 19 |
nicklas |
frm.used_quantity.value = i >= 0 ? item.value.substring(0, i) : item.value; |
7604 |
25 Feb 19 |
nicklas |
frm.position.value = i >= 0 ? item.value.substring(i+1) : '1'; |
7604 |
25 Feb 19 |
nicklas |
frm.used_quantity.focus(); |
7604 |
25 Feb 19 |
nicklas |
364 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
366 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm.used_quantity.value = ''; |
7604 |
25 Feb 19 |
nicklas |
frm.position.value = '1'; |
7604 |
25 Feb 19 |
nicklas |
369 |
} |
7604 |
25 Feb 19 |
nicklas |
370 |
} |
7604 |
25 Feb 19 |
nicklas |
371 |
|
7604 |
25 Feb 19 |
nicklas |
bioassays.usedQuantityOnBlur = function() |
7604 |
25 Feb 19 |
nicklas |
373 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioassay']; |
7604 |
25 Feb 19 |
nicklas |
var usedQuantity = frm.used_quantity.value; |
7604 |
25 Feb 19 |
nicklas |
var position = frm.position.value; |
7604 |
25 Feb 19 |
nicklas |
var size = parseInt(frm.size.value); |
7604 |
25 Feb 19 |
nicklas |
if (position != '' && (position > size || position <= 0)) |
7604 |
25 Feb 19 |
nicklas |
379 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.showNotification(frm.position, 'Position must be between 1 and ' + size); |
7604 |
25 Feb 19 |
nicklas |
return; |
7604 |
25 Feb 19 |
nicklas |
382 |
} |
7604 |
25 Feb 19 |
nicklas |
if (position == '') position = 1; |
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 |
386 |
{ |
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 |
389 |
{ |
7604 |
25 Feb 19 |
nicklas |
option.item.value = usedQuantity + ':' + position; |
7604 |
25 Feb 19 |
nicklas |
var text = option.text.replace(/\[.*\]/, '['+displayQuantity+']'); |
7604 |
25 Feb 19 |
nicklas |
text = text.replace(/\d*\:/, position + ':'); |
7604 |
25 Feb 19 |
nicklas |
option.text = text; |
7604 |
25 Feb 19 |
nicklas |
394 |
} |
7604 |
25 Feb 19 |
nicklas |
395 |
} |
7604 |
25 Feb 19 |
nicklas |
396 |
} |
7604 |
25 Feb 19 |
nicklas |
397 |
|
7604 |
25 Feb 19 |
nicklas |
398 |
|
7604 |
25 Feb 19 |
nicklas |
return bioassays; |
7604 |
25 Feb 19 |
nicklas |
400 |
}(); |
7604 |
25 Feb 19 |
nicklas |
401 |
|
7604 |
25 Feb 19 |
nicklas |
Doc.onLoad(BioAssays.initPage); |
7604 |
25 Feb 19 |
nicklas |
Doc.addElementInitializer(BioAssays.initElements); |
7604 |
25 Feb 19 |
nicklas |
404 |
|