2 <!-- Application: Evergreen Staff Client -->
3 <!-- Screen: Serial Notes -->
8 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
10 <?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
11 <?xml-stylesheet href="chrome://open_ils_staff_client/skin/global.css" type="text/css"?>
12 <?xml-stylesheet href="/xul/server/skin/global.css" type="text/css"?>
13 <?xml-stylesheet href="/xul/server/skin/patron_display.css" type="text/css"?>
15 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
17 <!DOCTYPE window PUBLIC "" ""[
18 <!--#include virtual="/opac/locale/${locale}/lang.dtd"-->
21 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
23 <?xul-overlay href="/xul/server/OpenILS/util_overlay.xul"?>
25 <window id="notes_win" width="700" height="550" oils_persist="height width sizemode"
26 onload="try{ my_init(); font_helper(); persist_helper(); } catch(E) { alert(E); }"
27 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
29 <!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
31 <script type="text/javascript">var myPackageDir = 'open_ils_staff_client'; var IAMXUL = true; var g = {};</script>
32 <scripts id="openils_util_scripts"/>
34 <script type="text/javascript" src="/xul/server/main/JSAN.js"/>
38 function $(id) { return document.getElementById(id); }
42 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
43 if (typeof JSAN == 'undefined') {
44 throw( $("commonStrings").getString('common.jsan.missing') );
46 JSAN.errorLevel = "die"; // none, warn, or die
47 JSAN.addRepository('/xul/server/');
49 JSAN.use('util.error'); g.error = new util.error();
50 JSAN.use('util.network'); g.network = new util.network();
51 JSAN.use('util.date'); JSAN.use('util.money');
52 JSAN.use('OpenILS.data'); g.data = new OpenILS.data(); g.data.init({'via':'stash'});
54 g.error.sdump('D_TRACE','my_init() for notes.xul');
56 g.object_type = xul_param('object_type',{'modal_xulG':true});
57 g.object_id = xul_param('object_id',{'modal_xulG':true});
58 g.function_type = xul_param('function_type',{'modal_xulG':true});
59 g.constructor = xul_param('constructor',{'modal_xulG':true});
64 var err_msg = $("commonStrings").getFormattedString('common.exception', ['serial/notes.xul', js2JSON(E)]);
65 try { g.error.sdump('D_ERROR',err_msg); } catch(E) { dump(err_msg); }
71 retrieve_notes(); render_notes();
74 function retrieve_notes() {
75 g.notes = g.network.simple_request('FM_'+g.function_type+'_RETRIEVE_ALL',[ { 'authtoken' : ses(), 'object_id' : g.object_id } ]).reverse();
78 function apply(node,field,value) {
83 case 'description' : n.appendChild( document.createTextNode( value ) ); break;
84 case 'label' : n.value = value; break;
85 default : n.value = value; break;
91 function render_notes() {
92 JSAN.use('util.widgets'); util.widgets.remove_children('notes_panel');
93 var np = $('notes_panel');
94 var hbox = document.createElement('hbox'); np.appendChild(hbox);
95 var btn = document.createElement('button'); hbox.appendChild(btn);
96 btn.setAttribute('label', $('catStrings').getString('staff.cat.copy_notes.render_notes.label'));
97 btn.setAttribute('accesskey', $('catStrings').getString('staff.cat.copy_notes.render_notes.accesskey'));
98 btn.setAttribute('oncommand','new_note()');
100 var hb; // keep button bar reference for adding close button
101 for (var i = 0; i < g.notes.length; i++) {
104 var node = $('note_template').cloneNode(true); np.appendChild(node); node.hidden = false;
105 apply(node,'create_date',g.notes[i].create_date().toString().substr(0,10));
106 util.widgets.apply(node,'name','create_date',
110 $('catStrings').getString('staff.cat.copy_notes.widgets_apply.note_id') + " "
111 + g.notes[i].id() + " "
112 + $('catStrings').getString('staff.cat.copy_notes.widgets_apply.creator_id') + " "
113 + g.notes[i].creator()
117 apply(node,'title',g.notes[i].title());
118 apply(node,'pub',get_bool( g.notes[i].pub() ) ? $('catStrings').getString('staff.cat.copy_notes.widgets.public') : $('catStrings').getString('staff.cat.copy_notes.widgets.private'));
119 apply(node,'value',g.notes[i].value());
120 apply(node,'id',g.notes[i].id());
121 apply(node,'creator',g.notes[i].creator());
124 hb = document.createElement('hbox'); np.appendChild(hb);
125 var btn0 = document.createElement('button'); hb.appendChild(btn0);
126 btn0.setAttribute('label', $('serialStrings').getString('staff.serial.notes.do_edit_note.label'));
127 btn0.setAttribute('image',"/xul/server/skin/media/images/up_arrow.gif");
129 btn0.addEventListener(
131 function(index){ return function() { new_note(index) } }(i),
134 var btn1 = document.createElement('button'); hb.appendChild(btn1);
135 btn1.setAttribute('label', $('catStrings').getString('staff.cat.copy_notes.delete_note.label'));
136 btn1.setAttribute('image',"/xul/server/skin/media/images/up_arrow.gif");
138 btn1.addEventListener(
140 function(index){ return function() {
141 var r = g.error.yns_alert(
142 $('catStrings').getFormattedString('staff.cat.copy_notes.delete_note.prompt.msg', [g.notes[index].title(), g.notes[index].create_date().toString().substr(0,10)]),
143 $('catStrings').getString('staff.cat.copy_notes.delete_note.prompt.title'),
144 $('catStrings').getString('staff.cat.copy_notes.delete_note.prompt.yes'),
145 $('catStrings').getString('staff.cat.copy_notes.delete_note.prompt.no'),
147 $('commonStrings').getString('common.confirm')
150 g.network.simple_request('FM_'+g.function_type+'_DELETE',[ses(),g.notes[index].id()]);
151 setTimeout(function() {
152 alert($('catStrings').getString('staff.cat.copy_notes.delete_note.success'));
162 if (!hb) { // no notes yet, fill the space and add a bar
163 var spacer = document.createElement('spacer'); np.appendChild(spacer); spacer.flex = 1;
164 hb = document.createElement('hbox'); np.appendChild(hb);
166 var spacer = document.createElement('spacer');
167 hb.appendChild(spacer); spacer.flex = 1;
168 var btn2 = document.createElement('button'); hb.appendChild(btn2);
169 btn2.setAttribute('label', $('catStrings').getString('staff.cat.copy_notes.delete_note.close_window'));
170 btn2.setAttribute('oncommand','window.close();');
174 function new_note(index) {
178 var edit_mode; // for clarity
180 var button_accesskey;
182 if (typeof index != 'undefined') {
184 public = get_bool(g.notes[index].pub());
185 title = g.notes[index].title();
186 value = g.notes[index].value();
187 label_text = $('serialStrings').getString('staff.serial.notes.edit_note.label');
188 button_accesskey = $('serialStrings').getString('staff.serial.notes.edit_note.accesskey');
190 label_text = $('catStrings').getString('staff.cat.copy_notes.new_note.add_note.label');
191 button_accesskey = $('catStrings').getString('staff.cat.copy_notes.new_note.add_note.accesskey');
195 netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalBrowserWrite");
196 var xml = '<groupbox xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" flex="1"> \
197 <caption label="' + label_text + '"/> \
198 <grid flex="1"><columns><column/><column flex="1"/></columns> \
200 <row><label value="' + $('catStrings').getString('staff.cat.copy_notes.new_note.public') + '"/><checkbox id="pub" name="fancy_data" checked="' + public + '"/></row> \
201 <row><label value="' + $('catStrings').getString('staff.cat.copy_notes.new_note.title') + '"/><textbox id="title" name="fancy_data" context="clipboard" value="' + title + '"/></row> \
202 <row><label value="' + $('catStrings').getString('staff.cat.copy_notes.new_note.note') + '"/><textbox multiline="true" id="note" name="fancy_data" context="clipboard" value="' + value + '"/></row> \
203 <row><spacer/><hbox> \
204 <button label="' + $('catStrings').getString('staff.cat.copy_notes.new_note.cancel.label') + '" name="fancy_cancel" accesskey="' + $('catStrings').getString('staff.cat.copy_notes.new_note.cancel.accesskey') + '"/> \
205 <button label="' + label_text + '" accesskey="' + button_accesskey + '" name="fancy_submit"/></hbox></row> \
206 </rows></grid></groupbox>';
207 //g.data.init({'via':'stash'});
208 //g.data.temp_note_xml = xml; g.data.stash('temp_note_xml');
209 JSAN.use('util.window'); var win = new util.window();
210 var fancy_prompt_data = win.open(
211 urls.XUL_FANCY_PROMPT,
212 //+ '?xml_in_stash=temp_note_xml'
213 //+ '&focus=' + window.escape('title')
214 //+ '&title=' + window.escape('Add Note'),
215 'fancy_prompt', 'chrome,resizable,modal,width=700,height=500',
216 { 'xml' : xml, 'focus' : 'title', 'title' : label_text }
218 //g.data.init({'via':'stash'});
219 if (fancy_prompt_data.fancy_status == 'complete') {
220 //alert(js2JSON(g.data.fancy_prompt_data));
223 note = g.notes[index];
225 note = new g.constructor();
228 note.title( fancy_prompt_data.title );
229 note.value( fancy_prompt_data.note );
230 note.pub( get_bool( fancy_prompt_data.pub ) ? get_db_true() : get_db_false() );
231 note[g.object_type]( g.object_id );
232 var r = g.network.simple_request('FM_'+g.function_type+'_UPDATE',[ ses(), note ]);
233 if (typeof r.ilsevent != 'undefined') throw(r);
234 setTimeout(function() {
239 g.error.standard_unexpected_error_alert($('catStrings').getString('staff.cat.copy_notes.new_note.error'),E);
246 <messagecatalog id="catStrings" src="/xul/server/locale/<!--#echo var='locale'-->/cat.properties" />
247 <messagecatalog id="serialStrings" src="/xul/server/locale/<!--#echo var='locale'-->/serial.properties" />
249 <stack hidden="true" id="note_template" flex="1">
250 <groupbox flex="1" style="background-color: black;"/>
251 <groupbox flex="1" style="background-color: #FFDE00; -moz-border-radius-topright: 35px;" >
253 <description name="title" style="font-weight: bold"/>
255 <description name="create_date" style="font-weight: bold"/>
256 <description name="pub" style="font-weight: bold"/>
258 <description name="value"/>
262 <vbox flex="1" class="my_overflow" id="notes_panel">