]> git.evergreen-ils.org Git - Evergreen.git/blob - Open-ILS/xul/staff_client/server/serial/siss_editor.js
merge seials-integration [sic] branch into trunk
[Evergreen.git] / Open-ILS / xul / staff_client / server / serial / siss_editor.js
1 dump('entering serial/siss_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.siss_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/siss_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 serial.siss_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' : 'siss',
31     'fm_type_plural' : 'sisses',
32     'can_have_notes' : true,
33
34     'init' : function (params) {
35         var obj = this;
36         
37         params.retrieve_function = 'FM_SISS_FLESHED_BATCH_RETRIEVE.authoritative';
38
39         obj.editor_base_init(params);
40
41         /* Do it */
42         obj.summarize( obj.sisses );
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         if (field == 'date_published') {
57             if (value == '') { value = null; }
58         }
59         obj.editor_base_apply(field, value);
60     },
61
62     /******************************************************************************************************/
63     /* Initialize the panes */
64
65     'init_panes' : function () {
66         var obj = this;
67         obj.panes_and_field_names = {
68
69     /* These get shown in the left panel */
70             'siss_editor_left_pane' :
71         [
72             [
73                 $('catStrings').getString('staff.cat.copy_editor.field.creation_date.label') + ' ', //adding extra spaces to satisfy summarize uniqueness requirements
74                 {
75                     render: 'fm.create_date() == null ? "<Unset>" : util.date.formatted_date( fm.create_date(), "%F");',
76                 }
77             ],
78             [
79                 $('catStrings').getString('staff.cat.copy_editor.field.creator.label') + ' ',
80                 {
81                     render: 'fm.creator().usrname() == null ? "<Unset>" : fm.creator().usrname();',
82                 }
83             ],
84             [
85                 $('catStrings').getString('staff.cat.copy_editor.field.last_edit_date.label') + ' ',
86                 {
87                     render: 'fm.edit_date() == null ? "<Unset>" : util.date.formatted_date( fm.edit_date(), "%F");',
88                 }
89             ],
90             [
91                 $('catStrings').getString('staff.cat.copy_editor.field.last_editor.label') + ' ',
92                 {
93                     render: 'fm.editor().usrname() == null ? "<Unset>" : fm.editor().usrname();',
94                 }
95             ],
96         ],
97
98         'siss_editor_middle_pane' :
99         [
100 /*rjs7 don't think we need these anymore            [
101                 'Holding Type',
102                 {
103                     render: 'fm.holding_type();',
104                     input: 'c = function(v){ obj.apply("holding_type",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ ["basic", "basic"], ["index", "index"], ["supplement", "supplement"] ] ); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
105                 }
106             ],
107             [
108                 'Holding Link ID',
109                 {
110                     render: 'fm.holding_link_id();',
111                     input: 'c = function(v){ obj.apply("holding_link_id",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.setAttribute("value",obj.editor_values.holding_link_id); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
112                     value_key: 'holding_link_id'
113                 }
114             ],*/
115             [
116                 'Holding Code',
117                 {
118                     render: 'fm.holding_code();',
119                     input: 'c = function(v){ obj.apply("holding_code",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.setAttribute("value",obj.editor_values.holding_code); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
120                     value_key: 'holding_code'
121                 }
122             ],
123             [
124                 'Caption/Pattern', //TODO: make this a drop-down selector, perhaps?
125                 {
126                     render: 'fm.caption_and_pattern();',
127                     input: 'c = function(v){ obj.apply("caption_and_pattern",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.setAttribute("value",obj.editor_values.caption_and_pattern); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
128                     value_key: 'caption_and_pattern'
129                 }
130             ],
131         ],
132
133         'siss_editor_right_pane' :
134         [
135             [
136                 'Date Published',
137                 {
138                     render: 'fm.date_published() == null ? "" : util.date.formatted_date( fm.date_published(), "%F");',
139                     input: 'c = function(v){ obj.apply("date_published",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.setAttribute("value",obj.editor_values.date_published); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
140                     value_key: 'date_published'
141                 }
142             ],
143             [
144                 'Issuance Label',
145                 {
146                     render: 'fm.label() == null ? "" : fm.label();',
147                     input: 'c = function(v){ obj.apply("label",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.setAttribute("value",obj.editor_values.label); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
148                     value_key: 'label'
149                 }
150             ],
151         ],
152
153         };
154     },
155
156     /******************************************************************************************************/
157     /* This loops through all our fieldnames and all the copies, tallying up counts for the different values */
158
159     'summarize' : serial.editor_base.editor_base_summarize,
160
161     /******************************************************************************************************/
162     /* Display the summarized data and inputs for editing */
163
164     'render' : serial.editor_base.editor_base_render,
165
166     /******************************************************************************************************/
167     /* This actually draws the change button and input widget for a given field */
168     'render_input' : serial.editor_base.editor_base_render_input,
169
170     /******************************************************************************************************/
171     /* update the issuances */
172
173     'save' : function() {
174         var obj = this;
175         obj.editor_base_save('open-ils.serial.issuance.fleshed.batch.update');
176     },
177
178     /******************************************************************************************************/
179     /* spawn issuance notes interface */
180
181     'notes' : function() {
182         var obj = this;
183         JSAN.use('util.window'); var win = new util.window();
184         win.open(
185             urls.XUL_SERIAL_NOTES, 
186             'Issuance Notes','chrome,resizable,modal',
187             { 'object_id' : obj.sisses[0].id(), 'function_type' : 'SISSN', 'object_type' : 'issuance', 'constructor' : sissn }
188         );
189     },
190
191     /******************************************************************************************************/
192     'save_attributes' : serial.editor_base.editor_base_save_attributes
193 };
194
195 dump('exiting serial/siss_editor.js\n');