From 8f265e723ef800ef9aa5966144ddfd95e921b897 Mon Sep 17 00:00:00 2001 From: senator Date: Thu, 8 Jul 2010 15:11:24 +0000 Subject: [PATCH] Acq: If you go from a catalog record to "View/Place orders", there are now easy shortcuts for adding a new lineitem to a selection list or a PO if there aren't already any existing lineitems to work with. git-svn-id: svn://svn.open-ils.org/ILS/trunk@16881 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/ui/default/acq/common/li_table.js | 72 +++++++------- Open-ILS/web/js/ui/default/acq/lineitem/related.js | 110 ++++++++++----------- .../web/templates/default/acq/lineitem/related.tt2 | 25 ++--- 3 files changed, 94 insertions(+), 113 deletions(-) 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 c21e0a79b..040e0e88c 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 @@ -1838,41 +1838,7 @@ function AcqLiTable() { break; case 'create_order': - - if(!this.createPoProviderSelector) { - var widget = new openils.widget.AutoFieldWidget({ - fmField : 'provider', - fmClass : 'acqpo', - searchFilter: {"active": "t"}, - parentNode : dojo.byId('acq-lit-po-provider'), - dijitArgs : { - "onChange": function() { - if (this.item) { - self._updateCreatePoPrepayCheckbox( - this.item.prepayment_required - ); - } - } - } - }); - widget.build( - function(w) { self.createPoProviderSelector = w; } - ); - } - - if(!this.createPoAgencySelector) { - var widget = new openils.widget.AutoFieldWidget({ - fmField : 'ordering_agency', - fmClass : 'acqpo', - parentNode : dojo.byId('acq-lit-po-agency'), - orgLimitPerms : ['CREATE_PURCHASE_ORDER'], - }); - widget.build( - function(w) { self.createPoAgencySelector = w; } - ); - } - - + this._loadPOSelect(); acqLitPoCreateDialog.show(); break; @@ -2408,7 +2374,38 @@ function AcqLiTable() { ); } - this._loadPLSelect = function() { + this._loadPOSelect = function() { + if (!this.createPoProviderSelector) { + var widget = new openils.widget.AutoFieldWidget({ + "fmField": "provider", + "fmClass": "acqpo", + "searchFilter": {"active": "t"}, + "parentNode": dojo.byId("acq-lit-po-provider"), + "dijitArgs": { + "onChange": function() { + if (this.item) { + self._updateCreatePoPrepayCheckbox( + this.item.prepayment_required + ); + } + } + } + }); + widget.build(function(w) { self.createPoProviderSelector = w; }); + } + + if (!this.createPoAgencySelector) { + var widget = new openils.widget.AutoFieldWidget({ + "fmField": "ordering_agency", + "fmClass": "acqpo", + "parentNode": dojo.byId("acq-lit-po-agency"), + "orgLimitPerms": ["CREATE_PURCHASE_ORDER"], + }); + widget.build(function(w) { self.createPoAgencySelector = w; }); + } + }; + + this._loadPLSelect = function(preSel) { if(this._plSelectLoaded) return; var plList = []; function handleResponse(r) { @@ -2424,7 +2421,8 @@ function AcqLiTable() { self._plSelectLoaded = true; acqLitAddExistingSelect.store = new dojo.data.ItemFileReadStore({data:acqpl.toStoreData(plList)}); - acqLitAddExistingSelect.setValue(); + + acqLitAddExistingSelect.setValue(preSel); } } ); diff --git a/Open-ILS/web/js/ui/default/acq/lineitem/related.js b/Open-ILS/web/js/ui/default/acq/lineitem/related.js index 5e58b9aa3..9adbc8e48 100644 --- a/Open-ILS/web/js/ui/default/acq/lineitem/related.js +++ b/Open-ILS/web/js/ui/default/acq/lineitem/related.js @@ -35,6 +35,7 @@ function fetchRelated() { if(identTarget == 'bib') var method = 'open-ils.acq.lineitems_for_bib.by_bib_id'; + var total = 0; fieldmapper.standardRequest( ["open-ils.acq", method], { "async": true, @@ -46,9 +47,14 @@ function fetchRelated() { "onresponse": function(r) { var resp = openils.Util.readResponse(r); if (resp) { + total++; liTable.show("list"); liTable.addLineitem(resp); } + }, + "oncomplete": function() { + if (!total) + openils.Util.show("li_create_holder"); } } ); @@ -69,78 +75,63 @@ function fetchBib() { }) } -function addLi(fields) { - - var li = new fieldmapper.jub(); - li.marc(bibRecord.marc()); - li.eg_bib_id(bibRecord.id()); - if(fields.picklist) li.picklist(fields.picklist); - if(fields.po) li.po(fields.po); - li.selector(openils.User.user.id()); - li.creator(openils.User.user.id()); - li.editor(openils.User.user.id()); - - fieldmapper.standardRequest( - ['open-ils.acq', 'open-ils.acq.lineitem.create'], - { async : true, - params : [openils.User.authtoken, li], - oncomplete : function(r) { - var id = openils.Util.readResponse(r); - if(!id) return; - if(fields.picklist) - location.href = oilsBasePath + '/acq/picklist/view/' + fields.picklist; - else - location.href = oilsBasePath + '/acq/po/view/' + fields.po; - } - } - ); -} - -function loadPl() { - - if(paramPL) { - - fieldmapper.standardRequest( - ['open-ils.acq', 'open-ils.acq.picklist.retrieve'], - { async: true, - params: [openils.User.authtoken, paramPL], - oncomplete : function(r) { - var pl = openils.Util.readResponse(r); - plSelector.store = - new dojo.data.ItemFileReadStore({data:fieldmapper.acqpl.toStoreData([pl])}); - plSelector.attr('value', pl.name()); - plSelector.attr('disabled', true); - } - } - ); - - } else { - +function createLi(oncomplete) { + return function() { + progressDialog.show(); + liTable.reset(); fieldmapper.standardRequest( - ['open-ils.acq', 'open-ils.acq.picklist.user.retrieve.atomic'], - { async: true, - params: [openils.User.authtoken], - oncomplete : function(r) { - var list = openils.Util.readResponse(r); - plSelector.store = - new dojo.data.ItemFileReadStore({data:fieldmapper.acqpl.toStoreData(list)}); + ["open-ils.acq", "open-ils.acq.biblio.create_by_id"], { + "params": [ + openils.User.authtoken, [bibRecord.id()], { + "flesh_attrs": true, + "flesh_cancel_reason": true, + "flesh_notes": true + } + ], + "async": true, + "onresponse": function(r) { + var li = openils.Util.readResponse(r); + if (typeof(li) == "object") { + liTable.show("list"); + liTable.addLineitem(li); + dojo.query( + "input[name='selectbox']", liTable._findLiRow(li) + )[0].checked = true; + } + }, + "oncomplete": function() { + progressDialog.hide(); + openils.Util.hide("li_create_holder"); + oncomplete(); } } ); - } + }; } +function prepareButtons() { + addToPlButton.onClick = createLi( + function() { /* oncomplete */ + liTable._loadPLSelect(paramPL); + acqLitSavePlDialog.show(); + } + ); + createPoButton.onClick = createLi( + function() { /* oncomplete */ + liTable._loadPOSelect(); + acqLitPoCreateDialog.show(); + } + ); +} function load() { var cgi = new openils.CGI(); identTarget = cgi.param('target'); paramPL = cgi.param('pl'); - paramPO = cgi.param('po'); - - loadPl(); +// paramPO = cgi.param('po'); - if(identTarget == 'bib') { + if (identTarget == 'bib') { fetchBib(); } else { fetchLi(); @@ -150,6 +141,7 @@ function load() { liTable.reset(); liTable._isRelatedViewer = true; + prepareButtons(); fetchRelated(); } diff --git a/Open-ILS/web/templates/default/acq/lineitem/related.tt2 b/Open-ILS/web/templates/default/acq/lineitem/related.tt2 index ec2eaf1f0..27d00e1e5 100644 --- a/Open-ILS/web/templates/default/acq/lineitem/related.tt2 +++ b/Open-ILS/web/templates/default/acq/lineitem/related.tt2 @@ -38,23 +38,14 @@
-
- Create New Lineitem For This Record -
- - - - - - - - - - -
Add To Selection List
- -
-
+ +
-- 2.11.0