]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/serial/sssum_editor.js
Improve Firefox/XULRunner Support
[working/Evergreen.git] / Open-ILS / xul / staff_client / server / serial / sssum_editor.js
1 dump('entering serial/sssum_editor.js\n');
2 // vim:noet:sw=4:ts=4:
3
4 JSAN.use('serial.editor_base');
5
6 if (typeof serial == 'undefined') serial = {};
7 serial.sssum_editor = function (params) {
8     try {
9         JSAN.use('util.error'); this.error = new util.error();
10         JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
11         JSAN.use('util.network'); this.network = new util.network();
12     } catch(E) {
13         dump('serial/sssum_editor: ' + E + '\n');
14     }
15
16     /* This keeps track of what fields have been edited for styling purposes */
17     this.changed = {};
18
19     /* This holds the original values for prepopulating the field editors */
20     this.editor_values = {};
21
22 };
23
24 serial.sssum_editor.prototype = {
25     // we could do this with non-standard '__proto__' property instead
26     'editor_base_init' : serial.editor_base.editor_base_init,
27     'editor_base_apply' : serial.editor_base.editor_base_apply,
28     'editor_base_save' : serial.editor_base.editor_base_save,
29
30     'fm_type' : 'sssum',
31     'fm_type_plural' : 'sssums',
32
33     'init' : function (params) {
34         var obj = this;
35
36         params.retrieve_function = 'FM_SSSUM_BATCH_RETRIEVE.authoritative';
37
38         obj.editor_base_init(params);
39
40         /* Do it */
41         obj.summarize( obj.sssums );
42         obj.render();
43     },
44
45     /******************************************************************************************************/
46     /* Restore backup copies */
47
48     'reset' :  serial.editor_base.editor_base_reset,
49
50     /******************************************************************************************************/
51     /* Apply a value to a specific field on all the copies being edited */
52
53     'apply' : function(field,value) {
54         var obj = this;
55
56         obj.editor_base_apply(field, value);
57     },
58
59     /******************************************************************************************************/
60
61     'init_panes' : function () {
62         var obj = this;
63         obj.panes_and_field_names = {
64
65         /* These get shown in the left panel */
66         'sssum_editor_left_pane' :
67         [
68             [
69                 'id',
70                 { 
71                     //input: 'c = function(v){ obj.apply("distribution",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
72
73                 }
74             ],
75             [
76                 'textual_holdings',
77                 { 
78                     input: 'c = function(v){ obj.apply("textual_holdings",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.setAttribute("multiline",true); x.setAttribute("cols", 80); x.setAttribute("value",obj.editor_values.textual_holdings); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
79                     value_key: 'textual_holdings'
80                 }
81             ],
82             [
83                 'generated_coverage',
84                 {
85                 }
86             ]
87         ]
88         };
89     },
90
91     /******************************************************************************************************/
92     /* This loops through all our fieldnames and all the copies, tallying up counts for the different values */
93
94     'summarize' :  serial.editor_base.editor_base_summarize,
95
96     /******************************************************************************************************/
97     /* Display the summarized data and inputs for editing */
98
99     'render' :  serial.editor_base.editor_base_render,
100
101     /******************************************************************************************************/
102     /* This actually draws the change button and input widget for a given field */
103     'render_input' : serial.editor_base.editor_base_render_input,
104
105     /******************************************************************************************************/
106     /* save the streams */
107
108     'save' : function() {
109         var obj = this;
110         obj.editor_base_save('open-ils.serial.supplement_summary.batch.update');
111     },
112
113     /******************************************************************************************************/
114     'save_attributes' : serial.editor_base.editor_base_save_attributes
115 };
116
117 dump('exiting serial/sssum_editor.js\n');