1 dump('entering serial/scap_editor.js\n');
4 JSAN.use('serial.editor_base');
6 if (typeof serial == 'undefined') serial = {};
7 serial.scap_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/scap_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 = {};
25 serial.scap_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,
32 'fm_type_plural' : 'scaps',
34 'init' : function (params) {
37 params.retrieve_function = 'FM_SCAP_BATCH_RETRIEVE.authoritative';
39 obj.editor_base_init(params);
42 obj.summarize( obj.scaps );
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) {
57 obj.editor_base_apply(field, value);
60 /******************************************************************************************************/
62 'init_panes' : function () {
64 obj.panes_and_field_names = {
66 /* These get shown in the left panel */
67 'scap_editor_left_pane' :
72 //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);',
79 render: 'fm.create_date() == null ? "" : util.date.formatted_date( fm.create_date(), "%F");',
85 input: 'c = function(v){ obj.apply("type",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ ["basic", "basic"], ["index", "index"], ["supplement", "supplement"] ] ); x.setAttribute("value",obj.editor_values.type); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
92 render: 'fm.active() == null ? $("catStrings").getString("staff.cat.copy_editor.field.unset_or_null") : ( get_bool( fm.active() ) ? $("catStrings").getString("staff.cat.copy_editor.field.circulate.yes_or_true") : $("catStrings").getString("staff.cat.copy_editor.field.circulate.no_or_false") )',
93 input: 'c = function(v){ obj.apply("active",v); if (typeof post_c == "function") post_c(v); }; x = util.widgets.make_menulist( [ [ $("catStrings").getString("staff.cat.copy_editor.field.circulate.yes_or_true"), get_db_true() ], [ $("catStrings").getString("staff.cat.copy_editor.field.circulate.no_or_false"), get_db_false() ] ] ); x.setAttribute("value",obj.editor_values.active); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
95 dropdown_key: 'fm.active()'
101 input: 'c = function(v){ obj.apply("pattern_code",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.setAttribute("multiline",true); x.setAttribute("cols",40); x.setAttribute("value",obj.editor_values.pattern_code); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
102 value_key: 'pattern_code'
110 /******************************************************************************************************/
111 /* This loops through all our fieldnames and all the copies, tallying up counts for the different values */
113 'summarize' : serial.editor_base.editor_base_summarize,
115 /******************************************************************************************************/
116 /* Display the summarized data and inputs for editing */
118 'render' : serial.editor_base.editor_base_render,
120 /******************************************************************************************************/
121 /* This actually draws the change button and input widget for a given field */
122 'render_input' : serial.editor_base.editor_base_render_input,
124 /******************************************************************************************************/
125 /* save the caption/patterns */
127 'save' : function() {
129 obj.editor_base_save('open-ils.serial.caption_and_pattern.batch.update');
132 /* Pattern/caption wizard */
133 "pattern_wizard": function() {
136 var onsubmit = function(value) {
137 obj.apply("pattern_code", value);
138 obj.summarize(obj.scaps);
141 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
143 xulG.url_prefix("/xul/server/serial/pattern_wizard.xul"),
150 /******************************************************************************************************/
151 'save_attributes' : serial.editor_base.editor_base_save_attributes
154 dump('exiting serial/scap_editor.js\n');