Acq: more LI search interface improvements
authorsenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 17 Feb 2010 14:33:11 +0000 (14:33 +0000)
committersenator <senator@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Wed, 17 Feb 2010 14:33:11 +0000 (14:33 +0000)
Another bug fixed that made LI searches sometimes not find LIs that
    didn't belong to a PO already

Generalized the ISBN export feature in the LI table to be an exporter of
    more attributes.

git-svn-id: svn://svn.open-ils.org/ILS/trunk@15564 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm
Open-ILS/web/css/skin/default/acq.css
Open-ILS/web/js/dojo/openils/acq/nls/acq.js
Open-ILS/web/js/ui/default/acq/common/li_table.js
Open-ILS/web/js/ui/default/acq/lineitem/search.js
Open-ILS/web/templates/default/acq/common/li_table.tt2

index 499fb14..f025619 100644 (file)
@@ -320,7 +320,11 @@ sub lineitem_search_by_attributes {
                     "field" => "id",
                     "fkey" => "lineitem",
                     "join" => {
-                        "acqpo" => {"field" => "id", "fkey" => "purchase_order"}
+                        "acqpo" => {
+                            "type" => "left",
+                            "field" => "id",
+                            "fkey" => "purchase_order"
+                        }
                     }
                 }
             }
index 78f6a11..6b00a98 100644 (file)
@@ -136,6 +136,7 @@ label[for="attr_search_type_scalar"] { vertical-align: top; }
 #acq-lit-li-details-table th {padding:0px 3px 1px 3px; font-weight:bold;}
 #acq-lit-li-details-table .dijit {width:130px;}
 #acq-lit-li-details-table td input {width:100px;}
+#acq-lit-export-attr { margin-left: 10px; }
 .acq-lit-note-textarea { border-right: 2px solid #aaa; width:50%;}
 .acq-lit-note-textarea div { padding: 4px; font-weight: bold; }
 #acq-lit-notes-tbody td {padding: 20px 10px 20px 10px; border-bottom:2px solid #aaa;}
index f3f903f..5db9e14 100644 (file)
@@ -15,7 +15,7 @@
     'LI_ATTR_SEARCH_TOO_LARGE': "That file is too large for this operation.",
     'SELECT_AN_LI_ATTRIBUTE': "You must select an LI attribute.",
     'NO_RESULTS': "No results.",
-    'ISBN_SAVE_DIALOG_TITLE': "Save ISBNs to a file",
-    'ISBN_SHORT_LIST': "Not all of the selected items had ISBNs.\nChoose OK to save the ISBNs that could be found.",
-    'ISBN_EMPTY_LIST': "No ISBNs found."
+    'EXPORT_SAVE_DIALOG_TITLE': "Save field values to a file",
+    'EXPORT_SHORT_LIST': "Not all of the selected items had the attribute '${0}'.\nChoose OK to save those values that could be found.",
+    'EXPORT_EMPTY_LIST': "No values for attribute '${0}' found."
 }
index b605fec..9213115 100644 (file)
@@ -19,6 +19,7 @@ dojo.require('openils.XUL');
 dojo.requireLocalization('openils.acq', 'acq');
 var localeStrings = dojo.i18n.getLocalization('openils.acq', 'acq');
 const XUL_OPAC_WRAPPER = 'chrome://open_ils_staff_client/content/cat/opac.xul';
