From 38202064763ff7dd9929e3ce7a5fed6c5c62e28d Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 29 Oct 2015 10:17:37 -0400 Subject: [PATCH] KMAIN 266 Note batch dropdown Add batch note/alert field to purchase order line item batch apply. Add loop which adds notes/alerts to lineitems. Add notice to user that an alert code is required. modified: KCLS/openils/var/templates_kcls/acq/common/li_table.tt2 modified: Open-ILS/web/js/ui/kcls/acq/common/li_table.js Signed-off-by: Michael Glass (mglass@catalystitservices.com) berick: did some minor formatting cleanup. Signed-off-by: Bill Erickson --- Open-ILS/src/templates/acq/common/li_table.tt2 | 39 +++++++++++- Open-ILS/web/js/ui/default/acq/common/li_table.js | 76 ++++++++++++++++++++++- 2 files changed, 112 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/templates/acq/common/li_table.tt2 b/Open-ILS/src/templates/acq/common/li_table.tt2 index 91a14bc64d..eafd398853 100644 --- a/Open-ILS/src/templates/acq/common/li_table.tt2 +++ b/Open-ILS/src/templates/acq/common/li_table.tt2 @@ -87,6 +87,19 @@ + + +        + + + + + +        + + + + @@ -108,7 +121,31 @@ OR - + + +   +   + +
+

+ +
+
+ + +   + + +
+ +
+
+
+
+ +   +   + [% l("Apply to Selected") %] diff --git a/Open-ILS/web/js/ui/default/acq/common/li_table.js b/Open-ILS/web/js/ui/default/acq/common/li_table.js index 5ff4144d1e..fa68955fdd 100644 --- a/Open-ILS/web/js/ui/default/acq/common/li_table.js +++ b/Open-ILS/web/js/ui/default/acq/common/li_table.js @@ -1,4 +1,5 @@ dojo.require('dojo.date.locale'); +dojo.require('dojox.validate.check'); dojo.require('dojo.date.stamp'); dojo.require('dijit.form.Button'); dojo.require('dijit.form.TextBox'); @@ -303,6 +304,53 @@ function AcqLiTable() { alert(localeStrings.NO_LI_TO_UPDATE); return; } + //Get all li elements on the page + var liItems = self.getSelected(true, null, false); + + //Add batch of notes to all list elements + dojo.forEach(liItems, function(li) { + if(li_id_list.indexOf(JSON.stringify(li.id())) == -1){return;} + var value = acqBatchCreateNoteText.attr('value'); + if(!value) return; + var note = new fieldmapper.acqlin(); + note.isnew(true); + note.vendor_public( + Boolean(acqBatchCreateNoteVendorPublic.attr('checked')) + ); + note.value(value); + note.lineitem(li.id()); + self.updateLiNotes(li, note, true); + }); + acqBatchCreateNoteVendorPublic.attr("checked", false); + acqBatchCreateNoteText.attr("value", ""); + var alertCodeCheck = true; + //Add alerts to all list elements + dojo.forEach(liItems, function(li) { + if(li_id_list.indexOf(JSON.stringify(li.id())) == -1){return;} + if (!acqBatchLitAlertAlertText.item) { + if(acqBatchLitAlertNoteValue.attr("value") && alertCodeCheck) { + alertCodeCheck = false; + alert(localeStrings.ALERT_UNSELECTED); + } + return; + } + var alert_text = new fieldmapper.acqliat().fromStoreItem( + acqBatchLitAlertAlertText.item + ); + + var value = acqBatchLitAlertNoteValue.attr("value") || ""; + + var note = new fieldmapper.acqlin(); + note.isnew(true); + note.lineitem(li.id()); + note.value(value); + note.alert_text(alert_text); + + self.updateLiNotes(li, note, true); + }); + acqBatchLitAlertNoteValue.attr("value", ""); + acqBatchLitAlertAlertText.attr("value", ""); + progressDialog.show(true); progressDialog.attr("title", localeStrings.LI_BATCH_UPDATE); @@ -339,11 +387,15 @@ function AcqLiTable() { } } ); + location.reload(true); }; }; this.batchUpdateChanges = function() { var o = {}; + + // This will iterate over the batch apply properties, and will create + // an array containing values of the form (batchProp:batchValue). dojo.forEach( openils.Util.objectProperties(this.batchUpdateWidgets), @@ -470,6 +522,7 @@ function AcqLiTable() { openils.Util.show('acq-lit-table-div'); this.focusLi(); this.refreshInlineCopies(); + this._setBatchAlertStore(); break; case 'info': openils.Util.show('acq-lit-info-div'); @@ -1371,6 +1424,24 @@ function AcqLiTable() { openils.Util.show(state_cell); }; + this._setBatchAlertStore = function() { + acqBatchLitAlertAlertText.store = new dojo.data.ItemFileReadStore( + { + "data": acqliat.toStoreData( + this.pcrud.search( + "acqliat", { + "owning_lib": aou.orgNodeTrail( + aou.findOrgUnit(openils.User.user.ws_ou()) + ).map(function(o) { return o.id(); }) + } + ) + ) + } + ); + acqBatchLitAlertAlertText.setValue(); /* make the store "live" */ + acqBatchLitAlertAlertText._store_ready = true; + }; + this._setAlertStore = function() { acqLitAlertAlertText.store = new dojo.data.ItemFileReadStore( @@ -1501,7 +1572,8 @@ function AcqLiTable() { /** * Updates any new/changed/deleted notes on the server */ - this.updateLiNotes = function(li, newNote) { + this.updateLiNotes = function(li, newNote, isBatch) { + isBatch = isBatch || false; var notes; if(newNote) { @@ -1520,7 +1592,7 @@ function AcqLiTable() { fieldmapper.standardRequest( ['open-ils.acq', 'open-ils.acq.lineitem_note.cud.batch'], - { async : true, + { async : !isBatch, params : [this.authtoken, notes], onresponse : function(r) { var resp = openils.Util.readResponse(r); -- 2.11.0