From 3b637c3583d661bc9f4f08d1b2a9aa5f7c0aa9c3 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 12 Jul 2012 16:23:14 -0400 Subject: [PATCH] ACQ : Support for lineitem focus in invoice UI Adds support for a "focus_li" URL parameter. When set, the UI will scroll to the lineitem and provide a brief color change on the table row to help orient. Signed-off-by: Bill Erickson Signed-off-by: Lebbeous Fogle-Weekley --- Open-ILS/web/js/dojo/openils/acq/Lineitem.js | 2 +- Open-ILS/web/js/ui/default/acq/invoice/view.js | 41 ++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/Open-ILS/web/js/dojo/openils/acq/Lineitem.js b/Open-ILS/web/js/dojo/openils/acq/Lineitem.js index 4d0ec80e4c..ec28214d89 100644 --- a/Open-ILS/web/js/dojo/openils/acq/Lineitem.js +++ b/Open-ILS/web/js/dojo/openils/acq/Lineitem.js @@ -122,7 +122,7 @@ openils.acq.Lineitem.fetchAndRender = function(liId, args, callback) { ['open-ils.acq', 'open-ils.acq.lineitem.retrieve.authoritative'], { params : [ openils.User.authtoken, liId, args ], - + async : true, oncomplete : function(r) { var lineitem = openils.Util.readResponse(r); if(!lineitem) return; diff --git a/Open-ILS/web/js/ui/default/acq/invoice/view.js b/Open-ILS/web/js/ui/default/acq/invoice/view.js index a326299e06..8422b8d7b8 100644 --- a/Open-ILS/web/js/ui/default/acq/invoice/view.js +++ b/Open-ILS/web/js/ui/default/acq/invoice/view.js @@ -35,6 +35,7 @@ var virtualId = -1; var extraCopies = {}; var extraCopiesFund; var widgetRegistry = {acqie : {}, acqii : {}}; +var focusLineitem; function nodeByName(name, context) { return dojo.query('[name='+name+']', context)[0]; @@ -44,6 +45,7 @@ function init() { attachLi = cgi.param('attach_li'); attachPo = cgi.param('attach_po'); + focusLineitem = new openils.CGI().param('focus_li'); itemTypes = pcrud.retrieveAll('aiit'); @@ -430,6 +432,39 @@ function updateReceiveLink(li) { link.onclick = function() { location.href = oilsBasePath + '/acq/invoice/receive/' + invoiceId; }; } +/* + * Ensures focusLineitem is in view and causes a brief + * border around the lineitem to come to life then fade. + */ +function focusLi() { + if (!focusLineitem) return; + + // set during addLineitem() + var node = dojo.byId('li-title-ref-' + focusLineitem); + + console.log('focus: li-title-ref-' + focusLineitem + ' : ' + node); + + // LI may not yet be rendered + if (!node) return; + + console.log('focusing ' + focusLineitem); + + // prevent numerous re-focuses + focusLineitem = null; + + // causes the full row to be visible + dijit.scrollIntoView(node); + + dojo.require('dojox.fx'); + + setTimeout( + function() { + dojox.fx.highlight({color : '#BB4433', node : node, duration : 2000}).play(); + }, + 100); +} + + function addInvoiceEntry(entry) { openils.Util.removeCSSClass(dojo.byId('acq-invoice-entry-header'), 'hidden'); @@ -455,6 +490,9 @@ function addInvoiceEntry(entry) { entry.purchase_order(li.purchase_order()); nodeByName('title_details', row).innerHTML = html; + nodeByName('title_details', row).parentNode.id = 'li-title-ref-' + li.id(); + console.log(dojo.byId('li-title-ref-' + li.id())); + updateReceiveLink(li); dojo.forEach( @@ -499,6 +537,9 @@ function addInvoiceEntry(entry) { ); } ); + + if (focusLineitem == li.id()) + focusLi(); } ); -- 2.11.0