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