From 8b29ad37260b5a068bcb37b257611d4dbbcdeec6 Mon Sep 17 00:00:00 2001 From: senator Date: Thu, 17 Jun 2010 18:45:16 +0000 Subject: [PATCH] Acq: Remove the "Selection Lists" entry from the staff client's menu The unified search interface now does everything that the Selection Lists interface could. Also, merging selection lists now updates the edit_time field on the lead list. git-svn-id: svn://svn.open-ils.org/ILS/trunk@16746 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../perlmods/OpenILS/Application/Acq/Order.pm | 13 +- .../web/js/ui/default/acq/search/invoice.js | 52 +++++ .../web/js/ui/default/acq/search/picklist.js | 188 ++++++++++++++++++ .../ui/default/acq/search/purchase_order.js | 7 + .../web/js/ui/default/acq/search/unified.js | 11 + .../templates/default/acq/search/unified.tt2 | 171 +++++++--------- .../chrome/content/main/menu_frame_menus.xul | 4 +- 7 files changed, 342 insertions(+), 104 deletions(-) create mode 100644 Open-ILS/web/js/ui/default/acq/search/invoice.js create mode 100644 Open-ILS/web/js/ui/default/acq/search/picklist.js create mode 100644 Open-ILS/web/js/ui/default/acq/search/purchase_order.js diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm index f47d44dbfd..02b6283adf 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Acq/Order.pm @@ -831,9 +831,13 @@ sub update_picklist { $picklist = $mgr->editor->retrieve_acq_picklist($picklist) unless ref $picklist; $picklist->edit_time('now'); $picklist->editor($mgr->editor->requestor->id); - $mgr->picklist($picklist); - return $picklist if $mgr->editor->update_acq_picklist($picklist); - return undef; + if ($mgr->editor->update_acq_picklist($picklist)) { + $picklist = $mgr->editor->retrieve_acq_picklist($mgr->editor->data); + $mgr->picklist($picklist); + return $picklist; + } else { + return undef; + } } sub delete_picklist { @@ -2085,6 +2089,7 @@ sub merge_picklist_api { # XXX perms on each picklist modified + $lead_pl = $e->retrieve_acq_picklist($lead_pl) or return $e->die_event; # point all of the lineitems at the lead picklist my $li_ids = $e->search_acq_lineitem({picklist => $pl_list}, {idlist => 1}); @@ -2101,6 +2106,8 @@ sub merge_picklist_api { $e->delete_acq_picklist($pl) or return $e->die_event; } + update_picklist($mgr, $lead_pl) or return $e->die_event; + $e->commit; return $mgr->respond_complete; } diff --git a/Open-ILS/web/js/ui/default/acq/search/invoice.js b/Open-ILS/web/js/ui/default/acq/search/invoice.js new file mode 100644 index 0000000000..02adfb28b2 --- /dev/null +++ b/Open-ILS/web/js/ui/default/acq/search/invoice.js @@ -0,0 +1,52 @@ +function getInvIdent(rowIndex, item) { + if (item) { + return { + "inv_ident": this.grid.store.getValue(item, "inv_ident") || + this.grid.store.getValue(item, "id"), + "id": this.grid.store.getValue(item, "id") + }; + } +} + +function formatInvIdent(inv) { + if (inv) { + return "" + inv.inv_ident + ""; + } +} + +function printInvoiceVouchers() { + var inv_ids = dijit.byId("acq-unified-inv-grid"). + getSelectedItems().map(function(o) {return o.id[0];}); + + /* XXX this business about opening a window and populating its + * body should be wrapped up in a simple dijit or something. + * consolidate with claim_voucher.js maybe. */ + if (inv_ids.length) { + var win = null; + fieldmapper.standardRequest( + ["open-ils.acq", "open-ils.acq.invoice.print.html"], { + "params": [openils.User.authtoken, inv_ids], + "async": true, + "onresponse": function(r) { + if (r = openils.Util.readResponse(r)) { + if (!win) { + win = window.open( + "", "", "resizable,width=800," + + "height=600,scrollbars=1" + ); + win.document.title = localeStrings.INVOICES; + win.document.body.innerHTML = + "\n"; + } + win.document.body.innerHTML += + r.template_output().data(); + } + }, + "oncomplete": function() { win.print(); } + } + ); + } +} diff --git a/Open-ILS/web/js/ui/default/acq/search/picklist.js b/Open-ILS/web/js/ui/default/acq/search/picklist.js new file mode 100644 index 0000000000..b21bc37cb8 --- /dev/null +++ b/Open-ILS/web/js/ui/default/acq/search/picklist.js @@ -0,0 +1,188 @@ +dojo.require("dojo.data.ItemFileWriteStore"); +dojo.require("dijit.Dialog"); +dojo.require("dijit.form.Button"); +dojo.require("dijit.form.TextBox"); +dojo.require("dijit.form.FilteringSelect"); +dojo.require("dijit.form.Button"); +dojo.require("dojox.grid.cells.dijit"); +dojo.require("openils.acq.Picklist"); +dojo.require("openils.widget.ProgressDialog"); + +function getPlOwnerName(rowIndex, item) { + try { + return resultManager.plCache[this.grid.store.getValue(item, "id")]. + owner().usrname(); + } catch (E) { + return ""; + } +} + +function formatPlName(pl) { + if (pl) { + return "" + pl.name + ""; + } +} + +function deleteSelectedPl() { + var grid = resultManager.result_types.picklist.interface; + + progressDialog.show(true); + + openils.acq.Picklist.deleteList( + grid.getSelectedItems().map( + function(item) { + var id = grid.store.getValue(item, "id"); + grid.store.deleteItem(item); + return id; + } + ), function() { progressDialog.hide(); } + ); +} + +function cloneSelectedPl(fields) { + var grid = resultManager.result_types.picklist.interface; + + var item = grid.getSelectedItems()[0]; + if (!item) return; + + var plId = grid.store.getValue(item, "id"); + var entryCount = Number(grid.store.getValue(item, "entry_count")); + + progressDialog.show(); + progressDialog.update({"maximum": entryCount, "progress": 0}); + + fieldmapper.standardRequest( + ["open-ils.acq", "open-ils.acq.picklist.clone"], { + "async": true, + "params": [openils.User.authtoken, plId, fields.name], + "onresponse": function(r) { + var resp = openils.Util.readResponse(r); + if (resp) { + progressDialog.update({"progress": resp.li}); + + if (resp.complete) { + progressDialog.hide(); + var pl = resp.picklist; + pl.owner(openils.User.user); + pl.entry_count(entryCount); + resultManager.plCache[pl.id()] = pl; + grid.store.newItem(fieldmapper.acqpl.toStoreItem(pl)); + } + } + } + } + ); +} + +function loadLeadPlSelector() { + var grid = resultManager.result_types.picklist.interface; + var data = acqpl.initStoreData(); + var store = new dojo.data.ItemFileWriteStore({"data": data}); + + grid.getSelectedItems().forEach( + function(item) { + store.newItem( + fieldmapper.acqpl.toStoreItem( + resultManager.plCache[grid.store.getValue(item, "id")] + ) + ); + } + ); + + plMergeLeadSelector.store = store; + plMergeLeadSelector.startup(); +} + +function mergeSelectedPl(fields) { + var grid = resultManager.result_types.picklist.interface; + + if (!fields.lead) return; + + var ids = []; + var totalLi = 0; + var leadPl = resultManager.plCache[fields.lead]; + var leadPlItem; + + grid.getSelectedItems().forEach( + function(item) { + var id = grid.store.getValue(item, "id"); + if (id == fields.lead) { + leadPlItem = item; + return; + } + totalLi += new Number(grid.store.getValue(item, "entry_count")); + ids.push(id); + } + ); + + progressDialog.show(); + progressDialog.update({"maximum": totalLi, "progress": 0}); + + fieldmapper.standardRequest( + ["open-ils.acq", "open-ils.acq.picklist.merge"], { + "async": true, + "params": [openils.User.authtoken, fields.lead, ids], + "onresponse": function(r) { + var resp = openils.Util.readResponse(r); + if (resp) { + if (resp.li) + progressDialog.update({"progress": resp.li}); + + if (resp.complete) { + progressDialog.hide(); + leadPl.entry_count(leadPl.entry_count() + totalLi); + + grid.store.setValue( + leadPlItem, "entry_count", leadPl.entry_count() + ); + if (resp.picklist) { + grid.store.setValue( + leadPlItem, "edit_time", + resp.picklist.edit_time() + ); + } + + // remove the deleted lists from the grid + grid.getSelectedItems().filter( + function(o) { + return grid.store.getValue(o, "id") != + fields.lead; + } + ).forEach(function(o) { grid.store.deleteItem(o); }); + } + } + } + } + ); +} + +function createPl(fields) { + if (fields.name == '') return; + + var grid = resultManager.result_types.picklist.interface; + + openils.acq.Picklist.create(fields, + function(plId) { + fieldmapper.standardRequest( + ["open-ils.acq", "open-ils.acq.picklist.retrieve"], { + "async": true, + "params": [ + openils.User.authtoken, plId, + {"flesh_lineitem_count": 1, "flesh_owner": 1} + ], + "oncomplete": function(r) { + var pl = openils.Util.readResponse(r); + if (pl) { + resultManager.plCache[pl.id()] = pl; + grid.store.newItem( + acqpl.toStoreData([pl]).items[0] + ); + } + } + } + ); + } + ); +} + diff --git a/Open-ILS/web/js/ui/default/acq/search/purchase_order.js b/Open-ILS/web/js/ui/default/acq/search/purchase_order.js new file mode 100644 index 0000000000..d33b6c5d1a --- /dev/null +++ b/Open-ILS/web/js/ui/default/acq/search/purchase_order.js @@ -0,0 +1,7 @@ + function formatPoName(po) { + if (po) { + return "" + po.name + ""; + } + } + diff --git a/Open-ILS/web/js/ui/default/acq/search/unified.js b/Open-ILS/web/js/ui/default/acq/search/unified.js index b0d92085bc..87563399c2 100644 --- a/Open-ILS/web/js/ui/default/acq/search/unified.js +++ b/Open-ILS/web/js/ui/default/acq/search/unified.js @@ -27,6 +27,17 @@ HTMLSelectElement.prototype.setValue = function(s) { } } +/* minor formatting function used by autogrids in unified.tt2 */ +function getName(rowIndex, item) { + if (item) { + return { + "name": this.grid.store.getValue(item, "name") || + localeStrings.UNNAMED, + "id": this.grid.store.getValue(item, "id") + }; + } +} + /* quickly find elements by the value of a "name" attribute */ function nodeByName(name, root) { return dojo.query("[name='" + name + "']", root)[0]; diff --git a/Open-ILS/web/templates/default/acq/search/unified.tt2 b/Open-ILS/web/templates/default/acq/search/unified.tt2 index 08ca0f3503..97f09cf6b7 100644 --- a/Open-ILS/web/templates/default/acq/search/unified.tt2 +++ b/Open-ILS/web/templates/default/acq/search/unified.tt2 @@ -1,103 +1,10 @@ [% WRAPPER "default/base.tt2" %] [% ctx.page_title = "Acquisitions Search" %] - - - - + + + + +