[open-ils-commits] r18930 - in trunk/Open-ILS/xul/staff_client/chrome/content: OpenILS circ (phasefx)
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Dec 7 15:01:13 EST 2010
Author: phasefx
Date: 2010-12-07 15:01:09 -0500 (Tue, 07 Dec 2010)
New Revision: 18930
Modified:
trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js
trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline.js
trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkin.js
trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkin.xul
trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkout.js
trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkout.xul
trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_in_house_use.js
trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_in_house_use.xul
trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_register.js
trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_register.xul
trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_renew.js
trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_renew.xul
Log:
add unsaved data warning to offline interface. tweak oils_lock_page/oils_unlock_page to support multiple locks. Hide Cancel buttons in offline interfaces, which weren't consistently implemented and had no warnings. TODO: fix it so that closing the login window won't kill offline UI with unsaved data
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js 2010-12-07 16:58:24 UTC (rev 18929)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/OpenILS/global_util.js 2010-12-07 20:01:09 UTC (rev 18930)
@@ -3,37 +3,39 @@
function oils_lock_page(params) {
dump('oils_lock_page\n');
if (!params) { params = {}; }
- if (window.oils_lock) {
+ if (window.oils_lock > 0) {
if (!params.allow_multiple_locks) {
- return 'already locked';
+ return window.oils_lock;
}
}
- window.oils_lock = true;
+ window.oils_lock++;
if (typeof xulG != 'undefined') {
if (typeof xulG.unlock_tab == 'function') {
xulG.lock_tab();
}
}
- return 'locked';
+ return window.oils_lock;
}
function oils_unlock_page(params) {
dump('oils_unlock_page\n');
- window.oils_lock = false;
+ window.oils_lock--;
+ if (window.oils_lock < 0) { window.oils_lock = 0; }
if (typeof xulG != 'undefined') {
if (typeof xulG.unlock_tab == 'function') {
xulG.unlock_tab();
}
}
- return 'unlocked';
+ return window.oils_lock;
}
+ window.oils_lock = 0;
window.addEventListener(
'close',
function(ev) {
try {
dump('oils_lock_page/oils_unlock_page onclose handler\n');
- if (window.oils_lock) {
+ if (window.oils_lock > 0) {
var confirmation = window.confirm($('offlineStrings').getString('menu.close_window.unsaved_data_warning'));
if (!confirmation) {
ev.preventDefault();
@@ -41,7 +43,7 @@
}
}
- window.oils_lock = false;
+ window.oils_lock = 0;
if (typeof xulG != 'undefined') {
if (typeof xulG.unlock_tab == 'function') {
xulG.unlock_tab();
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline.js 2010-12-07 16:58:24 UTC (rev 18929)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline.js 2010-12-07 20:01:09 UTC (rev 18930)
@@ -31,23 +31,68 @@
],
'cmd_checkout' : [
['command'],
- function() { obj.deck.set_iframe('offline_checkout.xul',{},{}); }
+ function() {
+ obj.deck.set_iframe(
+ 'offline_checkout.xul',
+ {},
+ {
+ 'lock' : function() { oils_lock_page({'allow_multiple_locks':true}); },
+ 'unlock' : oils_unlock_page
+ }
+ );
+ }
],
'cmd_renew' : [
['command'],
- function() { obj.deck.set_iframe('offline_renew.xul',{},{}); }
+ function() {
+ obj.deck.set_iframe(
+ 'offline_renew.xul',
+ {},
+ {
+ 'lock' : function() { oils_lock_page({'allow_multiple_locks':true}); },
+ 'unlock' : oils_unlock_page
+ }
+ );
+ }
],
'cmd_in_house_use' : [
['command'],
- function() { obj.deck.set_iframe('offline_in_house_use.xul',{},{}); }
+ function() {
+ obj.deck.set_iframe(
+ 'offline_in_house_use.xul',
+ {},
+ {
+ 'lock' : function() { oils_lock_page({'allow_multiple_locks':true}); },
+ 'unlock' : oils_unlock_page
+ }
+ );
+ }
],
'cmd_checkin' : [
['command'],
- function() { obj.deck.set_iframe('offline_checkin.xul',{},{}); }
+ function() {
+ obj.deck.set_iframe(
+ 'offline_checkin.xul',
+ {},
+ {
+ 'lock' : function() { oils_lock_page({'allow_multiple_locks':true}); },
+ 'unlock' : oils_unlock_page
+ }
+ );
+ }
],
'cmd_register_patron' : [
['command'],
- function() { obj.deck.set_iframe('offline_register.xul',{},{}); }
+ function() {
+ obj.deck.set_iframe(
+ 'offline_register.xul',
+ {},
+ {
+ 'lock' : function() { oils_lock_page({'allow_multiple_locks':true}); },
+ 'unlock' : oils_unlock_page
+ }
+ );
+ }
],
'cmd_print_last_receipt' : [
['command'],
@@ -58,7 +103,14 @@
],
'cmd_exit' : [
['command'],
- function() { try { xulG.close_tab(); } catch(E) { window.close(); } }
+ function() {
+ try {
+ xulG.close_tab();
+ } catch(E) {
+ JSAN.use('util.widgets');
+ util.widgets.dispatch('close',window);
+ }
+ }
],
}
}
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkin.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkin.js 2010-12-07 16:58:24 UTC (rev 18929)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkin.js 2010-12-07 20:01:09 UTC (rev 18930)
@@ -1,4 +1,5 @@
var offlineStrings;
+var local_lock = false;
function my_init() {
try {
@@ -26,6 +27,13 @@
JSAN.use('util.date');
+ function handle_lock(ev) {
+ if (!local_lock) {
+ local_lock = true;
+ xulG.lock();
+ }
+ }
+ $('i_barcode').addEventListener('change',handle_lock,false);
$('i_barcode').addEventListener('keypress',handle_keypress,false);
$('i_barcode').focus();
@@ -92,6 +100,11 @@
var x = $('i_barcode'); x.value = ''; x.focus();
+ if (!local_lock) {
+ local_lock = true;
+ xulG.lock();
+ }
+
} catch(E) {
dump(E+'\n'); alert(E);
@@ -109,6 +122,11 @@
}
file.close();
+ if (local_lock) {
+ local_lock = false;
+ xulG.unlock();
+ }
+
if ($('print_receipt').checked) {
try {
var params = {
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkin.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkin.xul 2010-12-07 16:58:24 UTC (rev 18929)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkin.xul 2010-12-07 20:01:09 UTC (rev 18930)
@@ -67,7 +67,7 @@
</hbox>
<hbox>
<spacer flex="1"/>
- <button id="cancel" label="&common.cancel;" oncommand="g.list.clear()"/>
+ <button id="cancel" hidden="true" label="&common.cancel;" oncommand="g.list.clear()"/>
<button id="submit" label="&common.save_transactions.label;" accesskey="&common.save_transactions.accesskey;" />
</hbox>
</vbox>
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkout.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkout.js 2010-12-07 16:58:24 UTC (rev 18929)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkout.js 2010-12-07 20:01:09 UTC (rev 18930)
@@ -1,4 +1,5 @@
var offlineStrings;
+var local_lock = false;
function my_init() {
try {
@@ -31,14 +32,23 @@
var todayPlus = new Date(); todayPlus.setTime( today.getTime() + 24*60*60*1000*14 );
todayPlus = util.date.formatted_date(todayPlus,"%F");
+ function handle_lock(ev) {
+ if (!local_lock) {
+ local_lock = true;
+ xulG.lock();
+ }
+ }
+
$('duedate').setAttribute('value',todayPlus);
$('duedate').addEventListener('change',check_date,false);
$('p_barcode').addEventListener('change',test_patron,false);
+ $('p_barcode').addEventListener('change',handle_lock,false);
$('p_barcode').addEventListener('keypress',handle_keypress,false);
$('p_barcode').focus();
+ $('i_barcode').addEventListener('change',handle_lock,false);
$('i_barcode').addEventListener('keypress',handle_keypress,false);
$('enter').addEventListener('command',handle_enter,false);
@@ -238,6 +248,11 @@
var x = $('i_barcode'); x.value = ''; x.focus();
+ if (!local_lock) {
+ local_lock = true;
+ xulG.lock();
+ }
+
} catch(E) {
dump(E+'\n'); alert(E);
@@ -261,6 +276,11 @@
file.append_object(row);
}
file.close();
+
+ if (local_lock) {
+ local_lock = false;
+ xulG.unlock();
+ }
}
function next_patron(cancel) {
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkout.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkout.xul 2010-12-07 16:58:24 UTC (rev 18929)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_checkout.xul 2010-12-07 20:01:09 UTC (rev 18930)
@@ -106,7 +106,7 @@
</hbox>
<hbox>
<spacer flex="1"/>
- <button id="cancel" label="&common.cancel;" />
+ <button id="cancel" hidden="true" label="&common.cancel;" />
<button id="submit" label="&common.save_transactions.label;" accesskey="&common.save_transactions.accesskey;" />
</hbox>
</vbox>
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_in_house_use.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_in_house_use.js 2010-12-07 16:58:24 UTC (rev 18929)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_in_house_use.js 2010-12-07 20:01:09 UTC (rev 18930)
@@ -1,4 +1,5 @@
var offlineStrings;
+var local_lock = false;
function my_init() {
try {
@@ -24,6 +25,13 @@
'map_row_to_column' : circ.util.std_map_row_to_column(),
} );
+ function handle_lock(ev) {
+ if (!local_lock) {
+ local_lock = true;
+ xulG.lock();
+ }
+ }
+ $('i_barcode').addEventListener('change',handle_lock,false);
$('i_barcode').addEventListener('keypress',handle_keypress,false);
$('enter').addEventListener('command',handle_enter,false);
$('submit').addEventListener('command',next_patron,false);
@@ -95,6 +103,11 @@
var x = $('i_barcode'); x.value = ''; x.focus();
+ if (!local_lock) {
+ local_lock = true;
+ xulG.lock();
+ }
+
} catch(E) {
dump(E+'\n'); alert(E);
@@ -112,6 +125,11 @@
}
file.close();
+ if (local_lock) {
+ local_lock = false;
+ xulG.unlock();
+ }
+
if ($('print_receipt').checked) {
try {
var params = {
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_in_house_use.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_in_house_use.xul 2010-12-07 16:58:24 UTC (rev 18929)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_in_house_use.xul 2010-12-07 20:01:09 UTC (rev 18930)
@@ -76,7 +76,7 @@
</hbox>
<hbox>
<spacer flex="1"/>
- <button id="cancel" label="&common.cancel;" oncommand="g.list.clear()"/>
+ <button id="cancel" hidden="true" label="&common.cancel;" oncommand="g.list.clear()"/>
<button id="submit" label="&common.save_transactions.label;" accesskey="&common.save_transactions.accesskey;" />
</hbox>
</vbox>
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_register.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_register.js 2010-12-07 16:58:24 UTC (rev 18929)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_register.js 2010-12-07 20:01:09 UTC (rev 18930)
@@ -1,4 +1,5 @@
var offlineStrings;
+var local_lock = false;
function my_init() {
try {
@@ -21,6 +22,48 @@
$('barcode').addEventListener('keypress',handle_keypress,false);
$('submit').addEventListener('command',next_patron,false);
+ function handle_lock(ev) {
+ if (!local_lock) {
+ local_lock = true;
+ xulG.lock();
+ }
+ }
+ $('barcode').addEventListener('change',handle_lock,false);
+ $('passwd').addEventListener('change',handle_lock,false);
+ $('ident_value').addEventListener('change',handle_lock,false);
+ $('first_given_name').addEventListener('change',handle_lock,false);
+ $('family_name').addEventListener('change',handle_lock,false);
+ $('dob').addEventListener('change',handle_lock,false);
+ $('street1').addEventListener('change',handle_lock,false);
+ $('street2').addEventListener('change',handle_lock,false);
+ $('city').addEventListener('change',handle_lock,false);
+ $('state').addEventListener('change',handle_lock,false);
+ $('country').addEventListener('change',handle_lock,false);
+ $('post_code').addEventListener('change',handle_lock,false);
+
+ $('cancel').addEventListener(
+ 'command',
+ function(ev) {
+ $('barcode').value = '';
+ $('passwd').value = '';
+ $('ident_value').value = '';
+ $('first_given_name').value = '';
+ $('family_name').value = '';
+ $('dob').value = '';
+ $('street1').value = '';
+ $('street2').value = '';
+ $('city').value = '';
+ $('state').value = '';
+ $('country').value = '';
+ $('post_code').value = '';
+ if (local_lock) {
+ local_lock = false;
+ xulG.unlock();
+ }
+ },
+ false
+ );
+
JSAN.use('util.file');
JSAN.use('util.widgets');
@@ -316,6 +359,11 @@
file.append_object(obj);
file.close();
+ if (local_lock) {
+ local_lock = false;
+ xulG.unlock();
+ }
+
alert(offlineStrings.getString('circ.offline_register.patron.saved'));
$('passwd').value = parseInt(Math.random()*8999+1000);
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_register.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_register.xul 2010-12-07 16:58:24 UTC (rev 18929)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_register.xul 2010-12-07 20:01:09 UTC (rev 18930)
@@ -127,7 +127,7 @@
</hbox>
<hbox>
<spacer flex="1"/>
- <button id="cancel" label="&common.cancel;" />
+ <button id="cancel" hidden="true" label="&common.cancel;" />
<button id="submit" label="&staff.circ.offline_register.submit.label;" accesskey="&staff.circ.offline_register.submit.accesskey;" />
</hbox>
</groupbox>
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_renew.js
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_renew.js 2010-12-07 16:58:24 UTC (rev 18929)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_renew.js 2010-12-07 20:01:09 UTC (rev 18930)
@@ -1,4 +1,6 @@
var offlineStrings;
+var local_lock = false;
+
function my_init() {
try {
offlineStrings = $('offlineStrings');
@@ -27,14 +29,23 @@
var todayPlus = new Date(); todayPlus.setTime( today.getTime() + 24*60*60*1000*14 );
todayPlus = util.date.formatted_date(todayPlus,"%F");
+ function handle_lock(ev) {
+ if (!local_lock) {
+ local_lock = true;
+ xulG.lock();
+ }
+ }
+
$('duedate').setAttribute('value',todayPlus);
$('duedate').addEventListener('change',check_date,false);
+ $('p_barcode').addEventListener('change',handle_lock,false);
$('p_barcode').addEventListener('change',test_patron,false);
$('p_barcode').addEventListener('keypress',handle_keypress,false);
$('p_barcode').focus();
+ $('i_barcode').addEventListener('change',handle_lock,false);
$('i_barcode').addEventListener('keypress',handle_keypress,false);
$('enter').addEventListener('command',handle_enter,false);
@@ -199,6 +210,11 @@
var x = $('i_barcode'); x.value = ''; x.focus();
+ if (!local_lock) {
+ local_lock = true;
+ xulG.lock();
+ }
+
} catch(E) {
dump(E+'\n'); alert(E);
@@ -220,7 +236,12 @@
file.append_object(row);
}
file.close();
-
+
+ if (local_lock) {
+ local_lock = false;
+ xulG.unlock();
+ }
+
if ($('print_receipt').checked) {
try {
var params = {
Modified: trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_renew.xul
===================================================================
--- trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_renew.xul 2010-12-07 16:58:24 UTC (rev 18929)
+++ trunk/Open-ILS/xul/staff_client/chrome/content/circ/offline_renew.xul 2010-12-07 20:01:09 UTC (rev 18930)
@@ -100,7 +100,7 @@
</hbox>
<hbox>
<spacer flex="1"/>
- <button id="cancel" label="&common.cancel;" />
+ <button id="cancel" hidden="true" label="&common.cancel;" />
<button id="submit" label="&common.save_transactions.label;" accesskey="&common.save_transactions.accesskey;" />
</hbox>
</vbox>
More information about the open-ils-commits
mailing list