[open-ils-commits] r12724 - in trunk/Open-ILS/web: js/ui/default/acq/common js/ui/default/acq/picklist templates/default/acq/common templates/default/acq/picklist (erickson)

svn at svn.open-ils.org svn at svn.open-ils.org
Mon Mar 30 18:51:15 EDT 2009


Author: erickson
Date: 2009-03-30 18:51:15 -0400 (Mon, 30 Mar 2009)
New Revision: 12724

Modified:
   trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js
   trunk/Open-ILS/web/js/ui/default/acq/picklist/bib_search.js
   trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2
   trunk/Open-ILS/web/templates/default/acq/picklist/bib_search.tt2
Log:
move the select list creation actoin in with the rest of the linietem actions (dropdown)

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	2009-03-30 22:49:37 UTC (rev 12723)
+++ trunk/Open-ILS/web/js/ui/default/acq/common/li_table.js	2009-03-30 22:51:15 UTC (rev 12724)
@@ -6,6 +6,7 @@
 dojo.require('openils.Util');
 dojo.require('openils.acq.Lineitem');
 dojo.require('openils.acq.PO');
+dojo.require('openils.acq.Picklist');
 dojo.require('openils.widget.AutoFieldWidget');
 dojo.require('dojo.data.ItemFileReadStore');
 
@@ -22,6 +23,7 @@
     this.copyRow = this.copyTbody.removeChild(dojo.byId('acq-lit-li-details-row'));
     this.copyBatchRow = dojo.byId('acq-lit-li-details-batch-row');
     this.copyBatchWidgets = {};
+
     dojo.connect(acqLitLiActionsSelector, 'onChange', 
         function() { 
             self.applySelectedLiAction(this.attr('value')) 
@@ -33,6 +35,11 @@
         self._createPO(acqLitPoCreateDialog.getValues());
     }
 
+    acqLitSavePlButton.onClick = function() {
+        acqLitSavePlDialog.hide();
+        self._savePl(acqLitSavePlDialog.getValues());
+    }
+
     dojo.byId('acq-lit-select-toggle').onclick = function(){self.toggleSelect()};
     dojo.byId('acq-lit-info-back-button').onclick = function(){self.show('list')};
     dojo.byId('acq-lit-copies-back-button').onclick = function(){self.show('list')};
@@ -340,11 +347,14 @@
                     orgLimitPerms : ['CREATE_PICKLIST'],
                     readOnly : self.isPO
                 });
-                widget.build();
+                widget.build(
+                    // make sure we capture the value from any async widgets
+                    function(w, ww) { copy[field](ww.getFormattedValue()) }
+                );
                 dojo.connect(widget.widget, 'onChange', 
                     function(val) { 
-                        if(val != copy[field]()) {
-                            // prevent setting ischanged() automatically on widget load
+                        if(copy.isnew() || val != copy[field]()) {
+                            // prevent setting ischanged() automatically on widget load for existing copies
                             copy[field](widget.getFormattedValue()) 
                             copy.ischanged(true);
                         }
@@ -406,9 +416,11 @@
     this.applySelectedLiAction = function(action) {
         var self = this;
         switch(action) {
+
             case 'delete_selected':
                 this._deleteLiList(self.getSelected());
                 break;
+
             case 'create_order':
 
                 if(!this.createPoProviderSelector) {
@@ -425,6 +437,11 @@
          
                 acqLitPoCreateDialog.show();
                 break;
+
+            case 'save_picklist':
+                this._loadPLSelect();
+                acqLitSavePlDialog.show();
+                break;
         }
     }
 
@@ -509,6 +526,65 @@
             }
         };
     }
+
+
+    this._savePl = function(values) {
+        var self = this;
+        var selected = this.getSelected( (values.which == 'all') );
+        openils.Util.show('acq-lit-generic-progress');
+
+        if(values.new_name) {
+            openils.acq.Picklist.create(
+                {name: values.new_name}, 
+                function(id) {
+                    self._updateLiList(id, selected, 0, 
+                        function(){
+                            location.href = oilsBasePath + '/eg/acq/picklist/view/' + id;
+                        });
+                }
+            );
+        } else if(values.existing_pl) {
+            // update lineitems to use an existing picklist
+            self._updateLiList(values.existing_pl, selected, 0, 
+                function(){
+                    location.href = oilsBasePath + '/eg/acq/picklist/view/' + values.existing_pl;
+                });
+        }
+    }
+
+    this._updateLiList = function(pl, list, idx, oncomplete) {
+        if(idx >= list.length) return oncomplete();
+        var li = list[idx];
+        li.picklist(pl);
+        litGenericProgress.update({maximum: list.length, progress: idx});
+        new openils.acq.Lineitem({lineitem:li}).update(
+            function(r) {
+                self._updateLiList(pl, list, ++idx, oncomplete);
+            }
+        );
+    }
+
+    this._loadPLSelect = function() {
+        if(this._plSelectLoaded) return;
+        var plList = [];
+        function handleResponse(r) {
+            plList.push(r.recv().content());
+        }
+        var method = 'open-ils.acq.picklist.user.retrieve';
+        fieldmapper.standardRequest(
+            ['open-ils.acq', method],
+            {   async: true,
+                params: [this.authtoken],
+                onresponse: handleResponse,
+                oncomplete: function() {
+                    self._plSelectLoaded = true;
+                    acqLitAddExistingSelect.store = 
+                        new dojo.data.ItemFileReadStore({data:acqpl.toStoreData(plList)});
+                    acqLitAddExistingSelect.setValue();
+                }
+            }
+        );
+    }
 }
 
 

