[open-ils-commits] r15486 - in trunk/Open-ILS/web: css/skin/default js/dojo/openils/acq/nls js/ui/default/acq/common js/ui/default/acq/picklist templates/default/acq/common (senator)

svn at svn.open-ils.org svn at svn.open-ils.org
Tue Feb 9 16:55:32 EST 2010


Author: senator
Date: 2010-02-09 16:55:26 -0500 (Tue, 09 Feb 2010)
New Revision: 15486

Modified:
   trunk/Open-ILS/web/css/skin/default/acq.css
   trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js
   trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
   trunk/Open-ILS/web/js/ui/default/acq/picklist/view.js
   trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2
Log:
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). 


Modified: trunk/Open-ILS/web/css/skin/default/acq.css
===================================================================
--- trunk/Open-ILS/web/css/skin/default/acq.css	2010-02-09 20:38:27 UTC (rev 15485)
+++ trunk/Open-ILS/web/css/skin/default/acq.css	2010-02-09 21:55:26 UTC (rev 15486)
@@ -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; }

Modified: trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js
===================================================================
--- trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js	2010-02-09 20:38:27 UTC (rev 15485)
+++ trunk/Open-ILS/web/js/dojo/openils/acq/nls/acq.js	2010-02-09 21:55:26 UTC (rev 15486)
@@ -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."
 }

Modified: trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js	2010-02-09 20:38:27 UTC (rev 15485)
+++ trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js	2010-02-09 21:55:26 UTC (rev 15486)
@@ -35,6 +35,7 @@
     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 @@
     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 @@
         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 @@
         );
 
         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 @@
         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 @@
                 //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 @@
             }
         }
 
-        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 @@
                     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 @@
         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 @@
 
         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 @@
         }});
     }
 }
-
-
-

Modified: trunk/Open-ILS/web/js/ui/default/acq/picklist/view.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/picklist/view.js	2010-02-09 20:38:27 UTC (rev 15485)
+++ trunk/Open-ILS/web/js/ui/default/acq/picklist/view.js	2010-02-09 21:55:26 UTC (rev 15486)
@@ -80,8 +80,11 @@
             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');
+                }
             }
         }
     );

Modified: trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2	2010-02-09 20:38:27 UTC (rev 15485)
+++ trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2	2010-02-09 21:55:26 UTC (rev 15486)
@@ -170,7 +170,7 @@
         <div class='acq-lit-li-menu-bar'>
             <table style='width:100%'>
                 <tr>
-                    <td style='text-align:left;'>
+                    <td class="acq-lit-li-menu-left">
                         <div dojoType='dijit.form.Button' id='acq-lit-copies-back-button'>&#x2196; Return</div>
                         <span style='margin-left:10px;padding-left:10px;border-left:2px solid #aaa;'>
                             Item Count: 
@@ -179,13 +179,13 @@
                             <div dojoType='dijit.form.Button' jsId='acqLitAddCopyCount'>Go</div>
                         </span>
                     </td>
-                    <td style='text-align:right;'>
+                    <td class="acq-lit-li-menu-right">
+                        <span>
+                            <div dojoType='dijit.form.Button' jsId='acqLitSaveCopies'>Save Changes</div>
+                        </span>
                         <span id='acq-lit-update-copies-progress' class='hidden'>
                             <span dojoType="dijit.ProgressBar" style="width:300px" jsId="litUpdateCopiesProgress"></span>
                         </span>
-                        <span>
-                            <div dojoType='dijit.form.Button' jsId='acqLitSaveCopies'>Save Changes</div>
-                        </span>
                     </td>
                 </tr>
             </table>
@@ -214,7 +214,7 @@
                         <span>Distribution Formulas</span>
                         <div name='selector'></div>
                         <div name='set_button'></div>
-                        <div name='rel_button'></div>
+                        <div name="reset_button"></div>
                     </td>
                 </tr>
             </tbody>



More information about the open-ils-commits mailing list