<!ENTITY staff.main.menu.circ.offline.label "Enter Offline Interface">
<!ENTITY staff.main.menu.circ.patron_registration.accesskey "R">
<!ENTITY staff.main.menu.circ.patron_registration.label "Register Patron">
-<!ENTITY staff.main.menu.circ.staged_patrons.accesskey "t">
-<!ENTITY staff.main.menu.circ.staged_patrons.label "Staged Patrons">
+<!ENTITY staff.main.menu.circ.staged_patrons.accesskey "g">
+<!ENTITY staff.main.menu.circ.staged_patrons.label "Pending Patrons">
<!ENTITY staff.main.menu.circ.patron_retrieve.accesskey "L">
<!ENTITY staff.main.menu.circ.patron_retrieve.label "Retrieve Last Patron">
<!ENTITY staff.main.menu.circ.patron_status.key "P">
<!ENTITY staff.patron_display.archived_penalty.end_date.accesskey "">
<!ENTITY staff.patron_display.archived_penalty.retrieve.label "Retrieve Archived Penalties">
<!ENTITY staff.patron_display.archived_penalty.retrieve.accesskey "R">
-<!ENTITY staff.patron_display.staged.caption "Staged Patrons">
-<!ENTITY staff.patron_display.staged.menu.actions.label "Actions for Selected Events">
-<!ENTITY staff.patron_display.staged.menu.actions.accesskey "A">
-<!ENTITY staff.patron_display.staged.menu.actions.cancel.label "Cancel Patron">
+<!ENTITY staff.patron_display.staged.caption "Pending Patrons">
+<!ENTITY staff.patron_display.staged.menu.actions.cancel.label "Delete Patron">
<!ENTITY staff.patron_display.staged.menu.actions.cancel.accesskey "">
<!ENTITY staff.patron_display.staged.menu.actions.load.label "Load Patron">
<!ENTITY staff.patron_display.staged.menu.actions.load.accesskey "P">
+<!ENTITY staff.patron_display.staged.limit.label "Limit:">
+<!ENTITY staff.patron_display.staged.limit.accesskey "t">
+<!ENTITY staff.patron_display.staged.home_lib.label "Home Library:">
+<!ENTITY staff.patron_display.staged.home_lib.accesskey "H">
+<!ENTITY staff.patron_display.staged.reload.label "Refresh">
+<!ENTITY staff.patron_display.staged.reload.accesskey "R">
<!ENTITY staff.patron_display.trigger_event.caption "Modify Triggered Events">
<!ENTITY staff.patron_display.trigger_event.menu.actions.label "Actions for Selected Events">
<!ENTITY staff.patron_display.trigger_event.menu.actions.accesskey "A">
-var list; var error; var net; var rows; var menu_lib;
+var list; var error; var net; var rows; var row_id_usrname_map; var menu_lib;
function $(id) { return document.getElementById(id); }
list.set_list_actions();
$('cmd_cancel').addEventListener('command', gen_event_handler('cancel'), false);
$('cmd_load').addEventListener('command', gen_event_handler('load'), false);
+ $('cmd_reload').addEventListener('command', function() { populate_list(); }, false);
populate_list();
default_focus();
var file = new util.file('offline_ou_list');
if (file._file.exists()) {
var list_data = file.get_object(); file.close();
- var ml = util.widgets.make_menulist( list_data[0], ses('ws_ou') );
+ menu_lib = x.getAttribute('value') || ses('ws_ou');
+ var ml = util.widgets.make_menulist( list_data[0], menu_lib );
ml.setAttribute('id','lib_menu');
x.appendChild( ml );
ml.addEventListener(
'command',
function(ev) {
menu_lib = ev.target.value;
+ x.setAttribute('value',ev.target.value); oils_persist(x);
populate_list();
},
false
return function(ev) {
try {
var sel = list.retrieve_selection();
- var ids = util.functional.map_list( sel, function(o) { return o.getAttribute('retrieve_id'); } );
+ var row_ids = util.functional.map_list( sel, function(o) { return JSON2js( o.getAttribute('retrieve_id') ).row_id; } );
+ var usrnames = util.functional.map_list( sel, function(o) { return JSON2js( o.getAttribute('retrieve_id') ).usrname; } );
if (method == 'cancel') {
- cancel( ids );
+ cancel( row_ids );
} else {
- load( ids );
+ load( usrnames );
}
} catch(E) {
function cancel(ids) {
try {
- var pm = $('progress'); pm.value = 0; pm.hidden = false;
- var idx = -1;
- fieldmapper.standardRequest(
- [ api['FM_STGU_CANCEL'].app, api['FM_STGU_CANCEL'].method ],
- { async: true,
- params: [ses(), ids],
- onresponse: function(r) {
- try {
- idx++; pm.value = Number( pm.value ) + 100/ids.length;
- var result = openils.Util.readResponse(r);
- if (typeof result.ilsevent != 'undefined') { throw(result); }
- } catch(E) {
- error.standard_unexpected_error_alert('In patron/staged.js, handle_'+i+'_event onresponse.',E);
- }
- },
- onerror: function(r) {
- try {
- var result = openils.Util.readResponse(r);
- throw(result);
- } catch(E) {
- error.standard_unexpected_error_alert('In patron/staged.js, handle_'+i+'_event onerror.',E);
- }
- pm.hidden = true; pm.value = 0; populate_list();
- },
- oncomplete: function(r) {
- try {
- var result = openils.Util.readResponse(r);
- } catch(E) {
- error.standard_unexpected_error_alert('In patron/staged.js, handle_'+i+'_event oncomplete.',E);
+ if (! window.confirm( $('patronStrings').getString('staff.patron.staged.confirm_patron_delete') ) ) { return; }
+ var pm = $('progress'); pm.value = 0; pm.hidden = false;
+ var idx = 0;
+
+ function gen_req_handler(id) {
+ return function(req) {
+ try {
+ idx++; pm.value = Number( pm.value ) + 100/ids.length;
+ if (idx == ids.length) { pm.value = 0; pm.hidden = true; }
+ var robj = req.getResultObject();
+ if (robj == '1') {
+ var node = rows[ row_id_usrname_map[ id ] ].my_node;
+ var parentNode = node.parentNode;
+ parentNode.removeChild( node );
+ delete(rows[ row_id_usrname_map[ id ] ]);
+ delete(row_id_usrname_map[ id ]);
+ } else {
+ alert( $('patronStrings').getFormattedString('staff.patron.staged.error_on_delete',[ id ]) );
}
- pm.hidden = true; pm.value = 0; populate_list();
+ } catch(E) {
+ alert('Error in staged.js, cancel patron request handler: ' + E);
}
}
- );
+ }
+
+ for (var i = 0; i < ids.length; i++) {
+ net.simple_request('FM_STGU_DELETE', [ ses(), ids[i] ], gen_req_handler( ids[i] ));
+ }
} catch(E) {
alert('Error in staged.js, cancel(): ' + E);
}
xulG.new_patron_tab( {}, { 'doit' : 1, 'query' : s } );
}
-function spawn_editor(p) {
+function spawn_editor(p,func) {
var url = urls.XUL_PATRON_EDIT;
var loc = xulG.url_prefix( urls.XUL_REMOTE_BROWSER );
xulG.new_tab(
'url_prefix' : xulG.url_prefix,
'new_tab' : xulG.new_tab,
'new_patron_tab' : xulG.new_patron_tab,
+ 'on_save' : function() { if (typeof func == 'function') { func(); } },
'params' : p
}
}
);
}
-function load( ids ) {
+function load( usrnames ) {
try {
+
+ function gen_on_save_handler(usrname) {
+ return function() {
+ try {
+ var node = rows[ usrname ].my_node;
+ var parentNode = node.parentNode;
+ parentNode.removeChild( node );
+ delete(row_id_usrname_map[ rows[ usrname ].row.my.stgu.row_id() ]);
+ delete(rows[ usrname ]);
+ } catch(E) {
+ alert('Error in staged.js, load on save handler: ' + E);
+ }
+ }
+ }
+
var seen = {};
- for (var i = 0; i < ids.length; i++) {
- if (! seen[ ids[i] ]) {
- seen[ ids[i] ] = true;
- spawn_editor( { 'stage' : ids[i] } );
+ for (var i = 0; i < usrnames.length; i++) {
+ if (! seen[ usrnames[i] ]) {
+ seen[ usrnames[i] ] = true;
+ spawn_editor( { 'stage' : usrnames[i] }, gen_on_save_handler( usrnames[i] ) );
}
}
function retrieve_row(params) { // callback function for fleshing rows in a list
try {
- params.row_node.setAttribute('retrieve_id',params.row.my.stgu.usrname());
+ params.row_node.setAttribute('retrieve_id',js2JSON( { 'row_id' : params.row.my.stgu.row_id(), 'usrname' : params.row.my.stgu.usrname() } ));
params.on_retrieve(params.row);
} catch(E) {
alert('Error in staged.js, retrieve_row(): ' + E);
function populate_list() {
try {
- rows = {};
+ rows = {}; row_id_usrname_map = {};
list.clear();
function onResponse(r) {
}
};
rows[ blob.user.usrname() ] = list.append( row_params );
+ row_id_usrname_map[ blob.user.row_id() ] = blob.user.usrname();
}
function onError(r) {
fieldmapper.standardRequest(
[api['FM_STGU_RETRIEVE'].app, api['FM_STGU_RETRIEVE'].method ],
{ async: true,
- params: [ses(), menu_lib || ses('ws_ou')],
+ params: [ses(), menu_lib || ses('ws_ou'), $('limit').value || 100],
onresponse : onResponse,
onerror : onError,
oncomplete : function() {
<commandset id="staged_cmds">
<command id="cmd_load" disabled="true"/>
<command id="cmd_cancel" disabled="true"/>
+ <command id="cmd_reload" />
</commandset>
<!-- ///////////////////////////////////////////////////////////////////////////////////////////////////////////// -->
<caption id="staged_caption" label="&staff.patron_display.staged.caption;"/>
<vbox flex="0">
<hbox flex="1">
- <hbox id="lib_menu_placeholder" />
+ <vbox pack="center">
+ <label value="&staff.patron_display.staged.limit.label;" accesskey="&staff.patron_display.staged.limit.accesskey;" control="limit" />
+ </vbox>
+ <textbox id="limit" type="number" value="100" oils_persist="value" />
+ <vbox pack="center">
+ <label value="&staff.patron_display.staged.home_lib.label;" accesskey="&staff.patron_display.staged.home_lib.accesskey;" control="lib_menu" />
+ </vbox>
+ <hbox id="lib_menu_placeholder" oils_persist="value" />
+ <button command="cmd_reload" label="&staff.patron_display.staged.reload.label;" accesskey="&staff.patron_display.staged.reload.accesskey;" />
<spacer flex="1" />
<progressmeter id="progress" flex="1" hidden="true" mode="undetermined"/>
-<!--
- <menubar>
- <menu label="&staff.patron_display.staged.menu.actions.label;"
- accesskey="&staff.patron_display.staged.menu.actions.accesskey;"
- style="-moz-user-focus: normal">
- <menupopup>
- <menuitem command="cmd_load" label="&staff.patron_display.staged.menu.actions.load.label;" accesskey="&staff.patron_display.staged.menu.actions.load.accesskey;"/>
- <menuitem command="cmd_cancel" label="&staff.patron_display.staged.menu.actions.cancel.label;" accesskey="&staff.patron_display.staged.menu.actions.cancel.accesskey;"/>
- </menupopup>
- </menu>
- </menubar>
--->
<button command="cmd_load" label="&staff.patron_display.staged.menu.actions.load.label;" accesskey="&staff.patron_display.staged.menu.actions.load.accesskey;"/>
<button command="cmd_cancel" label="&staff.patron_display.staged.menu.actions.cancel.label;" accesskey="&staff.patron_display.staged.menu.actions.cancel.accesskey;"/>
</hbox>