From e59e5db8bef15da8461cbc03c1abe89170beecec Mon Sep 17 00:00:00 2001 From: phasefx Date: Wed, 7 Jan 2009 08:16:38 +0000 Subject: [PATCH] re-orient this interface from scaffolding off of csp's to just using ausp's. Need to add a drop-down of csp's for creating new ausp's, and an edit note function. Also need to rethink the patron sidebar to maintain/stabilize dimensions/layout git-svn-id: svn://svn.open-ils.org/ILS/trunk@11755 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/opac/locale/en-US/lang.dtd | 2 - .../server/locale/en-US/common.properties | 3 - .../server/patron/standing_penalties.js | 63 +++++++++---------- .../server/patron/standing_penalties.xul | 2 - .../xul/staff_client/server/patron/util.js | 8 +-- 5 files changed, 29 insertions(+), 49 deletions(-) diff --git a/Open-ILS/web/opac/locale/en-US/lang.dtd b/Open-ILS/web/opac/locale/en-US/lang.dtd index bacd2c3c8d..2735d6b5bb 100644 --- a/Open-ILS/web/opac/locale/en-US/lang.dtd +++ b/Open-ILS/web/opac/locale/en-US/lang.dtd @@ -1151,8 +1151,6 @@ - - diff --git a/Open-ILS/xul/staff_client/server/locale/en-US/common.properties b/Open-ILS/xul/staff_client/server/locale/en-US/common.properties index eb3ef71ed0..f6de5e109c 100644 --- a/Open-ILS/xul/staff_client/server/locale/en-US/common.properties +++ b/Open-ILS/xul/staff_client/server/locale/en-US/common.properties @@ -78,9 +78,6 @@ staff.csp_block_renew_yes=Yes staff.csp_block_renew_no= staff.csp_block_hold_yes=Yes staff.csp_block_hold_no= -staff.ausp_applied_label=Applied to Patron? -staff.ausp_applied_yes=Applied -staff.ausp_applied_no= staff.ausp_staff_label=Applied By staff.ausp_set_date_label=Applied On staff.ausp_note_label=Note diff --git a/Open-ILS/xul/staff_client/server/patron/standing_penalties.js b/Open-ILS/xul/staff_client/server/patron/standing_penalties.js index 15a2d5f714..d48ce3290a 100644 --- a/Open-ILS/xul/staff_client/server/patron/standing_penalties.js +++ b/Open-ILS/xul/staff_client/server/patron/standing_penalties.js @@ -22,27 +22,17 @@ function penalty_init() { var list = new util.list( 'csp_list' ); list.init( { - 'columns' : patron.util.csp_columns({}), + 'columns' : patron.util.ausp_columns({}), 'map_row_to_columns' : patron.util.std_map_row_to_columns(), 'retrieve_row' : function(params) { - params.row_node.setAttribute('retrieve_id',params.row.my.csp.id()); - if (params.row.my.ausp) { params.row_node.setAttribute('retrieve_ausp_id',params.row.my.ausp.id()); } + params.row_node.setAttribute('retrieve_id',params.row.my.ausp.id()); params.on_retrieve(params.row); return params.row; }, 'on_select' : function(ev) { var sel = list.retrieve_selection(); var ids = util.functional.map_list( sel, function(o) { return JSON2js( o.getAttribute('retrieve_id') ); } ); - var ausp_ids = util.functional.filter_list( - util.functional.map_list( sel, function(o) { return JSON2js( o.getAttribute('retrieve_ausp_id') || 'null' ); } ), - function(o) { return o != null; } - ); if (ids.length > 0) { - document.getElementById('cmd_apply_penalty').setAttribute('disabled','false'); - } else { - document.getElementById('cmd_apply_penalty').setAttribute('disabled','true'); - } - if (ausp_ids.length > 0) { document.getElementById('cmd_remove_penalty').setAttribute('disabled','false'); } else { document.getElementById('cmd_remove_penalty').setAttribute('disabled','true'); @@ -51,21 +41,18 @@ function penalty_init() { } ); - for (var i = 0; i < data.list.csp.length; i++) { - if (data.list.csp[i].id() > 100 ) { - //if (true) { - list.append( - { - 'row' : { - 'my' : { - 'csp' : data.list.csp[i], - 'au' : xulG.patron, - 'ausp' : util.functional.find_list( xulG.patron.standing_penalties(), function(o) { return o.standing_penalty().id() == data.list.csp[i].id(); } ) - } - } + var rows = []; + for (var i = 0; i < xulG.patron.standing_penalties().length; i++) { + var row_params = { + 'row' : { + 'my' : { + 'ausp' : xulG.patron.standing_penalties()[i], + 'csp' : xulG.patron.standing_penalties()[i].standing_penalty(), + 'au' : xulG.patron, } - ); - } + } + }; + rows[ xulG.patron.standing_penalties()[i].id() ] = list.append( row_params ); }; document.getElementById('cmd_apply_penalty').addEventListener( @@ -116,19 +103,25 @@ function penalty_init() { 'command', function() { var sel = list.retrieve_selection(); - var ids = util.functional.filter_list( - util.functional.map_list( sel, function(o) { return JSON2js( o.getAttribute('retrieve_ausp_id') || 'null' ); } ), - function(o) { return o != null; } - ); + var ids = util.functional.map_list( sel, function(o) { return JSON2js( o.getAttribute('retrieve_id') ); } ); if (ids.length > 0) { function gen_func(id) { return function() { - var penalty = util.functional.find_list( xulG.patron.standing_penalties(), function(o) { return o.id() == id; } ); - penalty.isdeleted(1); + try { + var penalty = util.functional.find_list( xulG.patron.standing_penalties(), function(o) { return o.id() == id; } ); + penalty.isdeleted(1); - var req = net.simple_request( 'FM_AUSP_REMOVE', [ ses(), penalty ] ); - if (typeof req.ilsevent != 'undefined' || String(req) != '1') { - error.standard_unexpected_error_alert(patronStrings.getFormattedString('staff.patron.standing_penalty.remove_error',[data.hash.csp[id].name()]),req); + var req = net.simple_request( 'FM_AUSP_REMOVE', [ ses(), penalty ] ); + if (typeof req.ilsevent != 'undefined' || String(req) != '1') { + error.standard_unexpected_error_alert(patronStrings.getFormattedString('staff.patron.standing_penalty.remove_error',[id]),req); + } else { + var node = rows[ id ].my_node; + var parentNode = node.parentNode; + parentNode.removeChild( node ); + delete(rows[ id ]); + } + } catch(E) { + alert(E); } }; } diff --git a/Open-ILS/xul/staff_client/server/patron/standing_penalties.xul b/Open-ILS/xul/staff_client/server/patron/standing_penalties.xul index 630dd6a758..37a81be946 100644 --- a/Open-ILS/xul/staff_client/server/patron/standing_penalties.xul +++ b/Open-ILS/xul/staff_client/server/patron/standing_penalties.xul @@ -47,7 +47,6 @@ - @@ -59,7 +58,6 @@ - diff --git a/Open-ILS/xul/staff_client/server/patron/util.js b/Open-ILS/xul/staff_client/server/patron/util.js index c9c041baf8..1c583325ca 100644 --- a/Open-ILS/xul/staff_client/server/patron/util.js +++ b/Open-ILS/xul/staff_client/server/patron/util.js @@ -257,7 +257,7 @@ patron.util.mp_columns = function(modify,params) { return c.sort( function(a,b) { if (a.label < b.label) return -1; if (a.label > b.label) return 1; return 0; } ); } -patron.util.csp_columns = function(modify,params) { +patron.util.ausp_columns = function(modify,params) { JSAN.use('OpenILS.data'); var data = new OpenILS.data(); data.init({'via':'stash'}); JSAN.use('util.functional'); @@ -298,12 +298,6 @@ patron.util.csp_columns = function(modify,params) { 'persist' : 'hidden width ordinal', 'id' : 'csp_block_hold', 'label' : commonStrings.getString('staff.csp_block_hold_label'), 'flex' : 1, 'primary' : false, 'hidden' : true, 'render' : function(my) { return String( my.csp.block_list() ).match('HOLD') ? commonStrings.getString('staff.csp_block_hold_yes') : commonStrings.getString('staff.csp_block_hold_no'); - } - }, - { - 'persist' : 'hidden width ordinal', 'id' : 'ausp_applied', 'label' : commonStrings.getString('staff.ausp_applied_label'), 'flex' : 1, - 'primary' : false, 'hidden' : false, 'render' : function(my) { - return my.ausp ? commonStrings.getString('staff.ausp_applied_yes') : commonStrings.getString('staff.ausp_applied_no'); } }, { -- 2.43.2