+var li_exportable_attrs = ["issn", "isbn", "upc"];
 
 function nodeByName(name, context) {
     return dojo.query('[name='+name+']', context)[0];
@@ -1024,8 +1025,8 @@ function AcqLiTable() {
                 this.createAssets();
                 break;
 
-            case 'export_isbn_list':
-                this.exportISBNList();
+            case 'export_attr_list':
+                this.chooseExportAttr();
                 break;
 
             case 'add_brief_record':
@@ -1053,34 +1054,61 @@ function AcqLiTable() {
         );
     }
 
-    /* Should really think about generalizing this to do more than ISBN #s */
-    this.exportISBNList = function() {
-        var selected = this.getSelected();
-        var isbn_list = selected.map(
+    this.chooseExportAttr = function() {
+        if (!acqLitExportAttrSelector._li_setup) {
+            var self = this;
+            acqLitExportAttrSelector.store = new dojo.data.ItemFileReadStore(
+                {
+                    "data": acqliad.toStoreData(
+                        (new openils.PermaCrud()).search(
+                            "acqliad", {"code": li_exportable_attrs}
+                        )
+                    )
+                }
+            );
+            acqLitExportAttrSelector.setValue();
+            acqLitExportAttrButton.onClick = function(){self.exportAttrList();};
+            acqLitExportAttrSelector._li_setup = true;
+        }
+        openils.Util.show("acq-lit-export-attr-holder", "inline");
+    };
+
+    this.exportAttrList = function() {
+        var attr_def = acqLitExportAttrSelector.item;
+        var li_list = this.getSelected();
+        var value_list = li_list.map(
             function(li) {
                 return (new openils.acq.Lineitem({"lineitem": li})).findAttr(
-                    "isbn", "lineitem_marc_attr_definition"
+                    attr_def.code, "lineitem_marc_attr_definition"
                 );
             }
         ).filter(function(attr) { return Boolean(attr); });
 
-        if (isbn_list.length > 0) {
-            if (isbn_list.length < selected.length) {
-                if (!confirm(localeStrings.ISBN_SHORT_LIST)) {
+        if (value_list.length > 0) {
+            if (value_list.length < li_list.length) {
+                if (!confirm(
+                    dojo.string.substitute(
+                        localeStrings.EXPORT_SHORT_LIST, [attr_def.description]
+                    )
+                )) {
                     return;
                 }
             }
             try {
                 openils.XUL.contentToFileSaveDialog(
-                    isbn_list.join("\n"),
-                    localeStrings.ISBN_SAVE_DIALOG_TITLE
+                    value_list.join("\n"),
+                    localeStrings.EXPORT_SAVE_DIALOG_TITLE
                 );
             } catch (E) {
                 alert(E);
             }
         } else {
-            alert(localeStrings.ISBN_EMPTY_LIST);
+            alert(dojo.string.substitute(
+                localeStrings.EXPORT_EMPTY_LIST, [attr_def.description]
+            ));
         }
+
+        openils.Util.hide("acq-lit-export-attr-holder");
     };
 
     this.printPO = function() {
index e1aedf8..5c7405e 100644 (file)
@@ -10,7 +10,6 @@ dojo.require("openils.PermaCrud");
 dojo.require("openils.XUL");
 dojo.require("openils.widget.AutoFieldWidget");
 
-var _searchable_by_array = ["issn", "isbn", "upc"];
 var combinedAttrValueArray = [];
 var scalarAttrSearchManager;
 var liTable;
@@ -36,7 +35,7 @@ function prepareScalarSearchStore(pcrud) {
 function prepareArraySearchStore(pcrud) {
     attrArrayDefSelector.store = new dojo.data.ItemFileReadStore({
         "data": acqliad.toStoreData(
-            pcrud.search("acqliad", {"code": _searchable_by_array})
+            pcrud.search("acqliad", {"code": li_exportable_attrs})
         )
     });
 }
index 5b8fcef..f01d90f 100644 (file)
@@ -18,7 +18,7 @@
                                             <option mask='pl' value='order_ready'>Mark Ready for Order</option>
                                             <option mask='*'  value='delete_selected'>Delete Selected Items</option>
                                             <option mask='*'  value='add_brief_record'>Add Brief Record</option>
-                                            <option mask='*'  value='export_isbn_list'>Export ISBN List</option>
+                                            <option mask='*'  value='export_attr_list'>Export Single Attribute List</option>
                                             <option mask='po' value='' disabled='disabled'>----PO----</option>
                                             <option mask='sr|pl' value='create_order'>Create Purchase Order</option>
                                             <option mask='po' value='create_assets'>Load Bibs and Items</option>
                                             <option mask='po' value='rollback_receive_po'>Un-Receive Purchase Order</option>
                                             <option mask='po' value='print_po'>Print Purchase Order</option>
                                         </select>
+                                        <span id="acq-lit-export-attr-holder" class="hidden">
+                                            <input dojoType="dijit.form.FilteringSelect" id="acq-lit-export-attr" jsId="acqLitExportAttrSelector" labelAttr="description" searchAttr="description" />
+                                            <span dojoType="dijit.form.Button" jsId="acqLitExportAttrButton">Export List</span>
+                                        </span>
                                     </span>
                                     <span id='acq-lit-generic-progress' class='hidden'>
                                         <span dojoType="dijit.ProgressBar" style="width:300px" jsId="litGenericProgress"></span>