3488 |
16 Sep 15 |
nicklas |
var FrozenTissueDate = function() |
3488 |
16 Sep 15 |
nicklas |
2 |
{ |
3488 |
16 Sep 15 |
nicklas |
var ftd = {}; |
3488 |
16 Sep 15 |
nicklas |
var debug = 0; |
3488 |
16 Sep 15 |
nicklas |
5 |
|
4806 |
14 May 18 |
nicklas |
var warnings; |
3488 |
16 Sep 15 |
nicklas |
7 |
|
3488 |
16 Sep 15 |
nicklas |
ftd.initPage = function() |
3488 |
16 Sep 15 |
nicklas |
9 |
{ |
3488 |
16 Sep 15 |
nicklas |
// Step 1 |
3488 |
16 Sep 15 |
nicklas |
Events.addEventHandler('step-1', 'wizard-validate', ftd.validateStep1); |
3488 |
16 Sep 15 |
nicklas |
Wizard.initFileSelectionField('importfile'); |
3488 |
16 Sep 15 |
nicklas |
13 |
|
3488 |
16 Sep 15 |
nicklas |
// Navigation |
3488 |
16 Sep 15 |
nicklas |
Buttons.addClickHandler('gocancel', Wizard.cancelWizard); |
3488 |
16 Sep 15 |
nicklas |
Buttons.addClickHandler('gorestart', Wizard.restartWizard); |
3488 |
16 Sep 15 |
nicklas |
Buttons.addClickHandler('goimport', Wizard.goRegister); |
4806 |
14 May 18 |
nicklas |
Buttons.addClickHandler('showAllWarnings', ftd.showAllWarnings); |
4806 |
14 May 18 |
nicklas |
19 |
|
3488 |
16 Sep 15 |
nicklas |
// Final registration |
3488 |
16 Sep 15 |
nicklas |
Events.addEventHandler('wizard', 'wizard-submit', ftd.submit); |
3488 |
16 Sep 15 |
nicklas |
22 |
|
3488 |
16 Sep 15 |
nicklas |
Doc.show('step-1'); |
3488 |
16 Sep 15 |
nicklas |
Doc.show('goimport'); |
3488 |
16 Sep 15 |
nicklas |
25 |
} |
3488 |
16 Sep 15 |
nicklas |
26 |
|
3488 |
16 Sep 15 |
nicklas |
ftd.validateStep1 = function(event) |
3488 |
16 Sep 15 |
nicklas |
28 |
{ |
3488 |
16 Sep 15 |
nicklas |
var valid = true; |
3488 |
16 Sep 15 |
nicklas |
valid &= Wizard.isValid('importfile'); |
3488 |
16 Sep 15 |
nicklas |
if (!valid) event.preventDefault(); |
3488 |
16 Sep 15 |
nicklas |
32 |
} |
3488 |
16 Sep 15 |
nicklas |
33 |
|
3488 |
16 Sep 15 |
nicklas |
ftd.submit = function() |
3488 |
16 Sep 15 |
nicklas |
35 |
{ |
3488 |
16 Sep 15 |
nicklas |
var frm = document.forms['reggie']; |
3488 |
16 Sep 15 |
nicklas |
37 |
|
3488 |
16 Sep 15 |
nicklas |
var url = '../Import.servlet?ID='+App.getSessionId(); |
3488 |
16 Sep 15 |
nicklas |
url += '&cmd=ImportFrozenTissueDate'; |
3488 |
16 Sep 15 |
nicklas |
url += '&file='+encodeURIComponent(frm.importfile.value); |
3916 |
02 May 16 |
nicklas |
url += '&progressbar=import-frozen-tissue-progress'; |
3488 |
16 Sep 15 |
nicklas |
42 |
|
3916 |
02 May 16 |
nicklas |
Wizard.showLoadingAnimation('Importing FrozenTissueDate...', 'import-frozen-tissue-progress'); |
3488 |
16 Sep 15 |
nicklas |
Wizard.asyncJsonRequest(url, ftd.submissionResults, 'POST'); |
3488 |
16 Sep 15 |
nicklas |
45 |
} |
3488 |
16 Sep 15 |
nicklas |
46 |
|
3488 |
16 Sep 15 |
nicklas |
ftd.submissionResults = function(response) |
3488 |
16 Sep 15 |
nicklas |
48 |
{ |
3488 |
16 Sep 15 |
nicklas |
Wizard.showFinalMessage(response.messages); |
4806 |
14 May 18 |
nicklas |
50 |
|
4806 |
14 May 18 |
nicklas |
warnings = response.warnings; |
4806 |
14 May 18 |
nicklas |
52 |
|
4806 |
14 May 18 |
nicklas |
var oldWarnings = 0; |
4806 |
14 May 18 |
nicklas |
if (warnings && warnings.length) |
3488 |
16 Sep 15 |
nicklas |
55 |
{ |
4806 |
14 May 18 |
nicklas |
oldWarnings = ftd.createWarningsTable(warnings); |
4806 |
14 May 18 |
nicklas |
if (oldWarnings > 0) |
4512 |
31 May 17 |
nicklas |
58 |
{ |
4806 |
14 May 18 |
nicklas |
Doc.show('showAllWarnings'); |
4512 |
31 May 17 |
nicklas |
60 |
} |
4806 |
14 May 18 |
nicklas |
61 |
} |
4806 |
14 May 18 |
nicklas |
62 |
|
4806 |
14 May 18 |
nicklas |
Doc.show('gorestart'); |
4806 |
14 May 18 |
nicklas |
64 |
} |
4806 |
14 May 18 |
nicklas |
65 |
|
4806 |
14 May 18 |
nicklas |
ftd.createWarningsTable = function(warnings) |
4806 |
14 May 18 |
nicklas |
67 |
{ |
4806 |
14 May 18 |
nicklas |
var html = ''; |
4806 |
14 May 18 |
nicklas |
var numOldWarnings = 0; |
4806 |
14 May 18 |
nicklas |
for (var warningNo = 0; warningNo < warnings.length; warningNo++) |
4806 |
14 May 18 |
nicklas |
71 |
{ |
4806 |
14 May 18 |
nicklas |
var warning = warnings[warningNo]; |
4806 |
14 May 18 |
nicklas |
if (!warning.isNew) numOldWarnings++; |
4806 |
14 May 18 |
nicklas |
html += '<tr class="highlight '+(warning.isNew ? 'newwarning' : 'oldwarning')+'">'; |
4806 |
14 May 18 |
nicklas |
html += '<td>'+warning.line+'</td>'; |
4806 |
14 May 18 |
nicklas |
html += '<td>'+Strings.encodeTags(warning.reason)+'</td>'; |
4806 |
14 May 18 |
nicklas |
html += '<td>'+Strings.encodeTags(warning.provId); |
4806 |
14 May 18 |
nicklas |
if (warning.caseName) |
4512 |
31 May 17 |
nicklas |
79 |
{ |
4806 |
14 May 18 |
nicklas |
html += '<img class="link case-summary" data-name="'+Strings.encodeTags(warning.caseName)+'" src="../images/case_summary.png">'; |
4512 |
31 May 17 |
nicklas |
81 |
} |
4806 |
14 May 18 |
nicklas |
html += '</td>'; |
4806 |
14 May 18 |
nicklas |
html += '<td>'+Strings.encodeTags(warning.comment)+'</td>'; |
4806 |
14 May 18 |
nicklas |
html += '</tr>'; |
4806 |
14 May 18 |
nicklas |
85 |
} |
4806 |
14 May 18 |
nicklas |
Doc.element('import-warnings').innerHTML = html; |
4806 |
14 May 18 |
nicklas |
87 |
|
4806 |
14 May 18 |
nicklas |
var cs = document.getElementsByClassName('case-summary'); |
4806 |
14 May 18 |
nicklas |
for (var i = 0; i < cs.length; i++) |
4806 |
14 May 18 |
nicklas |
90 |
{ |
5019 |
10 Oct 18 |
nicklas |
Events.addEventHandler(cs[i], 'click', Reggie.openCaseSummaryPopupOnEvent); |
4806 |
14 May 18 |
nicklas |
92 |
} |
4806 |
14 May 18 |
nicklas |
93 |
|
4806 |
14 May 18 |
nicklas |
if (numOldWarnings < warnings.length) |
4806 |
14 May 18 |
nicklas |
95 |
{ |
4806 |
14 May 18 |
nicklas |
// There is at least one new warning |
4512 |
31 May 17 |
nicklas |
Doc.show('warnings-section'); |
3488 |
16 Sep 15 |
nicklas |
98 |
} |
4806 |
14 May 18 |
nicklas |
99 |
|
4806 |
14 May 18 |
nicklas |
return numOldWarnings; |
3488 |
16 Sep 15 |
nicklas |
101 |
} |
4806 |
14 May 18 |
nicklas |
102 |
|
4806 |
14 May 18 |
nicklas |
ftd.showAllWarnings = function() |
4806 |
14 May 18 |
nicklas |
104 |
{ |
4806 |
14 May 18 |
nicklas |
Doc.hide('showAllWarnings'); |
4806 |
14 May 18 |
nicklas |
Doc.show('warnings-section'); |
4806 |
14 May 18 |
nicklas |
Doc.removeClass('warnings-section', 'hide-old-warnings'); |
4806 |
14 May 18 |
nicklas |
108 |
} |
4806 |
14 May 18 |
nicklas |
109 |
|
3488 |
16 Sep 15 |
nicklas |
return ftd; |
3488 |
16 Sep 15 |
nicklas |
111 |
}(); |
3488 |
16 Sep 15 |
nicklas |
112 |
|
3488 |
16 Sep 15 |
nicklas |
Doc.onLoad(FrozenTissueDate.initPage); |
3488 |
16 Sep 15 |
nicklas |
114 |
|