1 dump('entering serial/siss_editor.js\n');
4 JSAN.use('serial.editor_base');
6 if (typeof serial == 'undefined') serial = {};
7 serial.siss_editor = function (params) {
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();
14 dump('serial/siss_editor: ' + E + '\n');
17 /* This keeps track of what fields have been edited for styling purposes */
20 /* This holds the original values for prepopulating the field editors */
21 this.editor_values = {};
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,
31 'fm_type_plural' : 'sisses',
32 'can_have_notes' : true,
34 'init' : function (params) {
37 params.retrieve_function = 'FM_SISS_FLESHED_BATCH_RETRIEVE.authoritative';
39 obj.editor_base_init(params);
42 obj.summarize( obj.sisses );
46 /******************************************************************************************************/
47 /* Restore backup copies */
49 'reset' : serial.editor_base.editor_base_reset,
51 /******************************************************************************************************/
52 /* Apply a value to a specific field on all the copies being edited */
54 'apply' : function(field,value) {
56 if (field == 'date_published') {
57 if (value == '') { value = null; }
59 obj.editor_base_apply(field, value);
62 /******************************************************************************************************/
63 /* Initialize the panes */
65 'init_panes' : function () {
67 obj.panes_and_field_names = {
69 /* These get shown in the left panel */
70 'siss_editor_left_pane' :
73 $('catStrings').getString('staff.cat.copy_editor.field.creation_date.label') + ' ', //adding extra spaces to satisfy summarize uniqueness requirements
75 render: 'fm.create_date() == null ? "<Unset>" : util.date.formatted_date( fm.create_date(), "%F");',
79 $('catStrings').getString('staff.cat.copy_editor.field.creator.label') + ' ',
81 render: 'fm.creator().usrname() == null ? "<Unset>" : fm.creator().usrname();',
85 $('catStrings').getString('staff.cat.copy_editor.field.last_edit_date.label') + ' ',
87 render: 'fm.edit_date() == null ? "<Unset>" : util.date.formatted_date( fm.edit_date(), "%F");',
91 $('catStrings').getString('staff.cat.copy_editor.field.last_editor.label') + ' ',
93 render: 'fm.editor().usrname() == null ? "<Unset>" : fm.editor().usrname();',
98 'siss_editor_middle_pane' :
100 /*rjs7 don't think we need these anymore [
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);',
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'
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'
124 'Caption/Pattern', //TODO: make this a drop-down selector, perhaps?
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'
133 'siss_editor_right_pane' :
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'
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);',
156 /******************************************************************************************************/
157 /* This loops through all our fieldnames and all the copies, tallying up counts for the different values */
159 'summarize' : serial.editor_base.editor_base_summarize,
161 /******************************************************************************************************/
162 /* Display the summarized data and inputs for editing */
164 'render' : serial.editor_base.editor_base_render,
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,
170 /******************************************************************************************************/
171 /* update the issuances */
173 'save' : function() {
175 obj.editor_base_save('open-ils.serial.issuance.fleshed.batch.update');
178 /******************************************************************************************************/
179 /* spawn issuance notes interface */
181 'notes' : function() {
183 JSAN.use('util.window'); var win = new util.window();
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 }
191 /******************************************************************************************************/
192 'save_attributes' : serial.editor_base.editor_base_save_attributes
195 dump('exiting serial/siss_editor.js\n');