From feec091d7810c1c4980900bf734ca6e85cc3cf49 Mon Sep 17 00:00:00 2001 From: senator Date: Wed, 17 Feb 2010 14:33:11 +0000 Subject: [PATCH] Acq: more LI search interface improvements 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 --- .../perlmods/OpenILS/Application/Acq/Lineitem.pm | 6 ++- Open-ILS/web/css/skin/default/acq.css | 1 + Open-ILS/web/js/dojo/openils/acq/nls/acq.js | 6 +-- Open-ILS/web/js/ui/default/acq/common/li_table.js | 54 ++++++++++++++++------ Open-ILS/web/js/ui/default/acq/lineitem/search.js | 3 +- .../web/templates/default/acq/common/li_table.tt2 | 6 ++- 6 files changed, 56 insertions(+), 20 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm index 499fb14d68..f0256195eb 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Lineitem.pm @@ -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" + } } } } diff --git a/Open-ILS/web/css/skin/default/acq.css b/Open-ILS/web/css/skin/default/acq.css index 78f6a112ae..6b00a986e7 100644 --- a/Open-ILS/web/css/skin/default/acq.css +++ b/Open-ILS/web/css/skin/default/acq.css @@ -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;} 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 f3f903ff2a..5db9e14615 100644 --- a/Open-ILS/web/js/dojo/openils/acq/nls/acq.js +++ b/Open-ILS/web/js/dojo/openils/acq/nls/acq.js @@ -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." } 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 b605fecff8..9213115c13 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 @@ -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() { diff --git a/Open-ILS/web/js/ui/default/acq/lineitem/search.js b/Open-ILS/web/js/ui/default/acq/lineitem/search.js index e1aedf86ca..5c7405e65e 100644 --- a/Open-ILS/web/js/ui/default/acq/lineitem/search.js +++ b/Open-ILS/web/js/ui/default/acq/lineitem/search.js @@ -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}) ) }); } 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 5b8fceff10..f01d90fd72 100644 --- a/Open-ILS/web/templates/default/acq/common/li_table.tt2 +++ b/Open-ILS/web/templates/default/acq/common/li_table.tt2 @@ -18,7 +18,7 @@ - + @@ -26,6 +26,10 @@ +