Modified: trunk/Open-ILS/web/js/ui/default/acq/picklist/bib_search.js
===================================================================
--- trunk/Open-ILS/web/js/ui/default/acq/picklist/bib_search.js	2009-03-30 22:49:37 UTC (rev 12723)
+++ trunk/Open-ILS/web/js/ui/default/acq/picklist/bib_search.js	2009-03-30 22:51:15 UTC (rev 12724)
@@ -148,72 +148,7 @@
     dojo.style(div, 'display', 'block');
 }
 
-function loadPLSelect() {
-    var plList = [];
-    function handleResponse(r) {
-        plList.push(r.recv().content());
-    }
-    var method = 'open-ils.acq.picklist.user.retrieve';
-    fieldmapper.standardRequest(
-        ['open-ils.acq', method],
-        {   async: true,
-            params: [openils.User.authtoken],
-            onresponse: handleResponse,
-            oncomplete: function() {
-                plAddExistingSelect.store = 
-                    new dojo.data.ItemFileReadStore({data:acqpl.toStoreData(plList)});
-                plAddExistingSelect.setValue();
-            }
-        }
-    );
-}
 
-
-function saveResults(values) {
-    openils.Util.show('oils-acq-update-li-progress');
-    selectedLIs = liTable.getSelected( (values.which == 'all') );
-
-    if(values.new_name && values.new_name != '') {
-        // save selected lineitems to a new picklist
-        if(values.which = 'selected') {
-            openils.acq.Picklist.create(
-                {name: values.new_name}, 
-                function(id) {
-                    updateLiList(id, selectedLIs, 0, 
-                        function(){location.href = 'view/' + id});
-                }
-            );
-        }  else {
-            // save all == change the name of the results picklist
-            resultPicklist.name(values.new_name); 
-            openils.acq.Picklist.update(resultPicklist,
-                function(stat) {
-                    location.href = 'view/' + resultPicklist.id(); 
-                }
-            );
-        }
-    } else if(values.existing_pl) {
-        // update lineitems to use an existing picklist
-        updateLiList(values.existing_pl, selectedLIs, 0, 
-            function(){location.href = 'view/' + values.existing_pl});
-    }
-}
-
-function updateLiList(pl, list, idx, oncomplete) {
-    if(idx >= list.length) {
-        openils.Util.hide('oils-acq-update-li-progress');
-        return oncomplete();
-    }
-    var li = selectedLIs[idx];
-    li.picklist(pl);
-    liUpdateProgress.update({maximum: list.length, progress: idx});
-    new openils.acq.Lineitem({lineitem:li}).update(
-        function(r) {
-            updateLiList(pl, list, ++idx, oncomplete);
-        }
-    );
-}
-
 openils.Util.addOnLoad(drawForm);
 
 

Modified: trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2	2009-03-30 22:49:37 UTC (rev 12723)
+++ trunk/Open-ILS/web/templates/default/acq/common/li_table.tt2	2009-03-30 22:51:15 UTC (rev 12724)
@@ -14,12 +14,16 @@
                                         <select dojoType='dijit.form.FilteringSelect' value='_' jsId='acqLitLiActionsSelector'>
                                             <option value='_'>--Actions--</option>
                                             <option value='delete_selected'>Delete Selected Items</option>
