5631 |
27 Sep 19 |
nicklas |
var ImportPlates = function() |
5631 |
27 Sep 19 |
nicklas |
2 |
{ |
5631 |
27 Sep 19 |
nicklas |
var importer = {}; |
5631 |
27 Sep 19 |
nicklas |
var debug = 0; |
5631 |
27 Sep 19 |
nicklas |
5 |
|
5631 |
27 Sep 19 |
nicklas |
var prefixIsValid = false; |
5631 |
27 Sep 19 |
nicklas |
7 |
|
5631 |
27 Sep 19 |
nicklas |
var importData; |
5631 |
27 Sep 19 |
nicklas |
9 |
|
5631 |
27 Sep 19 |
nicklas |
// Page initialization |
5631 |
27 Sep 19 |
nicklas |
importer.initPage = function() |
5631 |
27 Sep 19 |
nicklas |
12 |
{ |
5631 |
27 Sep 19 |
nicklas |
// Step 1 |
5631 |
27 Sep 19 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', importer.validateStep1); |
5631 |
27 Sep 19 |
nicklas |
15 |
|
5631 |
27 Sep 19 |
nicklas |
Events.addEventHandler('prefix', 'change', importer.prefixOnChange); |
5631 |
27 Sep 19 |
nicklas |
Events.addEventHandler('prefix', 'keypress', Wizard.focusOnEnter); |
5631 |
27 Sep 19 |
nicklas |
Wizard.initFileSelectionField('importfile'); |
5631 |
27 Sep 19 |
nicklas |
Events.addEventHandler('importfile', 'change', importer.importFileOnChange); |
5631 |
27 Sep 19 |
nicklas |
Events.addEventHandler('sheet', 'change', importer.worksheetOnChange); |
5631 |
27 Sep 19 |
nicklas |
21 |
|
5631 |
27 Sep 19 |
nicklas |
Events.addEventHandler('plateNames', 'change', importer.displayAliquotsOnPlate); |
5631 |
27 Sep 19 |
nicklas |
23 |
|
5631 |
27 Sep 19 |
nicklas |
// Navigation |
5631 |
27 Sep 19 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
5631 |
27 Sep 19 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
5631 |
27 Sep 19 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
5631 |
27 Sep 19 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
5631 |
27 Sep 19 |
nicklas |
29 |
|
5631 |
27 Sep 19 |
nicklas |
// Final registration |
5631 |
27 Sep 19 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', importer.submit); |
5631 |
27 Sep 19 |
nicklas |
32 |
|
5631 |
27 Sep 19 |
nicklas |
Plate.init(9, 9, null, WellPainter); |
5631 |
27 Sep 19 |
nicklas |
Plate.paint(Plate.getWells()); |
5631 |
27 Sep 19 |
nicklas |
window.addEventListener('beforeunload', importer.confirmLeaveWizard); |
5631 |
27 Sep 19 |
nicklas |
// Wizard.keepSessionAlive(); |
5631 |
27 Sep 19 |
nicklas |
37 |
|
5631 |
27 Sep 19 |
nicklas |
Doc.show('step-1'); |
5631 |
27 Sep 19 |
nicklas |
Doc.show('gocancel'); |
5631 |
27 Sep 19 |
nicklas |
Doc.show('goregister'); |
5631 |
27 Sep 19 |
nicklas |
Events.sendChangeEvent('prefix'); |
5631 |
27 Sep 19 |
nicklas |
42 |
} |
5631 |
27 Sep 19 |
nicklas |
43 |
|
5631 |
27 Sep 19 |
nicklas |
44 |
/** |
5631 |
27 Sep 19 |
nicklas |
Ask for confirmation to abort if RNA has been placed on the plate. |
5631 |
27 Sep 19 |
nicklas |
46 |
*/ |
5631 |
27 Sep 19 |
nicklas |
importer.confirmLeaveWizard = function(event) |
5631 |
27 Sep 19 |
nicklas |
48 |
{ |
5631 |
27 Sep 19 |
nicklas |
if (Plate.getUsed().length > 0) |
5631 |
27 Sep 19 |
nicklas |
50 |
{ |
5631 |
27 Sep 19 |
nicklas |
event.preventDefault(); |
5631 |
27 Sep 19 |
nicklas |
52 |
} |
5631 |
27 Sep 19 |
nicklas |
53 |
} |
5631 |
27 Sep 19 |
nicklas |
54 |
|
5631 |
27 Sep 19 |
nicklas |
importer.prefixOnChange = function() |
5631 |
27 Sep 19 |
nicklas |
56 |
{ |
5631 |
27 Sep 19 |
nicklas |
var frm = document.forms['reggie']; |
5631 |
27 Sep 19 |
nicklas |
Wizard.setInputStatus('prefix'); |
5631 |
27 Sep 19 |
nicklas |
59 |
|
5631 |
27 Sep 19 |
nicklas |
var prefix = frm.prefix.value.toUpperCase().replace(/_/g, ''); |
5631 |
27 Sep 19 |
nicklas |
prefixIsValid = false; |
5631 |
27 Sep 19 |
nicklas |
if (prefix.length < 2) |
5631 |
27 Sep 19 |
nicklas |
63 |
{ |
5631 |
27 Sep 19 |
nicklas |
Wizard.setInputStatus('prefix', 'invalid', 'The prefix should have at least 2 characters.'); |
5631 |
27 Sep 19 |
nicklas |
frm.prefix.focus(); |
5631 |
27 Sep 19 |
nicklas |
return; |
5631 |
27 Sep 19 |
nicklas |
67 |
} |
5631 |
27 Sep 19 |
nicklas |
68 |
|
5631 |
27 Sep 19 |
nicklas |
frm.prefix.value = prefix+'_'; |
5631 |
27 Sep 19 |
nicklas |
Wizard.setInputStatus('prefix', 'valid'); |
5631 |
27 Sep 19 |
nicklas |
prefixIsValid = true; |
5631 |
27 Sep 19 |
nicklas |
72 |
|
5631 |
27 Sep 19 |
nicklas |
importer.prevalidateImportFile(); |
5631 |
27 Sep 19 |
nicklas |
74 |
} |
5631 |
27 Sep 19 |
nicklas |
75 |
|
5631 |
27 Sep 19 |
nicklas |
importer.importFileOnChange = function() |
5631 |
27 Sep 19 |
nicklas |
77 |
{ |
5631 |
27 Sep 19 |
nicklas |
Doc.hide('worksheetSection'); |
5631 |
27 Sep 19 |
nicklas |
Doc.hide('worksheetSection.help'); |
5631 |
27 Sep 19 |
nicklas |
importer.prevalidateImportFile(); |
5631 |
27 Sep 19 |
nicklas |
81 |
} |
5631 |
27 Sep 19 |
nicklas |
82 |
|
5631 |
27 Sep 19 |
nicklas |
importer.worksheetOnChange = function() |
5631 |
27 Sep 19 |
nicklas |
84 |
{ |
5631 |
27 Sep 19 |
nicklas |
importer.prevalidateImportFile(); |
5631 |
27 Sep 19 |
nicklas |
86 |
} |
5631 |
27 Sep 19 |
nicklas |
87 |
|
5631 |
27 Sep 19 |
nicklas |
importer.validateStep1 = function(event) |
5631 |
27 Sep 19 |
nicklas |
89 |
{ |
5631 |
27 Sep 19 |
nicklas |
if (!prefixIsValid || !Wizard.isValid('importfile')) |
5631 |
27 Sep 19 |
nicklas |
91 |
{ |
5631 |
27 Sep 19 |
nicklas |
event.preventDefault(); |
5631 |
27 Sep 19 |
nicklas |
93 |
} |
5631 |
27 Sep 19 |
nicklas |
94 |
} |
5631 |
27 Sep 19 |
nicklas |
95 |
|
5631 |
27 Sep 19 |
nicklas |
importer.prevalidateImportFile = function() |
5631 |
27 Sep 19 |
nicklas |
97 |
{ |
5631 |
27 Sep 19 |
nicklas |
Doc.hide('platePreview'); |
5631 |
27 Sep 19 |
nicklas |
Wizard.hideWizardStatus(); |
5631 |
27 Sep 19 |
nicklas |
Wizard.hideGoNextConfirmation(); |
5631 |
27 Sep 19 |
nicklas |
101 |
|
5631 |
27 Sep 19 |
nicklas |
var frm = document.forms['reggie']; |
5631 |
27 Sep 19 |
nicklas |
var path = frm.importfile.value; |
5631 |
27 Sep 19 |
nicklas |
if (!prefixIsValid || path == '') return; |
5631 |
27 Sep 19 |
nicklas |
105 |
|
5631 |
27 Sep 19 |
nicklas |
Wizard.setInputStatus('importfile'); |
5631 |
27 Sep 19 |
nicklas |
Data.set('importfile', 'valid', 0); |
5631 |
27 Sep 19 |
nicklas |
108 |
|
5631 |
27 Sep 19 |
nicklas |
var url = '../Import.servlet?ID='+App.getSessionId(); |
5631 |
27 Sep 19 |
nicklas |
url += '&cmd=PreValidateRNAImportFile'; |
5631 |
27 Sep 19 |
nicklas |
url += '&path='+encodeURIComponent(path); |
5631 |
27 Sep 19 |
nicklas |
url += '&prefix='+encodeURIComponent(frm.prefix.value); |
5631 |
27 Sep 19 |
nicklas |
url += '&sheet='+encodeURIComponent(frm.sheet.value); |
5631 |
27 Sep 19 |
nicklas |
114 |
|
5631 |
27 Sep 19 |
nicklas |
Wizard.showLoadingAnimation('Validating ' + Strings.encodeTags(path)); |
5631 |
27 Sep 19 |
nicklas |
Wizard.asyncJsonRequest(url, importer.onImportFileValidated, 'POST'); |
5631 |
27 Sep 19 |
nicklas |
117 |
} |
5631 |
27 Sep 19 |
nicklas |
118 |
|
5631 |
27 Sep 19 |
nicklas |
importer.onImportFileValidated = function(response) |
5631 |
27 Sep 19 |
nicklas |
120 |
{ |
5631 |
27 Sep 19 |
nicklas |
var frm = document.forms['reggie']; |
5631 |
27 Sep 19 |
nicklas |
122 |
|
5631 |
27 Sep 19 |
nicklas |
Wizard.setInputStatus('importfile'); |
5631 |
27 Sep 19 |
nicklas |
Wizard.showFinalMessage(response.messages); |
5631 |
27 Sep 19 |
nicklas |
125 |
|
5631 |
27 Sep 19 |
nicklas |
importData = response.importFile; |
5631 |
27 Sep 19 |
nicklas |
127 |
|
5631 |
27 Sep 19 |
nicklas |
var sheetNames = importData.sheetNames; |
5631 |
27 Sep 19 |
nicklas |
if (sheetNames && sheetNames.length) |
5631 |
27 Sep 19 |
nicklas |
130 |
{ |
5631 |
27 Sep 19 |
nicklas |
var currentSheet = frm.sheet.value; |
5631 |
27 Sep 19 |
nicklas |
frm.sheet.length = 0; |
5631 |
27 Sep 19 |
nicklas |
for (var sNo = 0; sNo < sheetNames.length; sNo++) |
5631 |
27 Sep 19 |
nicklas |
134 |
{ |
5631 |
27 Sep 19 |
nicklas |
var sheet = sheetNames[sNo]; |
5631 |
27 Sep 19 |
nicklas |
frm.sheet[frm.sheet.length] = new Option(sheet, sheet, false, currentSheet == sheet); |
5631 |
27 Sep 19 |
nicklas |
137 |
} |
5631 |
27 Sep 19 |
nicklas |
if (frm.sheet.length > 1) |
5631 |
27 Sep 19 |
nicklas |
139 |
{ |
5631 |
27 Sep 19 |
nicklas |
Doc.show('worksheetSection'); |
5631 |
27 Sep 19 |
nicklas |
Doc.show('worksheetSection.help'); |
5631 |
27 Sep 19 |
nicklas |
142 |
} |
5631 |
27 Sep 19 |
nicklas |
143 |
} |
5631 |
27 Sep 19 |
nicklas |
144 |
|
5631 |
27 Sep 19 |
nicklas |
var plates = importData.plates; |
5631 |
27 Sep 19 |
nicklas |
frm.plateNames.length = 0; |
5631 |
27 Sep 19 |
nicklas |
147 |
|
5631 |
27 Sep 19 |
nicklas |
if (plates && plates.length) |
5631 |
27 Sep 19 |
nicklas |
149 |
{ |
5631 |
27 Sep 19 |
nicklas |
for (var pNo = 0; pNo < plates.length; pNo++) |
5631 |
27 Sep 19 |
nicklas |
151 |
{ |
5631 |
27 Sep 19 |
nicklas |
var plate = plates[pNo]; |
5631 |
27 Sep 19 |
nicklas |
var text = plate.name; |
5631 |
27 Sep 19 |
nicklas |
if (plate.error) |
5631 |
27 Sep 19 |
nicklas |
155 |
{ |
5631 |
27 Sep 19 |
nicklas |
text += ' (' + plate.error + ')'; |
5631 |
27 Sep 19 |
nicklas |
157 |
} |
5631 |
27 Sep 19 |
nicklas |
else |
5631 |
27 Sep 19 |
nicklas |
159 |
{ |
5635 |
01 Oct 19 |
nicklas |
text += ' ('; |
5635 |
01 Oct 19 |
nicklas |
text += plate.id ? 'existing box; ' : 'new box; '; |
5635 |
01 Oct 19 |
nicklas |
text += plate.aliquots.length + ' aliquots)'; |
5631 |
27 Sep 19 |
nicklas |
163 |
} |
5631 |
27 Sep 19 |
nicklas |
frm.plateNames[frm.plateNames.length] = new Option(text); |
5631 |
27 Sep 19 |
nicklas |
165 |
} |
5631 |
27 Sep 19 |
nicklas |
166 |
} |
5631 |
27 Sep 19 |
nicklas |
167 |
|
5631 |
27 Sep 19 |
nicklas |
if (importData.valid) |
5631 |
27 Sep 19 |
nicklas |
169 |
{ |
5631 |
27 Sep 19 |
nicklas |
Wizard.setInputStatus('importfile', importData.warnings > 0 ? 'warning' : 'valid'); |
5631 |
27 Sep 19 |
nicklas |
Data.set('importfile', 'valid', 1); |
5631 |
27 Sep 19 |
nicklas |
if (importData.warnings > 0) |
5631 |
27 Sep 19 |
nicklas |
173 |
{ |
5631 |
27 Sep 19 |
nicklas |
Wizard.showGoNextConfirmation(true, 'Check to verify registration of plate with warnings.'); |
5631 |
27 Sep 19 |
nicklas |
175 |
} |
5631 |
27 Sep 19 |
nicklas |
176 |
} |
5631 |
27 Sep 19 |
nicklas |
else |
5631 |
27 Sep 19 |
nicklas |
178 |
{ |
5631 |
27 Sep 19 |
nicklas |
Wizard.setInputStatus('importfile', 'invalid'); |
5631 |
27 Sep 19 |
nicklas |
180 |
} |
5631 |
27 Sep 19 |
nicklas |
181 |
|
5631 |
27 Sep 19 |
nicklas |
importer.displayAliquotsOnPlate(); |
5631 |
27 Sep 19 |
nicklas |
183 |
} |
5631 |
27 Sep 19 |
nicklas |
184 |
|
5631 |
27 Sep 19 |
nicklas |
importer.displayAliquotsOnPlate = function() |
5631 |
27 Sep 19 |
nicklas |
186 |
{ |
5631 |
27 Sep 19 |
nicklas |
Doc.element('filename').innerHTML = Strings.encodeTags(importData.filename); |
5631 |
27 Sep 19 |
nicklas |
Doc.element('numPlates').innerHTML = importData.numPlates; |
5631 |
27 Sep 19 |
nicklas |
Doc.element('numAliquots').innerHTML = importData.numAliquots; |
5631 |
27 Sep 19 |
nicklas |
Doc.element('numErrors').innerHTML = importData.errors; |
5631 |
27 Sep 19 |
nicklas |
Doc.element('numWarnings').innerHTML = importData.warnings; |
5631 |
27 Sep 19 |
nicklas |
192 |
|
5631 |
27 Sep 19 |
nicklas |
Doc.element('importPossible').innerHTML = importData.valid ? '<img src="../images/ok.png">Import is possible!' : '<img src="../images/error.png">Import is not possible!'; |
5631 |
27 Sep 19 |
nicklas |
194 |
|
5631 |
27 Sep 19 |
nicklas |
Doc.show('platePreview'); |
5631 |
27 Sep 19 |
nicklas |
var frm = document.forms['reggie']; |
5631 |
27 Sep 19 |
nicklas |
var plateIndex = frm.plateNames.selectedIndex; |
5631 |
27 Sep 19 |
nicklas |
198 |
|
5631 |
27 Sep 19 |
nicklas |
var wells = Plate.getWells(); |
5631 |
27 Sep 19 |
nicklas |
Plate.clear(wells); |
5631 |
27 Sep 19 |
nicklas |
201 |
|
5631 |
27 Sep 19 |
nicklas |
if (plateIndex >= 0 && importData.plates.length > plateIndex) |
5631 |
27 Sep 19 |
nicklas |
203 |
{ |
5631 |
27 Sep 19 |
nicklas |
var plate = importData.plates[plateIndex]; |
5631 |
27 Sep 19 |
nicklas |
var aliquots = plate.aliquots; |
5631 |
27 Sep 19 |
nicklas |
for (var aNo = 0; aNo < aliquots.length; aNo++) |
5631 |
27 Sep 19 |
nicklas |
207 |
{ |
5631 |
27 Sep 19 |
nicklas |
var aliquot = aliquots[aNo]; |
5631 |
27 Sep 19 |
nicklas |
var well = Plate.getWellByLocation(aliquot.location); |
5631 |
27 Sep 19 |
nicklas |
if (well && !well.extract) |
5631 |
27 Sep 19 |
nicklas |
211 |
{ |
5631 |
27 Sep 19 |
nicklas |
if (plate.error && !aliquot.error) aliquot.error = plate.error; |
5631 |
27 Sep 19 |
nicklas |
well.setExtract(aliquot); |
5631 |
27 Sep 19 |
nicklas |
214 |
} |
5631 |
27 Sep 19 |
nicklas |
215 |
} |
5633 |
30 Sep 19 |
nicklas |
var existingAliquots = plate.existingAliquots; |
5633 |
30 Sep 19 |
nicklas |
for (var eNo = 0; eNo < existingAliquots.length; eNo++) |
5633 |
30 Sep 19 |
nicklas |
218 |
{ |
5633 |
30 Sep 19 |
nicklas |
var aliquot = existingAliquots[eNo]; |
5633 |
30 Sep 19 |
nicklas |
var well = Plate.getWellByLocation(aliquot.location); |
5633 |
30 Sep 19 |
nicklas |
if (well && !well.extract) |
5633 |
30 Sep 19 |
nicklas |
222 |
{ |
5633 |
30 Sep 19 |
nicklas |
//if (plate.error && !aliquot.error) aliquot.error = plate.error; |
5633 |
30 Sep 19 |
nicklas |
well.setExtract(aliquot); |
5633 |
30 Sep 19 |
nicklas |
225 |
} |
5633 |
30 Sep 19 |
nicklas |
226 |
} |
5631 |
27 Sep 19 |
nicklas |
227 |
} |
5631 |
27 Sep 19 |
nicklas |
Plate.paint(wells); |
5631 |
27 Sep 19 |
nicklas |
229 |
} |
5631 |
27 Sep 19 |
nicklas |
230 |
|
5631 |
27 Sep 19 |
nicklas |
importer.submit = function() |
5631 |
27 Sep 19 |
nicklas |
232 |
{ |
5631 |
27 Sep 19 |
nicklas |
var frm = document.forms['reggie']; |
5631 |
27 Sep 19 |
nicklas |
var path = frm.importfile.value; |
5631 |
27 Sep 19 |
nicklas |
235 |
|
5631 |
27 Sep 19 |
nicklas |
var url = '../Import.servlet?ID='+App.getSessionId(); |
5631 |
27 Sep 19 |
nicklas |
url += '&cmd=ImportRNAFromFile'; |
5631 |
27 Sep 19 |
nicklas |
url += '&path='+encodeURIComponent(path); |
5631 |
27 Sep 19 |
nicklas |
url += '&prefix='+encodeURIComponent(frm.prefix.value); |
5631 |
27 Sep 19 |
nicklas |
url += '&sheet='+encodeURIComponent(frm.sheet.value); |
5631 |
27 Sep 19 |
nicklas |
241 |
|
5631 |
27 Sep 19 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
5631 |
27 Sep 19 |
nicklas |
Wizard.asyncJsonRequest(url, importer.submissionResults, 'POST'); |
5631 |
27 Sep 19 |
nicklas |
244 |
} |
5631 |
27 Sep 19 |
nicklas |
245 |
|
5631 |
27 Sep 19 |
nicklas |
importer.submissionResults = function(response) |
5631 |
27 Sep 19 |
nicklas |
247 |
{ |
5631 |
27 Sep 19 |
nicklas |
window.removeEventListener('beforeunload', importer.confirmLeaveWizard); |
5631 |
27 Sep 19 |
nicklas |
Wizard.showFinalMessage(response.messages); |
5631 |
27 Sep 19 |
nicklas |
Doc.show('gorestart'); |
5631 |
27 Sep 19 |
nicklas |
251 |
} |
5631 |
27 Sep 19 |
nicklas |
252 |
|
5631 |
27 Sep 19 |
nicklas |
importer.initElements = function(element, autoInit) |
5631 |
27 Sep 19 |
nicklas |
254 |
{ |
5631 |
27 Sep 19 |
nicklas |
if (autoInit == 'plate-col') |
5631 |
27 Sep 19 |
nicklas |
256 |
{ |
5631 |
27 Sep 19 |
nicklas |
Events.addEventHandler(element, 'click', importer.toggleColumn); |
5631 |
27 Sep 19 |
nicklas |
Events.addEventHandler(element, 'mouseover', importer.highlightColumn); |
5631 |
27 Sep 19 |
nicklas |
Events.addEventHandler(element, 'mouseout', importer.highlightColumn); |
5631 |
27 Sep 19 |
nicklas |
260 |
} |
5631 |
27 Sep 19 |
nicklas |
else if (autoInit == 'plate-row') |
5631 |
27 Sep 19 |
nicklas |
262 |
{ |
5631 |
27 Sep 19 |
nicklas |
Events.addEventHandler(element, 'click', importer.toggleRow); |
5631 |
27 Sep 19 |
nicklas |
Events.addEventHandler(element, 'mouseover', importer.highlightRow); |
5631 |
27 Sep 19 |
nicklas |
Events.addEventHandler(element, 'mouseout', importer.highlightRow); |
5631 |
27 Sep 19 |
nicklas |
266 |
} |
5631 |
27 Sep 19 |
nicklas |
else if (autoInit == 'plate-well') |
5631 |
27 Sep 19 |
nicklas |
268 |
{ |
5631 |
27 Sep 19 |
nicklas |
Events.addEventHandler(element, 'click', importer.toggleWell); |
5631 |
27 Sep 19 |
nicklas |
270 |
} |
5631 |
27 Sep 19 |
nicklas |
271 |
} |
5631 |
27 Sep 19 |
nicklas |
272 |
|
5631 |
27 Sep 19 |
nicklas |
// Toggle the selected status of a single well |
5631 |
27 Sep 19 |
nicklas |
importer.toggleWell = function(event) |
5631 |
27 Sep 19 |
nicklas |
275 |
{ |
5631 |
27 Sep 19 |
nicklas |
var row = Data.int(event.currentTarget, 'row'); |
5631 |
27 Sep 19 |
nicklas |
var column = Data.int(event.currentTarget, 'col'); |
5631 |
27 Sep 19 |
nicklas |
var well = Plate.getWell(row, column); |
5631 |
27 Sep 19 |
nicklas |
Plate.toggleSelected([well]); |
5631 |
27 Sep 19 |
nicklas |
280 |
} |
5631 |
27 Sep 19 |
nicklas |
281 |
|
5631 |
27 Sep 19 |
nicklas |
// Toggle the selected status of a complete row |
5631 |
27 Sep 19 |
nicklas |
importer.toggleRow = function(event) |
5631 |
27 Sep 19 |
nicklas |
284 |
{ |
5631 |
27 Sep 19 |
nicklas |
var row = Data.int(event.currentTarget, 'row'); |
5631 |
27 Sep 19 |
nicklas |
Plate.toggleSelected(Plate.getRow(row)); |
5631 |
27 Sep 19 |
nicklas |
287 |
} |
5631 |
27 Sep 19 |
nicklas |
288 |
|
5631 |
27 Sep 19 |
nicklas |
// Toggle the selected status of a complete column |
5631 |
27 Sep 19 |
nicklas |
importer.toggleColumn = function(event) |
5631 |
27 Sep 19 |
nicklas |
291 |
{ |
5631 |
27 Sep 19 |
nicklas |
var column = Data.int(event.currentTarget, 'col'); |
5631 |
27 Sep 19 |
nicklas |
Plate.toggleSelected(Plate.getColumn(column)); |
5631 |
27 Sep 19 |
nicklas |
294 |
} |
5631 |
27 Sep 19 |
nicklas |
295 |
|
5631 |
27 Sep 19 |
nicklas |
// Highlight enable/disable all wells in a column |
5631 |
27 Sep 19 |
nicklas |
importer.highlightColumn = function(event) |
5631 |
27 Sep 19 |
nicklas |
298 |
{ |
5631 |
27 Sep 19 |
nicklas |
var column = Data.int(event.currentTarget, 'col'); |
5631 |
27 Sep 19 |
nicklas |
var on = event.type == 'mouseover'; |
5631 |
27 Sep 19 |
nicklas |
301 |
|
5631 |
27 Sep 19 |
nicklas |
Doc.addOrRemoveClass(event.currentTarget, 'highlight-column', on); |
5631 |
27 Sep 19 |
nicklas |
var wells = Plate.getColumn(column); |
5631 |
27 Sep 19 |
nicklas |
Plate.setHighlight(wells, 'highlight-column', on); |
5631 |
27 Sep 19 |
nicklas |
305 |
} |
5631 |
27 Sep 19 |
nicklas |
306 |
|
5631 |
27 Sep 19 |
nicklas |
// Highlight enable/disable all wells in a row |
5631 |
27 Sep 19 |
nicklas |
importer.highlightRow = function(event) |
5631 |
27 Sep 19 |
nicklas |
309 |
{ |
5631 |
27 Sep 19 |
nicklas |
var row = Data.int(event.currentTarget, 'row'); |
5631 |
27 Sep 19 |
nicklas |
var on = event.type == 'mouseover'; |
5631 |
27 Sep 19 |
nicklas |
312 |
|
5631 |
27 Sep 19 |
nicklas |
Doc.addOrRemoveClass(event.currentTarget, 'highlight-row', on); |
5631 |
27 Sep 19 |
nicklas |
var wells = Plate.getRow(row); |
5631 |
27 Sep 19 |
nicklas |
Plate.setHighlight(wells, 'highlight-row', on); |
5631 |
27 Sep 19 |
nicklas |
316 |
} |
5631 |
27 Sep 19 |
nicklas |
317 |
|
5631 |
27 Sep 19 |
nicklas |
return importer; |
5631 |
27 Sep 19 |
nicklas |
319 |
}(); |
5631 |
27 Sep 19 |
nicklas |
320 |
|
5631 |
27 Sep 19 |
nicklas |
Doc.onLoad(ImportPlates.initPage); |
5631 |
27 Sep 19 |
nicklas |
Doc.addElementInitializer(ImportPlates.initElements); |
5631 |
27 Sep 19 |
nicklas |
323 |
|
5631 |
27 Sep 19 |
nicklas |
var WellPainter = function() |
5631 |
27 Sep 19 |
nicklas |
325 |
{ |
5631 |
27 Sep 19 |
nicklas |
var painter = {}; |
5631 |
27 Sep 19 |
nicklas |
327 |
|
5631 |
27 Sep 19 |
nicklas |
// Add class indicators for replicates and QC assigned wells |
5631 |
27 Sep 19 |
nicklas |
painter.getClassNameForWell = function(well) |
5631 |
27 Sep 19 |
nicklas |
330 |
{ |
5631 |
27 Sep 19 |
nicklas |
var cls = ''; |
5631 |
27 Sep 19 |
nicklas |
if (well.extract) |
5631 |
27 Sep 19 |
nicklas |
333 |
{ |
5631 |
27 Sep 19 |
nicklas |
cls += ' primary'; |
5633 |
30 Sep 19 |
nicklas |
cls += well.extract.id ? ' existing': ' bg-green'; |
5631 |
27 Sep 19 |
nicklas |
336 |
} |
5631 |
27 Sep 19 |
nicklas |
if (well.column == Plate.columns-1) cls += ' last-child'; |
5631 |
27 Sep 19 |
nicklas |
return cls; |
5631 |
27 Sep 19 |
nicklas |
339 |
} |
5631 |
27 Sep 19 |
nicklas |
340 |
|
5631 |
27 Sep 19 |
nicklas |
painter.getWellText = function(well) |
5631 |
27 Sep 19 |
nicklas |
342 |
{ |
5631 |
27 Sep 19 |
nicklas |
var text = ''; |
5631 |
27 Sep 19 |
nicklas |
if (well.extract) |
5631 |
27 Sep 19 |
nicklas |
345 |
{ |
5631 |
27 Sep 19 |
nicklas |
// The well contains RNA |
5631 |
27 Sep 19 |
nicklas |
var aliquot = well.extract; |
5631 |
27 Sep 19 |
nicklas |
text += '<div class="name">'+Reggie.softLineBreaks(Strings.encodeTags(aliquot.name || aliquot.prefix))+'</div>'; |
5631 |
27 Sep 19 |
nicklas |
349 |
|
5633 |
30 Sep 19 |
nicklas |
if (aliquot.id) |
5632 |
30 Sep 19 |
nicklas |
351 |
{ |
5633 |
30 Sep 19 |
nicklas |
// Nothing |
5632 |
30 Sep 19 |
nicklas |
353 |
} |
5633 |
30 Sep 19 |
nicklas |
else |
5632 |
30 Sep 19 |
nicklas |
355 |
{ |
5633 |
30 Sep 19 |
nicklas |
text += '<div class="volumes"' + (aliquot.NDConcF ? ' title="NDConc: ' + Reggie.formatNumber(aliquot.NDConcF, 'ng/µl', 1, 1) + '"' : '') + '>'; |
5636 |
02 Oct 19 |
nicklas |
text += '<span class="quantity">'+(aliquot.quantityF ? Reggie.formatNumber(aliquot.quantityF*1000, 'ng', 1, 1) : (aliquot.NDConcF ? Reggie.formatNumber(aliquot.NDConcF, 'ng/µl', 1, 1) : '-')) + '</span>'; |
5633 |
30 Sep 19 |
nicklas |
text += '<span class="volume">'+(aliquot.volume ? Reggie.formatNumber(aliquot.volume, 'µl', 1, 1) : '-') + '</span>'; |
5633 |
30 Sep 19 |
nicklas |
text += '</div>'; |
5633 |
30 Sep 19 |
nicklas |
360 |
|
5633 |
30 Sep 19 |
nicklas |
text += '<div class="rnaqc">'; |
5633 |
30 Sep 19 |
nicklas |
if (aliquot.CA_RQS) |
5633 |
30 Sep 19 |
nicklas |
363 |
{ |
5633 |
30 Sep 19 |
nicklas |
text += 'RQS: ' + Strings.encodeTags(aliquot.CA_RQS); |
5633 |
30 Sep 19 |
nicklas |
365 |
} |
5633 |
30 Sep 19 |
nicklas |
else if (aliquot.BA_RIN) |
5633 |
30 Sep 19 |
nicklas |
367 |
{ |
5633 |
30 Sep 19 |
nicklas |
text += 'RIN: ' + Strings.encodeTags(aliquot.BA_RIN); |
5633 |
30 Sep 19 |
nicklas |
369 |
} |
5633 |
30 Sep 19 |
nicklas |
text += '</div>'; |
5632 |
30 Sep 19 |
nicklas |
371 |
} |
5631 |
27 Sep 19 |
nicklas |
if (aliquot.comment) |
5631 |
27 Sep 19 |
nicklas |
373 |
{ |
5631 |
27 Sep 19 |
nicklas |
text += '<div class="comment">'+Strings.encodeTags(aliquot.comment)+'</div>'; |
5631 |
27 Sep 19 |
nicklas |
375 |
} |
5631 |
27 Sep 19 |
nicklas |
376 |
} |
5631 |
27 Sep 19 |
nicklas |
else |
5631 |
27 Sep 19 |
nicklas |
378 |
{ |
5631 |
27 Sep 19 |
nicklas |
text = 'empty'; |
5631 |
27 Sep 19 |
nicklas |
380 |
} |
5631 |
27 Sep 19 |
nicklas |
return text; |
5631 |
27 Sep 19 |
nicklas |
382 |
} |
5631 |
27 Sep 19 |
nicklas |
383 |
|
5631 |
27 Sep 19 |
nicklas |
return painter; |
5631 |
27 Sep 19 |
nicklas |
385 |
}(); |