2669 |
15 Sep 14 |
nicklas |
var LibQC = function() |
2669 |
15 Sep 14 |
nicklas |
2 |
{ |
2669 |
15 Sep 14 |
nicklas |
var libqc = {}; |
2702 |
26 Sep 14 |
nicklas |
var debug = 0; |
2669 |
15 Sep 14 |
nicklas |
5 |
|
2669 |
15 Sep 14 |
nicklas |
var bioplateIsValid = false; |
2669 |
15 Sep 14 |
nicklas |
var qcCommentsIsValid = false; |
2669 |
15 Sep 14 |
nicklas |
8 |
|
2669 |
15 Sep 14 |
nicklas |
// Page initialization |
2669 |
15 Sep 14 |
nicklas |
libqc.initPage = function() |
2669 |
15 Sep 14 |
nicklas |
11 |
{ |
2669 |
15 Sep 14 |
nicklas |
// Step 1 |
2669 |
15 Sep 14 |
nicklas |
Events.addEventHandler('bioplate', 'change', libqc.bioplateOnChange); |
2669 |
15 Sep 14 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', libqc.validateStep1); |
2669 |
15 Sep 14 |
nicklas |
Buttons.addClickHandler('btnSelectLibPlate', libqc.selectLibPlate); |
2669 |
15 Sep 14 |
nicklas |
Events.addEventHandler('bioplate', 'base-selected', libqc.libPlateSelected); |
2669 |
15 Sep 14 |
nicklas |
17 |
|
2669 |
15 Sep 14 |
nicklas |
// Step 2 |
2669 |
15 Sep 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-initialize', libqc.initializeStep2); |
2669 |
15 Sep 14 |
nicklas |
Events.addEventHandler('step-2', 'wizard-validate', libqc.validateStep2); |
2669 |
15 Sep 14 |
nicklas |
Events.addEventHandler('qcDate', 'blur', Wizard.validateDate); |
2669 |
15 Sep 14 |
nicklas |
Events.addEventHandler('qccomments', 'blur',libqc.commentsOnChange); |
2669 |
15 Sep 14 |
nicklas |
Wizard.initFileSelectionField('pdfqc'); |
2669 |
15 Sep 14 |
nicklas |
24 |
|
2669 |
15 Sep 14 |
nicklas |
// Navigation |
2669 |
15 Sep 14 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
2669 |
15 Sep 14 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
2669 |
15 Sep 14 |
nicklas |
Buttons.addClickHandler('gonext', Wizard.goNextOnClick); |
2669 |
15 Sep 14 |
nicklas |
Buttons.addClickHandler('goregister', Wizard.goRegister); |
2669 |
15 Sep 14 |
nicklas |
30 |
|
2669 |
15 Sep 14 |
nicklas |
// Final registration |
2669 |
15 Sep 14 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', libqc.submit); |
2669 |
15 Sep 14 |
nicklas |
33 |
|
2669 |
15 Sep 14 |
nicklas |
var url = '../LibPrep.servlet?ID='+App.getSessionId(); |
2669 |
15 Sep 14 |
nicklas |
url += '&cmd=GetLibraryPlatesForLibPrep'; |
2669 |
15 Sep 14 |
nicklas |
Wizard.showLoadingAnimation('Loading Library plates...'); |
2669 |
15 Sep 14 |
nicklas |
Wizard.asyncJsonRequest(url, libqc.initializeStep1); |
2669 |
15 Sep 14 |
nicklas |
38 |
} |
2669 |
15 Sep 14 |
nicklas |
39 |
|
2669 |
15 Sep 14 |
nicklas |
40 |
|
2669 |
15 Sep 14 |
nicklas |
libqc.initializeStep1 = function(response) |
2669 |
15 Sep 14 |
nicklas |
42 |
{ |
2669 |
15 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2669 |
15 Sep 14 |
nicklas |
var bioplates = response.bioplates; |
2669 |
15 Sep 14 |
nicklas |
45 |
|
2669 |
15 Sep 14 |
nicklas |
var plates = frm.bioplate; |
2669 |
15 Sep 14 |
nicklas |
if (bioplates.length > 0) |
2669 |
15 Sep 14 |
nicklas |
48 |
{ |
2669 |
15 Sep 14 |
nicklas |
for (var i=0; i < bioplates.length; i++) |
2669 |
15 Sep 14 |
nicklas |
50 |
{ |
2669 |
15 Sep 14 |
nicklas |
var bioplate = bioplates[i]; |
2669 |
15 Sep 14 |
nicklas |
var option = new Option(bioplate.name, bioplate.id); |
2669 |
15 Sep 14 |
nicklas |
option.plate = bioplate; |
2669 |
15 Sep 14 |
nicklas |
plates.options[plates.length] = option; |
2669 |
15 Sep 14 |
nicklas |
55 |
} |
2669 |
15 Sep 14 |
nicklas |
56 |
} |
2669 |
15 Sep 14 |
nicklas |
57 |
|
2669 |
15 Sep 14 |
nicklas |
frm.bioplate.focus(); |
2669 |
15 Sep 14 |
nicklas |
libqc.bioPlateOnChange(); |
2669 |
15 Sep 14 |
nicklas |
60 |
|
2669 |
15 Sep 14 |
nicklas |
Doc.show('step-1'); |
2669 |
15 Sep 14 |
nicklas |
Doc.show('gonext'); |
2669 |
15 Sep 14 |
nicklas |
63 |
} |
2669 |
15 Sep 14 |
nicklas |
64 |
|
2669 |
15 Sep 14 |
nicklas |
libqc.bioPlateOnChange = function() |
2669 |
15 Sep 14 |
nicklas |
66 |
{ |
2669 |
15 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2669 |
15 Sep 14 |
nicklas |
bioplateIsValid = false; |
2669 |
15 Sep 14 |
nicklas |
69 |
|
2669 |
15 Sep 14 |
nicklas |
if (frm.bioplate.length == 0) |
2669 |
15 Sep 14 |
nicklas |
71 |
{ |
2669 |
15 Sep 14 |
nicklas |
Wizard.setInputStatus('bioplate', 'invalid', 'No Library plate available for processing.'); |
2669 |
15 Sep 14 |
nicklas |
return; |
2669 |
15 Sep 14 |
nicklas |
74 |
} |
2669 |
15 Sep 14 |
nicklas |
75 |
|
2669 |
15 Sep 14 |
nicklas |
bioplateIsValid = true; |
2669 |
15 Sep 14 |
nicklas |
Wizard.setInputStatus('bioplate', 'valid'); |
2669 |
15 Sep 14 |
nicklas |
78 |
} |
2669 |
15 Sep 14 |
nicklas |
79 |
|
2669 |
15 Sep 14 |
nicklas |
libqc.selectLibPlate = function() |
2669 |
15 Sep 14 |
nicklas |
81 |
{ |
2669 |
15 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2669 |
15 Sep 14 |
nicklas |
if (frm.bioplate.disabled) return; |
2669 |
15 Sep 14 |
nicklas |
84 |
|
2669 |
15 Sep 14 |
nicklas |
var url = '&resetTemporary=1'; |
2669 |
15 Sep 14 |
nicklas |
url += '&tmpfilter:STRING:bioPlateType.name=Library+plate'; |
2669 |
15 Sep 14 |
nicklas |
Dialogs.selectItem('BIOPLATE', 'bioplate', 0, url); |
2669 |
15 Sep 14 |
nicklas |
88 |
} |
2669 |
15 Sep 14 |
nicklas |
89 |
|
2669 |
15 Sep 14 |
nicklas |
90 |
|
2669 |
15 Sep 14 |
nicklas |
libqc.libPlateSelected = function(event) |
2669 |
15 Sep 14 |
nicklas |
92 |
{ |
2669 |
15 Sep 14 |
nicklas |
var id = event.detail.id; |
2669 |
15 Sep 14 |
nicklas |
var name = event.detail.name; |
2669 |
15 Sep 14 |
nicklas |
95 |
|
2669 |
15 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2669 |
15 Sep 14 |
nicklas |
var plateList = frm.bioplate; |
2669 |
15 Sep 14 |
nicklas |
for (var i = 0; i < plateList.length; i++) |
2669 |
15 Sep 14 |
nicklas |
99 |
{ |
2669 |
15 Sep 14 |
nicklas |
if (plateList[i].value == id) |
2669 |
15 Sep 14 |
nicklas |
101 |
{ |
2669 |
15 Sep 14 |
nicklas |
plateList[i].selected = true; |
2808 |
15 Oct 14 |
nicklas |
libqc.bioPlateOnChange(); |
2669 |
15 Sep 14 |
nicklas |
return; |
2669 |
15 Sep 14 |
nicklas |
105 |
} |
2669 |
15 Sep 14 |
nicklas |
106 |
} |
2669 |
15 Sep 14 |
nicklas |
107 |
|
2669 |
15 Sep 14 |
nicklas |
var option = new Option(name, id, true, true); |
2669 |
15 Sep 14 |
nicklas |
plateList[plateList.length] = option; |
2669 |
15 Sep 14 |
nicklas |
libqc.bioPlateOnChange(); |
2669 |
15 Sep 14 |
nicklas |
111 |
} |
2669 |
15 Sep 14 |
nicklas |
112 |
|
2669 |
15 Sep 14 |
nicklas |
113 |
|
2669 |
15 Sep 14 |
nicklas |
libqc.validateStep1 = function(event) |
2669 |
15 Sep 14 |
nicklas |
115 |
{ |
2669 |
15 Sep 14 |
nicklas |
if (!bioplateIsValid) event.preventDefault(); |
2669 |
15 Sep 14 |
nicklas |
117 |
} |
2669 |
15 Sep 14 |
nicklas |
118 |
|
2669 |
15 Sep 14 |
nicklas |
libqc.initializeStep2 = function() |
2669 |
15 Sep 14 |
nicklas |
120 |
{ |
2669 |
15 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2669 |
15 Sep 14 |
nicklas |
Wizard.setCurrentStep(2); |
2669 |
15 Sep 14 |
nicklas |
Doc.show('goregister'); |
2669 |
15 Sep 14 |
nicklas |
Doc.show('gocancel'); |
2669 |
15 Sep 14 |
nicklas |
Events.sendChangeEvent('pdfqc'); |
2669 |
15 Sep 14 |
nicklas |
libqc.commentsOnChange(); |
2669 |
15 Sep 14 |
nicklas |
frm.qcDate.focus(); |
2669 |
15 Sep 14 |
nicklas |
128 |
} |
2669 |
15 Sep 14 |
nicklas |
129 |
|
2669 |
15 Sep 14 |
nicklas |
libqc.commentsOnChange = function() |
2669 |
15 Sep 14 |
nicklas |
131 |
{ |
2669 |
15 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2669 |
15 Sep 14 |
nicklas |
qcCommentsIsValid = false; |
2669 |
15 Sep 14 |
nicklas |
Wizard.setInputStatus('qccomments'); |
2669 |
15 Sep 14 |
nicklas |
135 |
|
2669 |
15 Sep 14 |
nicklas |
var comments = frm.qccomments.value; |
2669 |
15 Sep 14 |
nicklas |
if (comments == '') |
2669 |
15 Sep 14 |
nicklas |
138 |
{ |
2669 |
15 Sep 14 |
nicklas |
Wizard.setInputStatus('qccomments', 'invalid', 'Missing'); |
2669 |
15 Sep 14 |
nicklas |
return; |
2669 |
15 Sep 14 |
nicklas |
141 |
} |
2669 |
15 Sep 14 |
nicklas |
142 |
|
2669 |
15 Sep 14 |
nicklas |
Wizard.setInputStatus('qccomments', 'valid'); |
2669 |
15 Sep 14 |
nicklas |
qcCommentsIsValid = true; |
2669 |
15 Sep 14 |
nicklas |
145 |
} |
2669 |
15 Sep 14 |
nicklas |
146 |
|
2669 |
15 Sep 14 |
nicklas |
libqc.validateStep2 = function(event) |
2669 |
15 Sep 14 |
nicklas |
148 |
{ |
2669 |
15 Sep 14 |
nicklas |
var valid = qcCommentsIsValid; |
2669 |
15 Sep 14 |
nicklas |
valid &= Wizard.isValid('pdfqc'); |
2669 |
15 Sep 14 |
nicklas |
valid &= Wizard.isValid('qcDate'); |
2669 |
15 Sep 14 |
nicklas |
152 |
|
2669 |
15 Sep 14 |
nicklas |
if (!valid) |
2669 |
15 Sep 14 |
nicklas |
154 |
{ |
2669 |
15 Sep 14 |
nicklas |
event.preventDefault(); |
2669 |
15 Sep 14 |
nicklas |
156 |
} |
2669 |
15 Sep 14 |
nicklas |
157 |
} |
2669 |
15 Sep 14 |
nicklas |
158 |
|
2669 |
15 Sep 14 |
nicklas |
libqc.submit = function() |
2669 |
15 Sep 14 |
nicklas |
160 |
{ |
2669 |
15 Sep 14 |
nicklas |
var frm = document.forms['reggie']; |
2669 |
15 Sep 14 |
nicklas |
162 |
|
2669 |
15 Sep 14 |
nicklas |
var submitInfo = {}; |
2669 |
15 Sep 14 |
nicklas |
submitInfo.bioplate = parseInt(frm.bioplate.value, 10); |
2669 |
15 Sep 14 |
nicklas |
submitInfo.qcDate = frm.qcDate.value; |
2669 |
15 Sep 14 |
nicklas |
submitInfo.qcPdf = frm.pdfqc.value; |
2669 |
15 Sep 14 |
nicklas |
submitInfo.qcComments = frm.qccomments.value; |
2669 |
15 Sep 14 |
nicklas |
168 |
|
2669 |
15 Sep 14 |
nicklas |
var url = '../LibPrep.servlet?ID='+App.getSessionId(); |
2669 |
15 Sep 14 |
nicklas |
url += '&cmd=ImportLibPrepQcResults'; |
2669 |
15 Sep 14 |
nicklas |
Wizard.showLoadingAnimation('Performing registration...'); |
2669 |
15 Sep 14 |
nicklas |
Wizard.asyncJsonRequest(url, libqc.submissionResults, 'POST', JSON.stringify(submitInfo)); |
2669 |
15 Sep 14 |
nicklas |
173 |
} |
2669 |
15 Sep 14 |
nicklas |
174 |
|
2669 |
15 Sep 14 |
nicklas |
libqc.submissionResults = function(response) |
2669 |
15 Sep 14 |
nicklas |
176 |
{ |
2669 |
15 Sep 14 |
nicklas |
Wizard.showFinalMessage(response.messages); |
2669 |
15 Sep 14 |
nicklas |
Doc.show('gorestart'); |
2669 |
15 Sep 14 |
nicklas |
179 |
} |
2669 |
15 Sep 14 |
nicklas |
180 |
|
2669 |
15 Sep 14 |
nicklas |
return libqc; |
2669 |
15 Sep 14 |
nicklas |
182 |
}(); |
2669 |
15 Sep 14 |
nicklas |
183 |
|
2669 |
15 Sep 14 |
nicklas |
Doc.onLoad(LibQC.initPage); |
2669 |
15 Sep 14 |
nicklas |
185 |
|