5458 |
29 May 19 |
nicklas |
var SelectPlates = function() |
5458 |
29 May 19 |
nicklas |
2 |
{ |
5458 |
29 May 19 |
nicklas |
var select = {}; |
5458 |
29 May 19 |
nicklas |
var plates; |
5459 |
29 May 19 |
nicklas |
var currentPreviewPlateId; |
5458 |
29 May 19 |
nicklas |
6 |
|
5458 |
29 May 19 |
nicklas |
var debug = 0; |
5458 |
29 May 19 |
nicklas |
8 |
|
5458 |
29 May 19 |
nicklas |
// Page initialization |
5458 |
29 May 19 |
nicklas |
select.initPage = function() |
5458 |
29 May 19 |
nicklas |
11 |
{ |
5458 |
29 May 19 |
nicklas |
Buttons.addClickHandler('close', App.closeWindow); |
5458 |
29 May 19 |
nicklas |
Buttons.addClickHandler('btnOk', select.saveSelected); |
5458 |
29 May 19 |
nicklas |
14 |
|
5459 |
29 May 19 |
nicklas |
Events.addEventHandler('plate-list', 'click', select.previewPlate); |
5459 |
29 May 19 |
nicklas |
16 |
|
5458 |
29 May 19 |
nicklas |
var url = '../Mips.servlet?ID='+App.getSessionId(); |
5458 |
29 May 19 |
nicklas |
url += '&cmd=GetAliquotPlatesForMips'; |
5458 |
29 May 19 |
nicklas |
var ignore = Data.get('page-data', 'ignore'); |
5458 |
29 May 19 |
nicklas |
if (ignore) url += '&ignore='+encodeURIComponent(ignore); |
5458 |
29 May 19 |
nicklas |
Wizard.showLoadingAnimation('Loading information about aliquot plates...'); |
5458 |
29 May 19 |
nicklas |
Wizard.asyncJsonRequest(url, select.aliquotPlatesLoaded); |
5458 |
29 May 19 |
nicklas |
23 |
} |
5458 |
29 May 19 |
nicklas |
24 |
|
5458 |
29 May 19 |
nicklas |
select.aliquotPlatesLoaded = function(response) |
5458 |
29 May 19 |
nicklas |
26 |
{ |
5458 |
29 May 19 |
nicklas |
plates = response.plates; |
5458 |
29 May 19 |
nicklas |
if (plates.length == 0) |
5458 |
29 May 19 |
nicklas |
29 |
{ |
5458 |
29 May 19 |
nicklas |
Wizard.setFatalError('Could not find any aliquot plates'); |
5458 |
29 May 19 |
nicklas |
return; |
5458 |
29 May 19 |
nicklas |
32 |
} |
5458 |
29 May 19 |
nicklas |
33 |
|
5458 |
29 May 19 |
nicklas |
var html = ''; |
5458 |
29 May 19 |
nicklas |
for (var plateNo = 0; plateNo < plates.length; plateNo++) |
5458 |
29 May 19 |
nicklas |
36 |
{ |
5458 |
29 May 19 |
nicklas |
var plate = plates[plateNo]; |
5458 |
29 May 19 |
nicklas |
38 |
|
5458 |
29 May 19 |
nicklas |
var notes = []; |
5458 |
29 May 19 |
nicklas |
if (plate.PlateProcessing == 'AddAliquots') notes[notes.length] = 'SCAN-B lab'; |
5458 |
29 May 19 |
nicklas |
if (plate.AutoProcessing == 'ReProcess') notes[notes.length] = 'Re-process'; |
5458 |
29 May 19 |
nicklas |
if (plate.comments) notes[notes.length] = Strings.encodeTags(plate.comments); |
5458 |
29 May 19 |
nicklas |
html += '<tr class="highlight">'; |
5458 |
29 May 19 |
nicklas |
html += '<td class="check"><input type="checkbox" id="check.'+plate.id+'" value="'+plate.id+'"></td>'; |
5459 |
29 May 19 |
nicklas |
html += '<td class="name"><label for="check.'+plate.id+'" data-plate-id="'+plate.id+'">'+Strings.encodeTags(plate.name)+'</label></td>'; |
5460 |
03 Jun 19 |
nicklas |
html += '<td class="image"><img class="link" src="../images/search.png" data-plate-id="'+plate.id+'" title="Preview aliquots on this plate"></td>'; |
5458 |
29 May 19 |
nicklas |
html += '<td class="count">'+plate.usedWells+'</td>'; |
5458 |
29 May 19 |
nicklas |
html += '<td class="count">'+plate.unusedAliquots+'</td>'; |
5458 |
29 May 19 |
nicklas |
html += '<td class="date">'+Reggie.reformatDate(plate.registrationDate)+'</td>'; |
5458 |
29 May 19 |
nicklas |
html += '<td class="notes">'+notes.join('; ')+'</td>'; |
5458 |
29 May 19 |
nicklas |
html += '</tr>'; |
5458 |
29 May 19 |
nicklas |
52 |
} |
5458 |
29 May 19 |
nicklas |
53 |
|
5458 |
29 May 19 |
nicklas |
Doc.element('plate-list').innerHTML = html; |
5458 |
29 May 19 |
nicklas |
Doc.show('aliquot-table', 'table'); |
5458 |
29 May 19 |
nicklas |
56 |
} |
5458 |
29 May 19 |
nicklas |
57 |
|
5459 |
29 May 19 |
nicklas |
select.previewPlate = function(event) |
5459 |
29 May 19 |
nicklas |
59 |
{ |
5459 |
29 May 19 |
nicklas |
var plateId = Data.get(event.target, 'plate-id'); |
5459 |
29 May 19 |
nicklas |
if (!plateId || plateId == currentPreviewPlateId) return; |
5459 |
29 May 19 |
nicklas |
62 |
|
5459 |
29 May 19 |
nicklas |
currentPreviewPlateId = plateId; |
5459 |
29 May 19 |
nicklas |
64 |
|
5459 |
29 May 19 |
nicklas |
var url = '../Mips.servlet?ID='+App.getSessionId(); |
5459 |
29 May 19 |
nicklas |
url += '&cmd=GetUnusedAliquotsFromPlates'; |
5459 |
29 May 19 |
nicklas |
url += '&plates='+plateId; |
5459 |
29 May 19 |
nicklas |
url += '&includeall=1'; |
5459 |
29 May 19 |
nicklas |
Wizard.asyncJsonRequest(url, select.previewLoaded); |
5459 |
29 May 19 |
nicklas |
70 |
} |
5458 |
29 May 19 |
nicklas |
71 |
|
5459 |
29 May 19 |
nicklas |
select.previewLoaded = function(response) |
5459 |
29 May 19 |
nicklas |
73 |
{ |
5459 |
29 May 19 |
nicklas |
var plate = response.plates[0]; |
5459 |
29 May 19 |
nicklas |
var html = '<table class="fullborder">'; |
5459 |
29 May 19 |
nicklas |
html += '<caption>Preview of ' + Strings.encodeTags(plate.name)+'</caption>'; |
5459 |
29 May 19 |
nicklas |
html += '<tr class="bg-filled-100 bottomborder"><th></th>'; |
5459 |
29 May 19 |
nicklas |
for (var c = 0; c < plate.columns; c++) |
5459 |
29 May 19 |
nicklas |
79 |
{ |
5459 |
29 May 19 |
nicklas |
html += '<th>'+(c+1)+'</th>'; |
5459 |
29 May 19 |
nicklas |
81 |
} |
5459 |
29 May 19 |
nicklas |
html += '</tr>'; |
5459 |
29 May 19 |
nicklas |
83 |
|
5459 |
29 May 19 |
nicklas |
for (var r = 0; r < plate.rows; r++) |
5459 |
29 May 19 |
nicklas |
85 |
{ |
5459 |
29 May 19 |
nicklas |
var row = Reggie.wellToAlpha(r); |
5459 |
29 May 19 |
nicklas |
html += '<tr><th class="bg-filled-100 rightborder">'+row+'</th>'; |
5459 |
29 May 19 |
nicklas |
for (var c = 0; c < plate.columns; c++) |
5459 |
29 May 19 |
nicklas |
89 |
{ |
5459 |
29 May 19 |
nicklas |
var id = row+(c+1); |
5459 |
29 May 19 |
nicklas |
html += '<td id="'+id+'"></td>'; |
5459 |
29 May 19 |
nicklas |
92 |
} |
5459 |
29 May 19 |
nicklas |
html += '</tr>'; |
5459 |
29 May 19 |
nicklas |
94 |
} |
5603 |
13 Sep 19 |
nicklas |
var panelCounters = []; |
5460 |
03 Jun 19 |
nicklas |
html += '<tr class="topborder pool-row">'; |
5460 |
03 Jun 19 |
nicklas |
html += '<th class="bg-filled-100 rightborder"></th>'; |
5460 |
03 Jun 19 |
nicklas |
for (var c = 0; c < plate.columns; c++) |
5460 |
03 Jun 19 |
nicklas |
99 |
{ |
5520 |
20 Jun 19 |
nicklas |
html += '<th><div id="c.'+c+'"></div></th>'; |
5603 |
13 Sep 19 |
nicklas |
panelCounters[c] = new ItemCounter(); |
5460 |
03 Jun 19 |
nicklas |
102 |
} |
5460 |
03 Jun 19 |
nicklas |
html += '</tr>'; |
5459 |
29 May 19 |
nicklas |
html += '</table>'; |
5460 |
03 Jun 19 |
nicklas |
105 |
|
5459 |
29 May 19 |
nicklas |
Doc.element('plate-preview').innerHTML = html; |
5459 |
29 May 19 |
nicklas |
107 |
|
5459 |
29 May 19 |
nicklas |
for (var a = 0; a < plate.aliquots.length; a++) |
5459 |
29 May 19 |
nicklas |
109 |
{ |
5459 |
29 May 19 |
nicklas |
var aliquot = plate.aliquots[a]; |
5459 |
29 May 19 |
nicklas |
var td = Doc.element(aliquot.bioWell.location); |
5603 |
13 Sep 19 |
nicklas |
var cls = 'aliquot ' + MipsColor.getColor(aliquot.MIPS_Panel); |
5459 |
29 May 19 |
nicklas |
if (aliquot.numChildren > 0) cls += ' used'; |
5459 |
29 May 19 |
nicklas |
td.className = cls; |
5603 |
13 Sep 19 |
nicklas |
td.title = aliquot.MIPS_Panel; |
5603 |
13 Sep 19 |
nicklas |
panelCounters[aliquot.bioWell.column].count(aliquot.MIPS_Panel); |
5459 |
29 May 19 |
nicklas |
117 |
} |
5460 |
03 Jun 19 |
nicklas |
for (var c = 0; c < plate.columns; c++) |
5460 |
03 Jun 19 |
nicklas |
119 |
{ |
5603 |
13 Sep 19 |
nicklas |
counter = panelCounters[c]; |
5603 |
13 Sep 19 |
nicklas |
var mipsPanel = Strings.encodeTags(counter.maxKey); |
5603 |
13 Sep 19 |
nicklas |
if (mipsPanel) |
5520 |
20 Jun 19 |
nicklas |
123 |
{ |
5603 |
13 Sep 19 |
nicklas |
var numPanels = counter.numKeys(); |
5520 |
20 Jun 19 |
nicklas |
var div = Doc.element('c.'+c); |
5603 |
13 Sep 19 |
nicklas |
div.innerHTML = mipsPanel + (numPanels > 1 ? '+' : ''); |
5603 |
13 Sep 19 |
nicklas |
div.title = mipsPanel + (numPanels > 1 ? ' and ' + (numPanels- 1) + ' more' : ''); |
5603 |
13 Sep 19 |
nicklas |
Doc.addClass(div.parentNode, MipsColor.getColor(mipsPanel)); |
5520 |
20 Jun 19 |
nicklas |
129 |
} |
5460 |
03 Jun 19 |
nicklas |
130 |
} |
5459 |
29 May 19 |
nicklas |
131 |
} |
5459 |
29 May 19 |
nicklas |
132 |
|
5458 |
29 May 19 |
nicklas |
select.saveSelected = function() |
5458 |
29 May 19 |
nicklas |
134 |
{ |
5458 |
29 May 19 |
nicklas |
var frm = document.forms['reggie']; |
5458 |
29 May 19 |
nicklas |
136 |
|
5458 |
29 May 19 |
nicklas |
var selected = []; |
5458 |
29 May 19 |
nicklas |
for (var plateNo = 0; plateNo < plates.length; plateNo++) |
5458 |
29 May 19 |
nicklas |
139 |
{ |
5458 |
29 May 19 |
nicklas |
var plate = plates[plateNo]; |
5458 |
29 May 19 |
nicklas |
if (frm['check.'+plate.id].checked) |
5458 |
29 May 19 |
nicklas |
142 |
{ |
5458 |
29 May 19 |
nicklas |
selected[selected.length] = {'id': plate.id, 'name': plate.name }; |
5458 |
29 May 19 |
nicklas |
144 |
}; |
5458 |
29 May 19 |
nicklas |
145 |
} |
5458 |
29 May 19 |
nicklas |
if (selected.length > 0) |
5458 |
29 May 19 |
nicklas |
147 |
{ |
5458 |
29 May 19 |
nicklas |
var notifyTarget = window.opener.Doc.element('plates'); |
5458 |
29 May 19 |
nicklas |
var remaining = selected.length-1; |
5458 |
29 May 19 |
nicklas |
for (var i = 0; i < selected.length; i++) |
5458 |
29 May 19 |
nicklas |
151 |
{ |
5458 |
29 May 19 |
nicklas |
var s = selected[i]; |
5458 |
29 May 19 |
nicklas |
s.remaining = remaining--; |
5458 |
29 May 19 |
nicklas |
Events.sendCustomEvent(notifyTarget, 'base-selected', s); |
5458 |
29 May 19 |
nicklas |
155 |
} |
5458 |
29 May 19 |
nicklas |
156 |
} |
5458 |
29 May 19 |
nicklas |
App.closeWindow(); |
5458 |
29 May 19 |
nicklas |
158 |
} |
5458 |
29 May 19 |
nicklas |
159 |
|
5458 |
29 May 19 |
nicklas |
return select; |
5458 |
29 May 19 |
nicklas |
161 |
}(); |
5458 |
29 May 19 |
nicklas |
162 |
|
5458 |
29 May 19 |
nicklas |
Doc.onLoad(SelectPlates.initPage); |
5458 |
29 May 19 |
nicklas |
164 |
|