From 227309968bebb8c7e539763430b5d26334d35129 Mon Sep 17 00:00:00 2001 From: senator Date: Tue, 9 Feb 2010 21:55:26 +0000 Subject: [PATCH] Several bug fixes and improvements to LI table and DF application. - The "release" button was removed from the DF application controls. - The "save changes" button was moved in from the right edge of the screen. - "Save changes" behaves better (doesn't reveal a dead progress bar) when there are no changes to save. - Distribution formula application controls and labels disappear properly from the LI table's copy editor if there are none in the system. - There is no more error about "li.id is not a function." - There is a "reset formulas" button in the DF application controls now that reverts all copy values to whatever they were before any DF were applied (within a single editing session). - When multiple DF are applied, they are applied "serially" with regards to copies, not "in parallel" (i.e., from the end of the last application, not from position zero). git-svn-id: svn://svn.open-ils.org/ILS/trunk@15486 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/css/skin/default/acq.css | 2 + Open-ILS/web/js/dojo/openils/acq/nls/acq.js | 5 +- Open-ILS/web/js/ui/default/acq/common/li_table.js | 130 ++++++++++++++------- Open-ILS/web/js/ui/default/acq/picklist/view.js | 7 +- .../web/templates/default/acq/common/li_table.tt2 | 12 +- 5 files changed, 102 insertions(+), 54 deletions(-) diff --git a/Open-ILS/web/css/skin/default/acq.css b/Open-ILS/web/css/skin/default/acq.css index 211128bef7..8926980055 100644 --- a/Open-ILS/web/css/skin/default/acq.css +++ b/Open-ILS/web/css/skin/default/acq.css @@ -127,6 +127,8 @@ #acq-lit-notes-tbody td {padding: 20px 10px 20px 10px; border-bottom:2px solid #aaa;} .acq-lit-li-menu-bar {width:99%; text-align:left; border:1px solid #aaa; margin:5px 0px 10px 0px;} +.acq-lit-li-menu-left {text-align:left; width:300px;} +.acq-lit-li-menu-right {text-align:left;} .acq-lit-table-spacer { height:20px; } .acq-lit-row td[name="selector"] { width:1.5em; font-weight:bold; color:blue; font-size:110%;} #acq-lit-notes-tbody li { margin-bottom:10px; border:1px solid #aaa; -moz-border-radius: 5px 5px 5px 5px; } diff --git a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js index dbe003f4f1..86c93a1ad3 100644 --- a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js +++ b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js @@ -6,5 +6,8 @@ 'NO_PO_RESULTS': "No results", 'PO_HEADING_ERROR' : "Unexpected problem building virtual combined PO", 'CONFIRM_SPLIT_PO': "Are you sure you want to split this purchase order into\none purchase order for every constituent line item?", - 'DFA_NOT_ALL': "Could not record all of your applications of distribution forumulae." + 'DFA_NOT_ALL': "Could not record all of your applications of distribution forumulas.", + 'APPLY': "Apply", + 'RESET_FORMULAE': "Reset Formulas", + 'OUT_OF_COPIES': "You have applied distribution formulas to every copy." } 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 49c05d8edf..03ba892d9a 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 @@ -35,6 +35,7 @@ function AcqLiTable() { this.plCache = {}; this.poCache = {}; this.dfaCache = []; + this.dfeOffset = 0; this.toggleState = false; this.tbody = dojo.byId('acq-lit-tbody'); this.selectors = []; @@ -48,6 +49,7 @@ function AcqLiTable() { this.liNotesRow = this.liNotesTbody.removeChild(dojo.byId('acq-lit-notes-row')); this.realCopiesTbody = dojo.byId('acq-lit-real-copies-tbody'); this.realCopiesRow = this.realCopiesTbody.removeChild(dojo.byId('acq-lit-real-copies-row')); + this._copy_fields_for_acqdf = ['owning_lib', 'location']; dojo.connect(acqLitLiActionsSelector, 'onChange', function() { @@ -546,7 +548,9 @@ function AcqLiTable() { var self = this; this.copyCache = {}; this.copyWidgetCache = {}; + this.oldCopyWidgetCache = {}; this.dfaCache = []; + this.dfeOffset = 0; acqLitSaveCopies.onClick = function() { self.saveCopyChanges(liId) }; acqLitBatchUpdateCopies.onClick = function() { self.batchCopyUpdate() }; @@ -592,31 +596,33 @@ function AcqLiTable() { ); var apply = new dijit.form.Button( - {label : 'Apply'}, // TODO i18n + {"label": localeStrings.APPLY}, nodeByName('set_button', row) ); - var release = new dijit.form.Button( - {label : 'Release', disabled: true}, // TODO i18n - nodeByName('rel_button', row) + var reset = new dijit.form.Button( + {"label": localeStrings.RESET_FORMULAE, "disabled": true}, + nodeByName("reset_button", row) ); dojo.connect(apply, 'onClick', function() { var form_id = selector.attr('value'); if(!form_id) return; - apply.attr('disabled', true); - release.attr('disabled', false); self._applyDistribFormula(form_id); + reset.attr("disabled", false); } ); - dojo.connect(release, 'onClick', + dojo.connect(reset, 'onClick', function() { - apply.attr('disabled', false); - release.attr('disabled', true); + self.restoreCopyFieldsBeforeDF(); + self.dfaCache = []; + self.dfeOffset = 0; + reset.attr("disabled", "true"); } ); + }; /** @@ -626,20 +632,27 @@ function AcqLiTable() { if(!formula) return; formula = this.distribForms.filter( - function(form) { - return form.id() == formula; - } + function(form) { return form.id() == formula; } )[0]; var copyRows = dojo.query('tr', self.copyTbody); - var acted = false; - for(var rowIndex = 0; rowIndex < copyRows.length; rowIndex++) { + if (this.dfeOffset >= copyRows.length) { + alert(localeStrings.OUT_OF_COPIES); + return; + } + + var entries_applied = 0; + for( + var rowIndex = this.dfeOffset; + rowIndex < copyRows.length; + rowIndex++ + ) { var row = copyRows[rowIndex]; var copy_id = row.getAttribute('copy_id'); var copyWidgets = this.copyWidgetCache[copy_id]; - var entryIndex = 0; + var entryIndex = this.dfeOffset; var entry = null; // find the correct entry for the current row @@ -658,11 +671,11 @@ function AcqLiTable() { //console.log("rowIndex = " + rowIndex + ", entry = " + entry.id() + ", entryIndex=" + // entryIndex + ", owning_lib = " + entry.owning_lib() + ", location = " + entry.location()); - dojo.forEach( - ['owning_lib', 'location'], + entries_applied++; + this.saveCopyFieldsBeforeDF(copy_id); + this._copy_fields_for_acqdf.forEach( function(field) { if(entry[field]()) { - acted = true; copyWidgets[field].attr('value', (entry[field]())); } } @@ -670,11 +683,40 @@ function AcqLiTable() { } } - if (acted) { + if (entries_applied) { this.dfaCache.push(formula.id()); + this.dfeOffset += entries_applied; }; }; + this.saveCopyFieldsBeforeDF = function(copy_id) { + var self = this; + if (!this.oldCopyWidgetCache[copy_id]) { + var copyWidgets = this.copyWidgetCache[copy_id]; + + this.oldCopyWidgetCache[copy_id] = {}; + this._copy_fields_for_acqdf.forEach( + function(f) { + self.oldCopyWidgetCache[copy_id][f] = + copyWidgets[f].attr("value"); + } + ); + } + }; + + this.restoreCopyFieldsBeforeDF = function() { + var self = this; + for (var copy_id in this.oldCopyWidgetCache) { + this._copy_fields_for_acqdf.forEach( + function(f) { + self.copyWidgetCache[copy_id][f].attr( + "value", self.oldCopyWidgetCache[copy_id][f] + ); + } + ); + } + }; + this._fetchDistribFormulas = function(onload) { if(this.distribForms) { onload(); @@ -687,12 +729,13 @@ function AcqLiTable() { oncomplete: function(r) { self.distribForms = openils.Util.readResponse(r); if(!self.distribForms || self.distribForms.length == 0) { - self.distribForms = []; - return onload(); + self.distribForms = []; + } else { + self.distribFormulaStore = + new dojo.data.ItemFileReadStore( + {data:acqdf.toStoreData(self.distribForms)} + ); } - self.distribFormulaStore = - new dojo.data.ItemFileReadStore( - {data:acqdf.toStoreData(self.distribForms)}); self._addDistribFormulaRow(); onload(); } @@ -861,8 +904,6 @@ function AcqLiTable() { var copies = []; - openils.Util.show('acq-lit-update-copies-progress'); - var total = 0; for(var id in this.copyCache) { var c = this.copyCache[id]; @@ -879,26 +920,28 @@ function AcqLiTable() { dojo.byId('acq-lit-copy-count-label-' + liId).innerHTML = total; - if(copies.length == 0) - return; - fieldmapper.standardRequest( - ['open-ils.acq', 'open-ils.acq.lineitem_detail.cud.batch'], - { async: true, - params: [openils.User.authtoken, copies], - onresponse: function(r) { - var res = openils.Util.readResponse(r); - litUpdateCopiesProgress.update(res); - }, - oncomplete: function() { - openils.Util.hide('acq-lit-update-copies-progress'); - self.drawCopies(liId); + if (copies.length > 0) { + openils.Util.show("acq-lit-update-copies-progress"); + fieldmapper.standardRequest( + ['open-ils.acq', 'open-ils.acq.lineitem_detail.cud.batch'], + { async: true, + params: [openils.User.authtoken, copies], + onresponse: function(r) { + var res = openils.Util.readResponse(r); + litUpdateCopiesProgress.update(res); + }, + oncomplete: function() { + self.drawCopies(liId); + openils.Util.hide("acq-lit-update-copies-progress"); + } } - } - ); + ); + } if (this.dfaCache.length > 0) { - var oldlength = this.dfaCache.length; + var oldlength = this.dfaCache.length; + fieldmapper.standardRequest( ["open-ils.acq", "open-ils.acq.distribution_formula.record_application"], @@ -1366,6 +1409,3 @@ function AcqLiTable() { }}); } } - - - diff --git a/Open-ILS/web/js/ui/default/acq/picklist/view.js b/Open-ILS/web/js/ui/default/acq/picklist/view.js index d89a5cd1a9..a93cd66f5c 100644 --- a/Open-ILS/web/js/ui/default/acq/picklist/view.js +++ b/Open-ILS/web/js/ui/default/acq/picklist/view.js @@ -80,8 +80,11 @@ function loadLIs() { params: [openils.User.authtoken, plId, {flesh_notes:true, flesh_attrs:true, clear_marc:true, offset:plOffset, limit:plLimit}], onresponse: function(r) { - liTable.show('list'); - liTable.addLineitem(openils.Util.readResponse(r)); + var li = openils.Util.readResponse(r); + if (li) { /* Not every response is an LI (for some reason) */ + liTable.addLineitem(li); + liTable.show('list'); + } } } ); diff --git a/Open-ILS/web/templates/default/acq/common/li_table.tt2 b/Open-ILS/web/templates/default/acq/common/li_table.tt2 index 5971e922f7..0787eb3070 100644 --- a/Open-ILS/web/templates/default/acq/common/li_table.tt2 +++ b/Open-ILS/web/templates/default/acq/common/li_table.tt2 @@ -170,7 +170,7 @@
- -
+
↖ Return
Item Count: @@ -179,13 +179,13 @@
Go
- +
Save Changes
+
@@ -214,7 +214,7 @@ Distribution Formulas
-
+
-- 2.11.0