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 BioPlates = function() |
7604 |
25 Feb 19 |
nicklas |
27 |
{ |
7604 |
25 Feb 19 |
nicklas |
var bioplates = {}; |
7604 |
25 Feb 19 |
nicklas |
var wellInfoCache = []; |
7604 |
25 Feb 19 |
nicklas |
30 |
|
7604 |
25 Feb 19 |
nicklas |
31 |
/** |
7604 |
25 Feb 19 |
nicklas |
Initialize the page. |
7604 |
25 Feb 19 |
nicklas |
33 |
*/ |
7604 |
25 Feb 19 |
nicklas |
bioplates.initPage = function() |
7604 |
25 Feb 19 |
nicklas |
35 |
{ |
7604 |
25 Feb 19 |
nicklas |
var pageId = Doc.getPageId(); |
7604 |
25 Feb 19 |
nicklas |
if (pageId == 'edit-page') |
7604 |
25 Feb 19 |
nicklas |
38 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnSave', bioplates.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', bioplates.loadAnnotationsFrame); |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabValidator('settings.info', bioplates.validateBioPlate); |
7604 |
25 Feb 19 |
nicklas |
45 |
|
7604 |
25 Feb 19 |
nicklas |
// Plate geometry |
7604 |
25 Feb 19 |
nicklas |
if (Doc.element('plategeometry_id')) |
7604 |
25 Feb 19 |
nicklas |
48 |
{ |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('plategeometry_id.select', bioplates.selectPlateGeometry); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('plategeometry_id', 'base-selected', bioplates.setPlateGeometryCallback); |
7604 |
25 Feb 19 |
nicklas |
51 |
|
7604 |
25 Feb 19 |
nicklas |
// Bioplate type |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('bioplatetype_id.select', bioplates.selectBioPlateType); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('bioplatetype_id', 'base-selected', bioplates.setBioPlateTypeCallback); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('bioplatetype_id', 'change', bioplates.bioPlateTypeOnChange); |
7604 |
25 Feb 19 |
nicklas |
bioplates.bioPlateTypeOnChange(); |
7604 |
25 Feb 19 |
nicklas |
57 |
} |
7604 |
25 Feb 19 |
nicklas |
58 |
|
7604 |
25 Feb 19 |
nicklas |
// Storage location |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('storage_id.select', bioplates.selectStorageLocation); |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('storage_id', 'base-selected', bioplates.setStorageLocationCallback); |
7604 |
25 Feb 19 |
nicklas |
62 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (pageId == 'view-page') |
7604 |
25 Feb 19 |
nicklas |
64 |
{ |
7604 |
25 Feb 19 |
nicklas |
var itemId = Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
var attributes = {'item-type': 'BIOPLATE', '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('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 |
77 |
|
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnMoveBioMaterial', bioplates.moveBioMaterial); |
7604 |
25 Feb 19 |
nicklas |
Buttons.addClickHandler('btnCreateChildBioPlate', bioplates.createChildBioPlate); |
7604 |
25 Feb 19 |
nicklas |
80 |
|
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 |
TabControl.addTabActivateListener('main.events', bioplates.viewEvents); |
7604 |
25 Feb 19 |
nicklas |
TabControl.addTabActivateListener('main.wells', bioplates.viewWells); |
7604 |
25 Feb 19 |
nicklas |
86 |
|
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler('bioplate', 'mouseleave', bioplates.hideWellInfo); |
7604 |
25 Feb 19 |
nicklas |
88 |
} |
7604 |
25 Feb 19 |
nicklas |
else if (pageId == 'list-page') |
7604 |
25 Feb 19 |
nicklas |
90 |
{ |
7604 |
25 Feb 19 |
nicklas |
var attributes = {'item-type': 'BIOPLATE'}; |
7604 |
25 Feb 19 |
nicklas |
var tableAttributes = {'table-id': 'bioplates'}; |
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('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 |
102 |
|
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 |
105 |
} |
7604 |
25 Feb 19 |
nicklas |
106 |
} |
7604 |
25 Feb 19 |
nicklas |
107 |
|
7604 |
25 Feb 19 |
nicklas |
// Add event handlers to the 'well' icons |
7604 |
25 Feb 19 |
nicklas |
bioplates.initElements = function(element, autoInit) |
7604 |
25 Feb 19 |
nicklas |
110 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (autoInit == 'well') |
7604 |
25 Feb 19 |
nicklas |
112 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (Data.int(element, 'allow-edit')) |
7604 |
25 Feb 19 |
nicklas |
114 |
{ |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler(element, 'click', bioplates.editWell); |
7604 |
25 Feb 19 |
nicklas |
116 |
} |
7604 |
25 Feb 19 |
nicklas |
if (Data.int(element, 'show-info')) |
7604 |
25 Feb 19 |
nicklas |
118 |
{ |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler(element, 'mouseover', bioplates.showWellInfo); |
7604 |
25 Feb 19 |
nicklas |
120 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
122 |
{ |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler(element, 'mouseover', bioplates.hideWellInfo); |
7604 |
25 Feb 19 |
nicklas |
124 |
} |
7604 |
25 Feb 19 |
nicklas |
125 |
} |
7604 |
25 Feb 19 |
nicklas |
126 |
} |
7604 |
25 Feb 19 |
nicklas |
127 |
|
7604 |
25 Feb 19 |
nicklas |
bioplates.loadAnnotationsFrame = function() |
7604 |
25 Feb 19 |
nicklas |
129 |
{ |
7604 |
25 Feb 19 |
nicklas |
Annotations.autoLoadEditFrame(null, null, bioplates.getParents()); |
7604 |
25 Feb 19 |
nicklas |
131 |
} |
7604 |
25 Feb 19 |
nicklas |
132 |
|
7604 |
25 Feb 19 |
nicklas |
bioplates.getParents = function() |
7604 |
25 Feb 19 |
nicklas |
134 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioplate']; |
7604 |
25 Feb 19 |
nicklas |
var parents = new Array(); |
7604 |
25 Feb 19 |
nicklas |
var storageId = Math.abs(parseInt(frm.storage_id.value)); |
7604 |
25 Feb 19 |
nicklas |
if (storageId > 0) parents[parents.length] = 'HARDWARE:'+storageId; |
7604 |
25 Feb 19 |
nicklas |
return parents; |
7604 |
25 Feb 19 |
nicklas |
140 |
} |
7604 |
25 Feb 19 |
nicklas |
141 |
|
7604 |
25 Feb 19 |
nicklas |
142 |
|
7604 |
25 Feb 19 |
nicklas |
bioplates.viewWells = function() |
7604 |
25 Feb 19 |
nicklas |
144 |
{ |
7604 |
25 Feb 19 |
nicklas |
var bioplateId = Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
var url = 'wells/index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&bioplate_id='+bioplateId; |
7604 |
25 Feb 19 |
nicklas |
location.replace(url); |
7604 |
25 Feb 19 |
nicklas |
149 |
} |
7604 |
25 Feb 19 |
nicklas |
150 |
|
7604 |
25 Feb 19 |
nicklas |
bioplates.viewEvents = function() |
7604 |
25 Feb 19 |
nicklas |
152 |
{ |
7604 |
25 Feb 19 |
nicklas |
var bioplateId = 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 += '&bioplate_id='+bioplateId; |
7604 |
25 Feb 19 |
nicklas |
location.replace(url); |
7604 |
25 Feb 19 |
nicklas |
157 |
} |
7604 |
25 Feb 19 |
nicklas |
158 |
|
7604 |
25 Feb 19 |
nicklas |
bioplates.moveBioMaterial = function() |
7604 |
25 Feb 19 |
nicklas |
160 |
{ |
7604 |
25 Feb 19 |
nicklas |
var bioplateId = Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
var url = 'index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=MoveBioMaterial'; |
7604 |
25 Feb 19 |
nicklas |
url += '&item_id='+bioplateId; |
7604 |
25 Feb 19 |
nicklas |
Dialogs.openPopup(url, 'MoveBioMaterial', 900, 600); |
7604 |
25 Feb 19 |
nicklas |
166 |
} |
7604 |
25 Feb 19 |
nicklas |
167 |
|
7604 |
25 Feb 19 |
nicklas |
bioplates.createChildBioPlate = function() |
7604 |
25 Feb 19 |
nicklas |
169 |
{ |
7604 |
25 Feb 19 |
nicklas |
var bioplateId = Data.get('page-data', 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
var url = 'index.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=CreateChildBioPlate'; |
7604 |
25 Feb 19 |
nicklas |
url += '&item_id='+bioplateId; |
7604 |
25 Feb 19 |
nicklas |
Dialogs.openPopup(url, 'CreateChildBioPlate', 900, 600); |
7604 |
25 Feb 19 |
nicklas |
175 |
} |
7604 |
25 Feb 19 |
nicklas |
176 |
|
7604 |
25 Feb 19 |
nicklas |
bioplates.editWell = function(event) |
7604 |
25 Feb 19 |
nicklas |
178 |
{ |
7604 |
25 Feb 19 |
nicklas |
var well = event.currentTarget; |
7604 |
25 Feb 19 |
nicklas |
var wellId = Data.get(well, 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
Items.editItem('BIOWELL', wellId); |
7604 |
25 Feb 19 |
nicklas |
182 |
} |
7604 |
25 Feb 19 |
nicklas |
183 |
|
7604 |
25 Feb 19 |
nicklas |
bioplates.showWellInfo = function(event) |
7604 |
25 Feb 19 |
nicklas |
185 |
{ |
7604 |
25 Feb 19 |
nicklas |
var well = event.currentTarget; |
7604 |
25 Feb 19 |
nicklas |
var wellId = Data.get(well, 'item-id'); |
7604 |
25 Feb 19 |
nicklas |
var coordinate = Data.get(well, 'coordinate'); |
7604 |
25 Feb 19 |
nicklas |
189 |
|
7604 |
25 Feb 19 |
nicklas |
// Display the 'wellInfo' postit note |
7604 |
25 Feb 19 |
nicklas |
var wellInfo = Doc.element('wellInfo'); |
7604 |
25 Feb 19 |
nicklas |
var wellTd = Doc.element('well.' + wellId); |
7604 |
25 Feb 19 |
nicklas |
var contentPos = Doc.getElementPosition('main.content'); |
7604 |
25 Feb 19 |
nicklas |
var pos = Doc.getElementPosition(wellTd); |
7604 |
25 Feb 19 |
nicklas |
var wiPos = Doc.getElementPosition('wellInfo'); |
7604 |
25 Feb 19 |
nicklas |
wellInfo.style.left = (pos.left + pos.width - contentPos.left - 5) + 'px'; |
7604 |
25 Feb 19 |
nicklas |
wellInfo.style.top = (pos.top - contentPos.top - 10) + 'px'; |
7604 |
25 Feb 19 |
nicklas |
Doc.show('wellInfo'); |
7604 |
25 Feb 19 |
nicklas |
199 |
|
7604 |
25 Feb 19 |
nicklas |
// Get the well information |
7604 |
25 Feb 19 |
nicklas |
var info = wellInfoCache['well.'+wellId]; |
7604 |
25 Feb 19 |
nicklas |
if (!info) |
7604 |
25 Feb 19 |
nicklas |
203 |
{ |
7604 |
25 Feb 19 |
nicklas |
// Use Ajax to load the information |
7604 |
25 Feb 19 |
nicklas |
wellInfo.innerHTML = '[' + coordinate + '] loading, please wait...'; |
7604 |
25 Feb 19 |
nicklas |
info = bioplates.loadWellInfo(wellId); |
7604 |
25 Feb 19 |
nicklas |
207 |
} |
7604 |
25 Feb 19 |
nicklas |
var html; |
7604 |
25 Feb 19 |
nicklas |
var bioMaterial = info.bioMaterial; |
7604 |
25 Feb 19 |
nicklas |
if (bioMaterial) |
7604 |
25 Feb 19 |
nicklas |
211 |
{ |
7604 |
25 Feb 19 |
nicklas |
if (bioMaterial.denied) |
7604 |
25 Feb 19 |
nicklas |
213 |
{ |
7604 |
25 Feb 19 |
nicklas |
html = 'Denied'; |
7604 |
25 Feb 19 |
nicklas |
215 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
217 |
{ |
7604 |
25 Feb 19 |
nicklas |
var id = bioMaterial.id; |
7604 |
25 Feb 19 |
nicklas |
var type = bioMaterial.type; |
7604 |
25 Feb 19 |
nicklas |
var subtype = bioMaterial.subtype; |
7604 |
25 Feb 19 |
nicklas |
html = '<span class="link"'; |
7604 |
25 Feb 19 |
nicklas |
html += ' data-item-type="'+type+'" data-item-id="'+id+'"'; |
7604 |
25 Feb 19 |
nicklas |
html += ' data-no-edit="'+bioMaterial.editable ? 0 : 1+'"'; |
7604 |
25 Feb 19 |
nicklas |
html += ' title="View this item'; |
7604 |
25 Feb 19 |
nicklas |
if (bioMaterial.editable) html += ' (use CTRL, ALT or SHIFT to edit)'; |
7604 |
25 Feb 19 |
nicklas |
html += '">'+bioMaterial.name+'</span>'; |
7604 |
25 Feb 19 |
nicklas |
html += ': <b>' + type + '</b>'; |
7604 |
25 Feb 19 |
nicklas |
if (subtype) html += ' <span class="itemsubtype">[' + subtype.name + ']</span>'; |
7604 |
25 Feb 19 |
nicklas |
html += '<br>'+bioMaterial.description; |
7604 |
25 Feb 19 |
nicklas |
230 |
} |
7604 |
25 Feb 19 |
nicklas |
231 |
} |
7604 |
25 Feb 19 |
nicklas |
else |
7604 |
25 Feb 19 |
nicklas |
233 |
{ |
7604 |
25 Feb 19 |
nicklas |
html = 'Empty'; |
7604 |
25 Feb 19 |
nicklas |
235 |
} |
7604 |
25 Feb 19 |
nicklas |
wellInfo.innerHTML = html; |
7604 |
25 Feb 19 |
nicklas |
Events.addEventHandler(wellInfo.getElementsByClassName('link')[0], 'click', Items.itemOnClick); |
7604 |
25 Feb 19 |
nicklas |
238 |
} |
7604 |
25 Feb 19 |
nicklas |
239 |
|
7604 |
25 Feb 19 |
nicklas |
bioplates.hideWellInfo = function() |
7604 |
25 Feb 19 |
nicklas |
241 |
{ |
7604 |
25 Feb 19 |
nicklas |
Doc.hide('wellInfo'); |
7604 |
25 Feb 19 |
nicklas |
243 |
} |
7604 |
25 Feb 19 |
nicklas |
244 |
|
7604 |
25 Feb 19 |
nicklas |
bioplates.loadWellInfo = function(wellId) |
7604 |
25 Feb 19 |
nicklas |
246 |
{ |
7604 |
25 Feb 19 |
nicklas |
var request = Ajax.getXmlHttpRequest(); |
7604 |
25 Feb 19 |
nicklas |
var url = 'wells/ajax.jsp?ID='+App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=WellInfo&encodeStrings=1&item_id=' + wellId; |
7604 |
25 Feb 19 |
nicklas |
request.open("GET", url, false); |
7604 |
25 Feb 19 |
nicklas |
251 |
|
7604 |
25 Feb 19 |
nicklas |
// NOTE! 'false' causes code to wait for the response. aka. 'Synchronous AJAX' or SJAX. |
7604 |
25 Feb 19 |
nicklas |
request.send(null); |
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 |
256 |
{ |
7604 |
25 Feb 19 |
nicklas |
alert(response.message); |
7604 |
25 Feb 19 |
nicklas |
return false; |
7604 |
25 Feb 19 |
nicklas |
259 |
} |
7604 |
25 Feb 19 |
nicklas |
260 |
|
7604 |
25 Feb 19 |
nicklas |
wellInfoCache['well.'+wellId] = response; |
7604 |
25 Feb 19 |
nicklas |
return response; |
7604 |
25 Feb 19 |
nicklas |
263 |
} |
7604 |
25 Feb 19 |
nicklas |
264 |
|
7604 |
25 Feb 19 |
nicklas |
265 |
|
7604 |
25 Feb 19 |
nicklas |
bioplates.validateBioPlate = function() |
7604 |
25 Feb 19 |
nicklas |
267 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioplate']; |
7604 |
25 Feb 19 |
nicklas |
if (Strings.trim(frm.name.value) == '') |
7604 |
25 Feb 19 |
nicklas |
270 |
{ |
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 |
273 |
} |
7604 |
25 Feb 19 |
nicklas |
if (frm.bioplatetype_id && frm.bioplatetype_id.length == 0) |
7604 |
25 Feb 19 |
nicklas |
275 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.showNotification('bioplatetype_id.select', 'You must select a bioplate type'); |
7604 |
25 Feb 19 |
nicklas |
return false; |
7604 |
25 Feb 19 |
nicklas |
278 |
} |
7604 |
25 Feb 19 |
nicklas |
if (frm.plategeometry_id && frm.plategeometry_id.length == 0) |
7604 |
25 Feb 19 |
nicklas |
280 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.showNotification('plategeometry_id.select', 'You must select a plate geometry'); |
7604 |
25 Feb 19 |
nicklas |
return false; |
7604 |
25 Feb 19 |
nicklas |
283 |
} |
7604 |
25 Feb 19 |
nicklas |
return true; |
7604 |
25 Feb 19 |
nicklas |
285 |
} |
7604 |
25 Feb 19 |
nicklas |
286 |
|
7604 |
25 Feb 19 |
nicklas |
// Submit the form |
7604 |
25 Feb 19 |
nicklas |
bioplates.save = function() |
7604 |
25 Feb 19 |
nicklas |
289 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioplate']; |
7604 |
25 Feb 19 |
nicklas |
if (TabControl.validateActiveTab('settings')) |
7604 |
25 Feb 19 |
nicklas |
292 |
{ |
7604 |
25 Feb 19 |
nicklas |
Annotations.saveModifiedAnnotationsToForm(frm); |
7604 |
25 Feb 19 |
nicklas |
frm.submit(); |
7604 |
25 Feb 19 |
nicklas |
295 |
} |
7604 |
25 Feb 19 |
nicklas |
296 |
} |
7604 |
25 Feb 19 |
nicklas |
297 |
|
7604 |
25 Feb 19 |
nicklas |
bioplates.selectPlateGeometry = function() |
7604 |
25 Feb 19 |
nicklas |
299 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioplate']; |
7604 |
25 Feb 19 |
nicklas |
var url = ''; |
7604 |
25 Feb 19 |
nicklas |
if (frm.plategeometry_id.length > 0) |
7604 |
25 Feb 19 |
nicklas |
303 |
{ |
7604 |
25 Feb 19 |
nicklas |
url += '&item_id='+frm.plategeometry_id[0].value; |
7604 |
25 Feb 19 |
nicklas |
305 |
} |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('PLATEGEOMETRY', 'plategeometry_id', 0, url); |
7604 |
25 Feb 19 |
nicklas |
307 |
} |
7604 |
25 Feb 19 |
nicklas |
308 |
|
7604 |
25 Feb 19 |
nicklas |
bioplates.setPlateGeometryCallback = function(event) |
7604 |
25 Feb 19 |
nicklas |
310 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioplate']; |
7604 |
25 Feb 19 |
nicklas |
var list = frm.plategeometry_id; |
7604 |
25 Feb 19 |
nicklas |
if (list.length < 1 || list[0].disabled) |
7604 |
25 Feb 19 |
nicklas |
314 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.addListOption(list, 0, new Option()); |
7604 |
25 Feb 19 |
nicklas |
316 |
} |
7604 |
25 Feb 19 |
nicklas |
list[0].value = event.detail.id; |
7604 |
25 Feb 19 |
nicklas |
list[0].text = event.detail.name; |
7604 |
25 Feb 19 |
nicklas |
list.selectedIndex = 0; |
7604 |
25 Feb 19 |
nicklas |
320 |
} |
7604 |
25 Feb 19 |
nicklas |
321 |
|
7604 |
25 Feb 19 |
nicklas |
bioplates.selectBioPlateType = function() |
7604 |
25 Feb 19 |
nicklas |
323 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioplate']; |
7604 |
25 Feb 19 |
nicklas |
var url = ''; |
7604 |
25 Feb 19 |
nicklas |
if (frm.bioplatetype_id.length > 0) |
7604 |
25 Feb 19 |
nicklas |
327 |
{ |
7604 |
25 Feb 19 |
nicklas |
url += '&item_id='+frm.bioplatetype_id[0].value; |
7604 |
25 Feb 19 |
nicklas |
329 |
} |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('BIOPLATETYPE', 'bioplatetype_id', 0, url); |
7604 |
25 Feb 19 |
nicklas |
331 |
} |
7604 |
25 Feb 19 |
nicklas |
332 |
|
7604 |
25 Feb 19 |
nicklas |
bioplates.setBioPlateTypeCallback = function(event) |
7604 |
25 Feb 19 |
nicklas |
334 |
{ |
7604 |
25 Feb 19 |
nicklas |
335 |
|
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioplate']; |
7604 |
25 Feb 19 |
nicklas |
var list = frm.bioplatetype_id; |
7604 |
25 Feb 19 |
nicklas |
if (list.length < 1 || list[0].disabled) |
7604 |
25 Feb 19 |
nicklas |
339 |
{ |
7604 |
25 Feb 19 |
nicklas |
Forms.addListOption(list, 0, new Option()); |
7604 |
25 Feb 19 |
nicklas |
341 |
} |
7604 |
25 Feb 19 |
nicklas |
list[0].value = event.detail.id; |
7604 |
25 Feb 19 |
nicklas |
list[0].text = event.detail.name; |
7604 |
25 Feb 19 |
nicklas |
list.selectedIndex = 0; |
7604 |
25 Feb 19 |
nicklas |
bioplates.bioPlateTypeOnChange(); |
7604 |
25 Feb 19 |
nicklas |
346 |
} |
7604 |
25 Feb 19 |
nicklas |
347 |
|
7604 |
25 Feb 19 |
nicklas |
bioplates.bioPlateTypeOnChange = function() |
7604 |
25 Feb 19 |
nicklas |
349 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioplate']; |
7604 |
25 Feb 19 |
nicklas |
if (frm.bioplatetype_id.selectedIndex < 0) return; |
7604 |
25 Feb 19 |
nicklas |
352 |
|
7604 |
25 Feb 19 |
nicklas |
var bioPlateTypeInfo = bioplates.getBioPlateTypeInfo(frm.bioplatetype_id.value); |
7604 |
25 Feb 19 |
nicklas |
var freezerTypeId = Data.get('storage_id', 'freezer-id'); |
7604 |
25 Feb 19 |
nicklas |
var storageTypeId = bioPlateTypeInfo.storageType ? bioPlateTypeInfo.storageType.id : freezerTypeId; |
7604 |
25 Feb 19 |
nicklas |
Data.set('storage_id', 'storage-type-id', storageTypeId); |
7604 |
25 Feb 19 |
nicklas |
var recentInfo = ItemSubtype.getProjectDefaultAndRecentItems('BIOPLATE', storageTypeId); |
7604 |
25 Feb 19 |
nicklas |
ItemSubtype.updateSelectionList(frm.storage_id, recentInfo['recent'], recentInfo['default']); |
7604 |
25 Feb 19 |
nicklas |
359 |
} |
7604 |
25 Feb 19 |
nicklas |
360 |
|
7604 |
25 Feb 19 |
nicklas |
361 |
|
7604 |
25 Feb 19 |
nicklas |
bioplates.getBioPlateTypeInfo = function(bioPlateTypeId) |
7604 |
25 Feb 19 |
nicklas |
363 |
{ |
7604 |
25 Feb 19 |
nicklas |
var request = Ajax.getXmlHttpRequest(); |
7703 |
11 Apr 19 |
nicklas |
var url = '../bioplatetypes/ajax.jsp?ID=' + App.getSessionId(); |
7604 |
25 Feb 19 |
nicklas |
url += '&cmd=GetPlateTypeInfo'; |
7604 |
25 Feb 19 |
nicklas |
url += '&item_id='+bioPlateTypeId; |
7604 |
25 Feb 19 |
nicklas |
request.open("GET", url, false); |
7604 |
25 Feb 19 |
nicklas |
request.send(null); |
7604 |
25 Feb 19 |
nicklas |
return JSON.parse(request.responseText); |
7604 |
25 Feb 19 |
nicklas |
371 |
} |
7604 |
25 Feb 19 |
nicklas |
372 |
|
7604 |
25 Feb 19 |
nicklas |
bioplates.selectStorageLocation = function() |
7604 |
25 Feb 19 |
nicklas |
374 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioplate']; |
7604 |
25 Feb 19 |
nicklas |
var url = ''; |
7604 |
25 Feb 19 |
nicklas |
if (frm.storage_id.length > 1) |
7604 |
25 Feb 19 |
nicklas |
378 |
{ |
7604 |
25 Feb 19 |
nicklas |
var id = Math.abs(parseInt(frm.storage_id[1].value)); |
7604 |
25 Feb 19 |
nicklas |
url += '&item_id='+id; |
7604 |
25 Feb 19 |
nicklas |
381 |
} |
7604 |
25 Feb 19 |
nicklas |
var storageTypeId = Data.get('storage_id', 'storage-type-id', Data.get('storage_id', 'freezer-id')); |
7604 |
25 Feb 19 |
nicklas |
url += '&resetTemporary=1&tmpfilter:INT:itemSubtype='+storageTypeId; |
7604 |
25 Feb 19 |
nicklas |
Dialogs.selectItem('HARDWARE', 'storage_id', 0, url); |
7604 |
25 Feb 19 |
nicklas |
385 |
} |
7604 |
25 Feb 19 |
nicklas |
386 |
|
7604 |
25 Feb 19 |
nicklas |
bioplates.setStorageLocationCallback = function(event) |
7604 |
25 Feb 19 |
nicklas |
388 |
{ |
7604 |
25 Feb 19 |
nicklas |
var frm = document.forms['bioplate']; |
7604 |
25 Feb 19 |
nicklas |
if (frm.storage_id.length < 1) |
7604 |
25 Feb 19 |
nicklas |
391 |
{ |
7604 |
25 Feb 19 |
nicklas |
frm.storage_id[frm.storage_id.length] = new Option(); |
7604 |
25 Feb 19 |
nicklas |
393 |
} |
7604 |
25 Feb 19 |
nicklas |
frm.storage_id[0].value = event.detail.id; |
7604 |
25 Feb 19 |
nicklas |
frm.storage_id[0].text = event.detail.name; |
7604 |
25 Feb 19 |
nicklas |
frm.storage_id.selectedIndex = 0; |
7604 |
25 Feb 19 |
nicklas |
397 |
} |
7604 |
25 Feb 19 |
nicklas |
398 |
|
7604 |
25 Feb 19 |
nicklas |
return bioplates; |
7604 |
25 Feb 19 |
nicklas |
400 |
}(); |
7604 |
25 Feb 19 |
nicklas |
401 |
|
7604 |
25 Feb 19 |
nicklas |
Doc.addElementInitializer(BioPlates.initElements); |
7604 |
25 Feb 19 |
nicklas |
Doc.onLoad(BioPlates.initPage); |