+                                            <option value='save_picklist'>Save Items To Selection List</option>
                                             <option value='selector_ready'>Mark Ready for Selector</option>
                                             <option value='order_ready'>Mark Ready for Order</option>
                                             <option value='create_order'>Create Purchase Order</option>
                                             <option value='print_po'>Print Purchase Order</option>
                                         </select>
                                     </span>
+                                    <span id='acq-lit-generic-progress' class='hidden'>
+                                        <span dojoType="dijit.ProgressBar" style="width:300px" jsId="litGenericProgress"></span>
+                                    </span>
                                 </td>
                                 <td>
                                     <div style='width:100%;text-align:right;'>
@@ -218,5 +222,35 @@
         </div>
     </div>
 
+    <div dojoType="dijit.Dialog" jsId='acqLitSavePlDialog'>
+        <table class='dijitTooltipTable'>
+            <tr>
+                <td colspan='2'>
+                    <input dojoType="dijit.form.RadioButton" name="which" type='radio' checked='checked' value='selected'/>
+                    <label for="name">Save selected</label>
+                    <input dojoType="dijit.form.RadioButton" name="which" type='radio' value='all'/>
+                    <label for="name">Save all</label>
+                </td>
+            </tr>
+            <tr><td colspan='2'><hr/></td></tr>
+            <tr>
+                <td><label for="new_name">Save as Selection List: </label></td>
+                <td><input dojoType="dijit.form.TextBox" name="new_name"/></td>
+            </tr>
+            <tr>
+                <td><label for="existing_pl">Add to Selection List: </label></td>
+                <td>
+                    <input jsId='acqLitAddExistingSelect' dojoType="dijit.form.FilteringSelect" 
+                        name="existing_pl" searchAttr='name' displayAttr='name'/>
+                </td>
+            </tr>
+            <tr>
+                <td colspan='2' align='center'>
+                    <button dojoType='dijit.form.Button' type="submit" jsId='acqLitSavePlButton'>Save</button>
+                </td>
+            </tr>
+        </table>
+    </div>
+
 </div>
 

Modified: trunk/Open-ILS/web/templates/default/acq/picklist/bib_search.tt2
===================================================================
--- trunk/Open-ILS/web/templates/default/acq/picklist/bib_search.tt2	2009-03-30 22:49:37 UTC (rev 12723)
+++ trunk/Open-ILS/web/templates/default/acq/picklist/bib_search.tt2	2009-03-30 22:51:15 UTC (rev 12724)
@@ -58,41 +58,6 @@
                 <div dojoType="dijit.ProgressBar" style="width:300px" jsId="liUpdateProgress"></div>
             </div>
             <div dojoType='dijit.form.Button' onClick='showDiv("oils-acq-search-block");'>New Search</div>
-            <div dojoType="dijit.form.DropDownButton">
-                <span>Save Results</span>
-                <div dojoType="dijit.TooltipDialog" execute="saveResults(arguments[0]);">
-                    <script type='dojo/connect' event='onOpen'>
-                        loadPLSelect(); 
-                    </script>
-                    <table class='dijitTooltipTable'>
-                        <tr>
-                            <td colspan='2'>
-                                <input dojoType="dijit.form.RadioButton" name="which" type='radio' checked='checked' value='selected'/>
-                                <label for="name">Save selected</label>
-                                <input dojoType="dijit.form.RadioButton" name="which" type='radio' value='all'/>
-                                <label for="name">Save all</label>
-                            </td>
-                        </tr>
-                        <tr><td colspan='2'><hr/></td></tr>
-                        <tr>
-                            <td><label for="new_name">Save as Selection List: </label></td>
-                            <td><input dojoType="dijit.form.TextBox" name="new_name"/></td>
-                        </tr>
-                        <tr>
-                            <td><label for="existing_pl">Add to Selection List: </label></td>
-                            <td>
-                                <input jsId='plAddExistingSelect' dojoType="dijit.form.FilteringSelect" 
-                                    name="existing_pl" searchAttr='name' displayAttr='name'/>
-                            </td>
-                        </tr>
-                        <tr>
-                            <td colspan='2' align='center'>
-                                <button dojoType='dijit.form.Button' type="submit">Save</button>
-                            </td>
-                        </tr>
-                    </table>
-                </div>
-            </div> 
         </div>
     </div>
     <div dojoType='dijit.layout.ContentPane' layoutAlign='client'>



More information about the open-ils-commits mailing list