]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/xul/staff_client/server/serial/scap_editor.js
Teach the i18n Makefile how to handle serial.properties
[working/Evergreen.git] / Open-ILS / xul / staff_client / server / serial / scap_editor.js
1 dump('entering serial/scap_editor.js\n');
2 // vim:noet:sw=4:ts=4:
3
4 JSAN.use('serial.editor_base');
5 var pattern_code_key = 'Pattern Code (temporary)';
6
7 if (typeof serial == 'undefined') serial = {};
8 serial.scap_editor = function (params) {
9     try {
10         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
11         JSAN.use('util.error'); this.error = new util.error();
12         JSAN.use('OpenILS.data'); this.data = new OpenILS.data(); this.data.init({'via':'stash'});
13         JSAN.use('util.network'); this.network = new util.network();
14     } catch(E) {
15         dump('serial/scap_editor: ' + E + '\n');
16     }
17
18     /* This keeps track of what fields have been edited for styling purposes */
19     this.changed = {};
20
21     /* This holds the original values for prepopulating the field editors */
22     this.editor_values = {};
23
24 };
25
26 serial.scap_editor.prototype = {
27     // we could do this with non-standard '__proto__' property instead
28     'editor_base_init' : serial.editor_base.editor_base_init,
29     'editor_base_apply' : serial.editor_base.editor_base_apply,
30     'editor_base_save' : serial.editor_base.editor_base_save,
31
32     'fm_type' : 'scap',
33     'fm_type_plural' : 'scaps',
34
35     'init' : function (params) {
36         var obj = this;
37
38         params.retrieve_function = 'FM_SCAP_BATCH_RETRIEVE.authoritative';
39
40         obj.editor_base_init(params);
41
42         /* Do it */
43         obj.summarize( obj.scaps );
44         obj.render();
45     },
46
47     /******************************************************************************************************/
48     /* Restore backup copies */
49
50     'reset' :  serial.editor_base.editor_base_reset,
51
52     /******************************************************************************************************/
53     /* Apply a value to a specific field on all the copies being edited */
54
55     'apply' : function(field,value) {
56         var obj = this;
57
58         obj.editor_base_apply(field, value);
59     },
60
61     /******************************************************************************************************/
62
63     'init_panes' : function () {
64         var obj = this;
65         obj.panes_and_field_names = {
66
67         /* These get shown in the left panel */
68         'scap_editor_left_pane' :
69         [
70             [
71                 'ID',
72                 { 
73                     render: '"ID : " + fm.id();', 
74                     //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);',
75
76                 }
77             ],
78             [
79                 $('catStrings').getString('staff.cat.copy_editor.field.creation_date.label'),
80                 {
81                     render: 'fm.create_date() == null ? "<Unset>" : util.date.formatted_date( fm.create_date(), "%F");',
82                 }
83             ],
84             [
85                 'Type',
86                 {
87                     render: 'fm.type();',
88                     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);',
89                     value_key: 'type'
90                 }
91             ],
92             [
93                 'Active?',
94                 {
95                     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") )',
96                     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);',
97                     value_key: 'active',
98                     dropdown_key: 'fm.active()'
99                 }
100             ],
101             [
102                 pattern_code_key,
103                 { 
104                     render: 'fm.pattern_code() == null ? "" : fm.pattern_code();',
105                     input: 'c = function(v){ obj.apply("pattern_code",v); if (typeof post_c == "function") post_c(v); }; x = document.createElement("textbox"); x.setAttribute("value",obj.editor_values.pattern_code); x.addEventListener("apply",function(f){ return function(ev) { f(ev.target.value); } }(c), false);',
106                     value_key: 'pattern_code'
107                 }
108             ]
109         ]
110
111         };
112     },
113
114     /******************************************************************************************************/
115     /* This loops through all our fieldnames and all the copies, tallying up counts for the different values */
116
117     'summarize' :  serial.editor_base.editor_base_summarize,
118
119     /******************************************************************************************************/
120     /* Display the summarized data and inputs for editing */
121
122     'render' :  serial.editor_base.editor_base_render,
123
124     /******************************************************************************************************/
125     /* This actually draws the change button and input widget for a given field */
126     'render_input' : serial.editor_base.editor_base_render_input,
127
128     /******************************************************************************************************/
129     /* save the caption/patterns */
130
131     'save' : function() {
132         var obj = this;
133         obj.editor_base_save('open-ils.serial.caption_and_pattern.batch.update');
134     },
135
136     /* Pattern/caption wizard */
137     "pattern_wizard": function() {
138         var obj = this;
139
140         var onsubmit = function(value) {
141             obj.apply("pattern_code", value);
142             obj.summarize(obj.scaps);
143             obj.render();
144         };
145         netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
146         window.openDialog(
147             xulG.url_prefix("/xul/server/serial/pattern_wizard.xul"),
148             "pattern_wizard",
149             "width=800",
150             onsubmit
151         );
152     },
153
154     /******************************************************************************************************/
155     'save_attributes' : serial.editor_base.editor_base_save_attributes
156 };
157
158 dump('exiting serial/scap_editor.js\n');