From 87e8303b839835726d7f6380d309d7558d9d07eb Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 30 Jul 2014 15:59:02 -0400 Subject: [PATCH] LP#1350371 detect dupe PO name on edit When changing the name of an existing PO, if the selected name collides w/ another PO at or below the ordering agency, a warning is shown to the user, including a link to the matching PO, and the name change is aborted. Signed-off-by: Bill Erickson Signed-off-by: Kathy Lussier Signed-off-by: Mike Rylander --- Open-ILS/src/templates/acq/po/view.tt2 | 9 +++- Open-ILS/web/js/ui/default/acq/po/view_po.js | 57 ++++++++++++++++++++ 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/templates/acq/po/view.tt2 b/Open-ILS/src/templates/acq/po/view.tt2 index ab1ba88922..00a8543f1e 100644 --- a/Open-ILS/src/templates/acq/po/view.tt2 +++ b/Open-ILS/src/templates/acq/po/view.tt2 @@ -16,8 +16,13 @@ [% l('Name') %] - + + + + [% l('Activatable?') %] diff --git a/Open-ILS/web/js/ui/default/acq/po/view_po.js b/Open-ILS/web/js/ui/default/acq/po/view_po.js index 8a43179211..436450a545 100644 --- a/Open-ILS/web/js/ui/default/acq/po/view_po.js +++ b/Open-ILS/web/js/ui/default/acq/po/view_po.js @@ -668,6 +668,63 @@ function splitPo() { function updatePoName() { var value = prompt('Enter new purchase order name:', PO.name()); // TODO i18n if(!value || value == PO.name()) return; + + var orgs = fieldmapper.aou.descendantNodeList(PO.ordering_agency(), true); + new openils.PermaCrud().search('acqpo', + { + id : {'<>' : PO.id()}, + name : value, + ordering_agency : orgs + }, + {async : true, oncomplete : function(r) { + var po = openils.Util.readResponse(r); + openils.Util.hide('acq-dupe-po-name'); + + if (po && (po = po[0])) { + var link = dojo.byId('acq-dupe-po-link'); + openils.Util.show('acq-dupe-po-name'); + var dupe_path = '/acq/po/view/' + po.id(); + + if (window.xulG) { + + if (window.IAMBROWSER) { + // TODO: integration + + } else { + // XUL client + link.onclick = function() { + + var loc = xulG.url_prefix('XUL_BROWSER?url=') + + window.encodeURIComponent( + xulG.url_prefix('EG_WEB_BASE' + dupe_path) + ); + + xulG.new_tab(loc, + {tab_name: '', browser:false}, + { + no_xulG : false, + show_nav_buttons : true, + show_print_button : true, + } + ); + } + } + + } else { + link.onclick = function() { + window.open(oilsBasePath + dupe_path, '_blank').focus(); + } + } + + } else { + updatePoName2(value); + } + }} + ); + +} + +function updatePoName2(value) { PO.name(value); pcrud.update(PO, { oncomplete : function(r, cudResults) { -- 2.43.2