1 dump('entering serial/ssub_editor.js\n');
4 JSAN.use('serial.editor_base');
6 if (typeof serial == 'undefined') serial = {};
7 serial.ssub_editor = function (params) {
9 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
10 JSAN.use('util.error'); this.error = new util.error();
12 dump('serial/ssub_editor: ' + E + '\n');
15 /* This keeps track of what fields have been edited for styling purposes */
18 /* This holds the original values for prepopulating the field editors */
19 this.editor_values = {};
23 serial.ssub_editor.prototype = {
24 // we could do this with non-standard '__proto__' property instead
25 'editor_base_init' : serial.editor_base.editor_base_init,
26 'editor_base_apply' : serial.editor_base.editor_base_apply,
27 'editor_base_save' : serial.editor_base.editor_base_save,
30 'fm_type_plural' : 'ssubs',
31 'can_have_notes' : true,
33 'init' : function (params) {
36 params.retrieve_function = 'FM_SSUB_FLESHED_BATCH_RETRIEVE.authoritative';
38 obj.editor_base_init(params);
41 obj.summarize( obj.ssubs );
45 /******************************************************************************************************/
46 /* Restore backup copies */
48 'reset' : serial.editor_base.editor_base_reset,
50 /******************************************************************************************************/
51 /* Apply a value to a specific field on all the copies being edited */
53 'apply' : function(field, value) {
56 if (field == 'start_date' || field == 'end_date') {
57 if (value == '') { value = null; }
60 obj.editor_base_apply(field, value);
64 /******************************************************************************************************/
65 /* These need data from the middle layer to render */
68 function init_panes0() {
69 obj.special_exception = {};
70 obj.special_exception[$('catStrings').getString('staff.cat.copy_editor.field.owning_library.label')] = function(label,value) {
71 JSAN.use('util.widgets');
72 if (value>0) { // an existing call number
73 obj.network.simple_request(
74 'FM_ACN_RETRIEVE.authoritative',
77 var cn = '??? id = ' + value;
79 cn = req.getResultObject();
81 obj.error.sdump('D_ERROR','callnumber retrieve: ' + E);
83 util.widgets.set_text(label,obj.data.hash.aou[ cn.owning_lib() ].shortname() + ' : ' + cn.label());
86 } else { // a yet to be created call number
87 if (obj.callnumbers) {
88 util.widgets.set_text(label,obj.data.hash.aou[ obj.callnumbers[value].owning_lib ].shortname() + ' : ' + obj.callnumbers[value].label);
95 /******************************************************************************************************/
96 /* These get show in the left panel */
98 'init_panes' : function () {
100 obj.panes_and_field_names = {
107 //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);',
114 render: 'typeof fm.owning_lib() == "object" ? fm.owning_lib().shortname() : obj.data.hash.aou[ fm.owning_lib() ].shortname()',
115 input: 'c = function(v){ obj.apply("owning_lib",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( util.functional.map_list( obj.data.list.aou, function(myobj) { var sname = myobj.shortname(); for (i = sname.length; i < 20; i++) sname += " "; return [ myobj.name() ? sname + " " + myobj.name() : myobj.shortname(), myobj.id(), ( ! get_bool( obj.data.hash.aout[ myobj.ou_type() ].can_have_vols() ) ), ( obj.data.hash.aout[ myobj.ou_type() ].depth() * 2), ]; }), obj.data.list.au[0].ws_ou()); x.setAttribute("value",obj.editor_values.owning_lib); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
116 value_key: 'owning_lib',
117 dropdown_key: 'fm.owning_lib() == null ? null : typeof fm.owning_lib() == "object" ? fm.owning_lib().id() : fm.owning_lib()',
127 render: 'fm.start_date() == null ? "" : util.date.formatted_date( fm.start_date(), "%F");',
128 input: 'c = function(v){ obj.apply("start_date",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.setAttribute("value",obj.editor_values.start_date); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
129 value_key: 'start_date',
136 render: 'fm.end_date() == null ? "" : util.date.formatted_date( fm.end_date(), "%F");',
137 input: 'c = function(v){ obj.apply("end_date",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.setAttribute("value",obj.editor_values.end_date); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
138 value_key: 'end_date'
142 'expected_date_offset',
144 input: 'c = function(v){ obj.apply("expected_date_offset",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.setAttribute("value",obj.editor_values.expected_date_offset); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
145 value_key: 'expected_date_offset'
153 /******************************************************************************************************/
154 /* This loops through all our fieldnames and all the copies, tallying up counts for the different values */
156 'summarize' : serial.editor_base.editor_base_summarize,
158 /******************************************************************************************************/
159 /* Display the summarized data and inputs for editing */
161 'render' : serial.editor_base.editor_base_render,
163 /******************************************************************************************************/
164 /* This actually draws the change button and input widget for a given field */
165 'render_input' : serial.editor_base.editor_base_render_input,
167 /******************************************************************************************************/
168 /* save the subscriptions */
170 'save' : function() {
172 obj.editor_base_save('open-ils.serial.subscription.fleshed.batch.update');
175 /******************************************************************************************************/
176 /* spawn notes interface */
178 'notes' : function() {
180 JSAN.use('util.window'); var win = new util.window();
182 urls.XUL_SERIAL_NOTES,
183 $('serialStrings').getString('staff.serial.ssub_editor.notes'),'chrome,resizable,modal',
184 { 'object_id' : obj.ssubs[0].id(), 'function_type' : 'SSUBN', 'object_type' : 'subscription', 'constructor' : ssubn }
188 /******************************************************************************************************/
189 'save_attributes' : serial.editor_base.editor_base_save_attributes
192 dump('exiting serial/ssub_editor.js\n');