|
1 |
| -/** |
2 |
| - * Controller class for Bika LIMS Reports |
| 1 | + |
| 2 | +/* Please use this command to compile this file into the parent `js` directory: |
| 3 | + coffee --no-header -w -o ../ -c bika.lims.reports.coffee |
3 | 4 | */
|
4 |
| -function ReportFolderView() { |
5 |
| - |
6 |
| - var that = this; |
7 |
| - |
8 |
| - /** |
9 |
| - * Entry-point method for AnalysisServiceEditView |
10 |
| - */ |
11 |
| - that.load = function() { |
12 |
| - |
13 |
| - $("a[id$='_selector']").click(function(event){ |
14 |
| - $(".criteria").toggle(false); |
15 |
| - event.preventDefault(); |
16 |
| - var div_id = $(this).attr("id").split("_selector")[0]; |
17 |
| - $("[id='"+div_id+"']").toggle(true); |
18 |
| - }); |
19 |
| - |
20 |
| - // AJAX: Set ReferenceSamples dropdown when Supplier is selected |
21 |
| - $("#SupplierUID").change(function(){ |
22 |
| - var val = $(this).val(); |
23 |
| - $.getJSON("referenceanalysisqc_samples", |
24 |
| - {"SupplierUID":val, |
25 |
| - "_authenticator": $("input[name='_authenticator']").val()}, |
26 |
| - function(data){ |
27 |
| - $("#SampleUID").empty().append("<option value=''></option>"); |
28 |
| - if(data){ |
29 |
| - for(var i=0;i<data.length;i++){ |
30 |
| - var sample = data[i]; |
31 |
| - $("#SampleUID").append("<option value='"+sample[0]+"'>"+sample[1]+"</option>"); |
32 |
| - } |
33 |
| - } |
34 |
| - } |
35 |
| - ); |
36 |
| - }); |
37 |
| - |
38 |
| - // AJAX: Set ReferenceServices dropdown when ReferenceSample is selected |
39 |
| - $("#SampleUID").change(function(){ |
40 |
| - var val = $(this).val(); |
41 |
| - $.getJSON("referenceanalysisqc_services", |
42 |
| - {"SampleUID":val, |
43 |
| - "_authenticator": $("input[name='_authenticator']").val()}, |
44 |
| - function(data){ |
45 |
| - $("#ReferenceServiceUID").empty().append("<option value=''></option>"); |
46 |
| - if(data){ |
47 |
| - for(var i=0;i<data.length;i++){ |
48 |
| - var service = data[i]; |
49 |
| - $("#ReferenceServiceUID").append("<option value='"+service[0]+"'>"+service[1]+"</option>"); |
50 |
| - } |
51 |
| - } |
52 |
| - } |
53 |
| - ); |
54 |
| - }); |
55 |
| - |
56 |
| - // Reference QC: reset the dropdowns on page reload |
57 |
| - $("#SupplierUID").val(""); |
58 | 5 |
|
| 6 | +(function() { |
| 7 | + var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }; |
| 8 | + |
| 9 | + window.ReportFolderView = (function() { |
| 10 | + function ReportFolderView() { |
| 11 | + this.on_toggle_change = bind(this.on_toggle_change, this); |
| 12 | + this.bind_eventhandler = bind(this.bind_eventhandler, this); |
| 13 | + this.load = bind(this.load, this); |
59 | 14 | }
|
60 |
| -} |
| 15 | + |
| 16 | + ReportFolderView.prototype.load = function() { |
| 17 | + console.debug("ReportFolderView::load"); |
| 18 | + return this.bind_eventhandler(); |
| 19 | + }; |
| 20 | + |
| 21 | + |
| 22 | + /* INITIALIZERS */ |
| 23 | + |
| 24 | + ReportFolderView.prototype.bind_eventhandler = function() { |
| 25 | + |
| 26 | + /* |
| 27 | + * Binds callbacks on elements |
| 28 | + */ |
| 29 | + console.debug("ReportFolderView::bind_eventhandler"); |
| 30 | + return $("body").on("click", "a[id$='_selector']", this.on_toggle_change); |
| 31 | + }; |
| 32 | + |
| 33 | + ReportFolderView.prototype.on_toggle_change = function(event) { |
| 34 | + |
| 35 | + /** |
| 36 | + * Event handler when the toggle anchor is clicked |
| 37 | + */ |
| 38 | + var div_id; |
| 39 | + console.debug("°°° ReportFolderView::on_toggle_change °°°"); |
| 40 | + event.preventDefault(); |
| 41 | + $(".criteria").toggle(false); |
| 42 | + div_id = event.currentTarget.id.split("_selector")[0]; |
| 43 | + return $("[id='" + div_id + "']").toggle(true); |
| 44 | + }; |
| 45 | + |
| 46 | + return ReportFolderView; |
| 47 | + |
| 48 | + })(); |
| 49 | + |
| 50 | +}).call(this); |
0 commit comments