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 JSAN.use('util.error'); this.error = new util.error();
11 dump('serial/ssub_editor: ' + E + '\n');
14 /* This keeps track of what fields have been edited for styling purposes */
17 /* This holds the original values for prepopulating the field editors */
18 this.editor_values = {};
22 serial.ssub_editor.prototype = {
23 // we could do this with non-standard '__proto__' property instead
24 'editor_base_init' : serial.editor_base.editor_base_init,
25 'editor_base_apply' : serial.editor_base.editor_base_apply,
26 'editor_base_save' : serial.editor_base.editor_base_save,
29 'fm_type_plural' : 'ssubs',
30 'can_have_notes' : true,
32 'init' : function (params) {
35 params.retrieve_function = 'FM_SSUB_FLESHED_BATCH_RETRIEVE.authoritative';
37 obj.editor_base_init(params);
40 obj.summarize( obj.ssubs );
44 /******************************************************************************************************/
45 /* Restore backup copies */
47 'reset' : serial.editor_base.editor_base_reset,
49 /******************************************************************************************************/
50 /* Apply a value to a specific field on all the copies being edited */
52 'apply' : function(field, value) {
55 if (field == 'start_date' || field == 'end_date') {
56 if (value == '') { value = null; }
59 obj.editor_base_apply(field, value);
63 /******************************************************************************************************/
64 /* These need data from the middle layer to render */
67 function init_panes0() {
68 obj.special_exception = {};
69 obj.special_exception[$('catStrings').getString('staff.cat.copy_editor.field.owning_library.label')] = function(label,value) {
70 JSAN.use('util.widgets');
71 if (value>0) { // an existing call number
72 obj.network.simple_request(
73 'FM_ACN_RETRIEVE.authoritative',
76 var cn = '??? id = ' + value;
78 cn = req.getResultObject();
80 obj.error.sdump('D_ERROR','callnumber retrieve: ' + E);
82 util.widgets.set_text(label,obj.data.hash.aou[ cn.owning_lib() ].shortname() + ' : ' + cn.label());
85 } else { // a yet to be created call number
86 if (obj.callnumbers) {
87 util.widgets.set_text(label,obj.data.hash.aou[ obj.callnumbers[value].owning_lib ].shortname() + ' : ' + obj.callnumbers[value].label);
94 /******************************************************************************************************/
95 /* These get show in the left panel */
97 'init_panes' : function () {
99 obj.panes_and_field_names = {
106 //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);',
113 render: 'typeof fm.owning_lib() == "object" ? fm.owning_lib().shortname() : obj.data.hash.aou[ fm.owning_lib() ].shortname()',
114 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(), false, ( 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);',
115 value_key: 'owning_lib',
116 dropdown_key: 'fm.owning_lib() == null ? null : typeof fm.owning_lib() == "object" ? fm.owning_lib().id() : fm.owning_lib()',
126 render: 'fm.start_date() == null ? "" : util.date.formatted_date( fm.start_date(), "%F");',
127 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);',
128 value_key: 'start_date',
135 render: 'fm.end_date() == null ? "" : util.date.formatted_date( fm.end_date(), "%F");',
136 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);',
137 value_key: 'end_date'
141 'expected_date_offset',
143 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);',
144 value_key: 'expected_date_offset'
152 /******************************************************************************************************/
153 /* This loops through all our fieldnames and all the copies, tallying up counts for the different values */
155 'summarize' : serial.editor_base.editor_base_summarize,
157 /******************************************************************************************************/
158 /* Display the summarized data and inputs for editing */
160 'render' : serial.editor_base.editor_base_render,
162 /******************************************************************************************************/
163 /* This actually draws the change button and input widget for a given field */
164 'render_input' : serial.editor_base.editor_base_render_input,
166 /******************************************************************************************************/
167 /* save the subscriptions */
169 'save' : function() {
171 obj.editor_base_save('open-ils.serial.subscription.fleshed.batch.update');
174 /******************************************************************************************************/
175 /* spawn notes interface */
177 'notes' : function() {
179 JSAN.use('util.window'); var win = new util.window();
181 urls.XUL_SERIAL_NOTES,
182 $('serialStrings').getString('staff.serial.ssub_editor.notes'),'chrome,resizable,modal',
183 { 'object_id' : obj.ssubs[0].id(), 'function_type' : 'SSUBN', 'object_type' : 'subscription', 'constructor' : ssubn }
187 /******************************************************************************************************/
188 'save_attributes' : serial.editor_base.editor_base_save_attributes
191 dump('exiting serial/ssub_editor.js\n');