From 0315013104c7947a53b881f897600deccd66632a Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Tue, 23 Jun 2015 10:33:02 -0400 Subject: [PATCH] JBAS-773 Merge custom ACQ changes into stock li-table Avoid using a custom version of the lineitem table code, since it is getting out of sync with stock. Instead, return to using the stock template and JS with custom changes merged in. Signed-off-by: Bill Erickson Conflicts: Open-ILS/web/js/ui/kcls/acq/common/li_table.js Conflicts: Open-ILS/web/js/ui/default/acq/common/li_table.js --- .../var/templates_kcls/acq/common/li_table.tt2 | 588 ---- Open-ILS/src/templates/acq/common/li_table.tt2 | 19 +- Open-ILS/web/js/ui/default/acq/common/li_table.js | 42 +- Open-ILS/web/js/ui/kcls/acq/common/li_table.js | 3512 -------------------- 4 files changed, 53 insertions(+), 4108 deletions(-) delete mode 100644 KCLS/openils/var/templates_kcls/acq/common/li_table.tt2 delete mode 100644 Open-ILS/web/js/ui/kcls/acq/common/li_table.js diff --git a/KCLS/openils/var/templates_kcls/acq/common/li_table.tt2 b/KCLS/openils/var/templates_kcls/acq/common/li_table.tt2 deleted file mode 100644 index 170f9ce466..0000000000 --- a/KCLS/openils/var/templates_kcls/acq/common/li_table.tt2 +++ /dev/null @@ -1,588 +0,0 @@ - - - - -
- - - - [% INCLUDE "acq/common/info.tt2" which = "Lit" %] - - - [% INCLUDE "acq/common/notes.tt2" which = "Lit" %] - - - - - - - - - - - - [% PROCESS 'acq/common/vlagent.tt2' %] - - - - - - - - -
- - - - - - - -
- - - - -
- - -
-
- - - - -
- diff --git a/Open-ILS/src/templates/acq/common/li_table.tt2 b/Open-ILS/src/templates/acq/common/li_table.tt2 index 895852ccff..91a14bc64d 100644 --- a/Open-ILS/src/templates/acq/common/li_table.tt2 +++ b/Open-ILS/src/templates/acq/common/li_table.tt2 @@ -120,6 +120,12 @@ [% l('Line Items') %] + + + [% l('Apply ISBN Picker to All Items') %] + + + [% l('Picked: ') %] @@ -204,11 +211,13 @@ 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 4dd6d3f17a..16745d39b1 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 @@ -1141,8 +1141,16 @@ function AcqLiTable() { if (orderIdent && orderIdent.attr_name() == name) { cbox.attr('value', orderIdent.attr_value()); + + // KCLS CUSTOM + var link = nodeByName('order_ident_picked', row); + link.innerHTML += orderIdent.attr_value(); } else { cbox.attr('value', values[name][0].attr_value()); + + // KCLS CUSTOM + var link = nodeByName('order_ident_picked', row); + link.innerHTML += "None"; } } @@ -1151,7 +1159,8 @@ function AcqLiTable() { sel._cbox = cbox; cbox._lineitem = li; - dojo.connect(cbox, 'onChange', updateOrderIdent); + // KCLS CUSTOM onChange => onBlur + dojo.connect(cbox, 'onBlur', updateOrderIdent); } changeComboBox(typeSel); // force the initial draw @@ -1253,6 +1262,10 @@ function AcqLiTable() { var actUpdateBarcodes = nodeByName("action_update_barcodes", row); var actHoldingsMaint = nodeByName("action_holdings_maint", row); + // KCLS CUSTOM + var actReceive = nodeByName("action_mark_recv", row); + var actUnRecv = nodeByName("action_mark_unrecv", row); + /* handle row coloring for based on LI state */ openils.Util.removeCSSClass(row, /^oils-acq-li-state-/); openils.Util.addCSSClass(row, "oils-acq-li-state-" + li.state()); @@ -1323,7 +1336,27 @@ function AcqLiTable() { } else { console.log('li cancel_reason is un-fleshed. Please fix'); } - } + + } else if (li.state() == 'on-order') { + // KCLS CUSTOM -- activate LI receive action + + actReceive.disabled = false; + actReceive.onclick = function() { + if (self.checkLiAlerts(li.id())) + self.issueReceive(li); + nodeByName("action_none", row).selected = true; + }; + + } else if (li.state() == 'received') { + // KCLS CUSTOM -- activate LI un-receive action + + actUnRecv.disabled = false; + actUnRecv.onclick = function() { + if (confirm(localeStrings.UNRECEIVE_LI)) + self.issueReceive(li, /* rollback */ true); + nodeByName("action_none", row).selected = true; + }; + } openils.Util.show(state_cell); }; @@ -3005,7 +3038,10 @@ function AcqLiTable() { this.createAssets = function(onAssetsCreated, noVl) { this.show('acq-lit-progress-numbers'); var self = this; - var vlArgs = (noVl) ? {} : {vandelay : this.vlAgent.values()}; + // KCLS CUSTOM: {vandelay : {noVl : true}} -- stock just uses {} + // Could be related to future changes in Vandelay.pm + var vlArgs = (noVl) ? + {vandelay : {noVl : true}} : {vandelay : this.vlAgent.values()}; this.batchProgress = {}; progressDialog.show(false); progressDialog.attr("title", localeStrings.LI_CREATING_ASSETS); diff --git a/Open-ILS/web/js/ui/kcls/acq/common/li_table.js b/Open-ILS/web/js/ui/kcls/acq/common/li_table.js deleted file mode 100644 index 187cd2d6fe..0000000000 --- a/Open-ILS/web/js/ui/kcls/acq/common/li_table.js +++ /dev/null @@ -1,3512 +0,0 @@ -dojo.require('dojo.date.locale'); -dojo.require('dojo.date.stamp'); -dojo.require('dijit.form.Button'); -dojo.require('dijit.form.TextBox'); -dojo.require('dijit.form.FilteringSelect'); -dojo.require('dijit.form.Textarea'); -dojo.require('dijit.Tooltip'); -dojo.require('dijit.ProgressBar'); -dojo.require('dojox.timing.doLater'); -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'); -dojo.require('openils.widget.ProgressDialog'); -dojo.require('openils.PermaCrud'); -dojo.require("openils.widget.PCrudAutocompleteBox"); -dojo.require('dijit.form.ComboBox'); -dojo.require('openils.CGI'); - -if (!localeStrings) { /* we can do this because javascript doesn't have block scope */ - 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"]; - -var fundLabelFormat = [ - '${1} (${2})', 'id', 'code', 'year' -]; -var fundSearchFormat = ['${0} (${1})', 'code', 'year']; - -function nodeByName(name, context) { - return dojo.query('[name='+name+']', context)[0]; -} - -// for caching linked users. e.g. lineitem_detail.receiver -var userCache = {}; - -var liDetailBatchFields = ['fund', 'owning_lib', 'location', 'collection_code', 'circ_modifier', 'cn_label']; -var liDetailFields = liDetailBatchFields.concat(['barcode', 'note']); -var fundStyles = { - "stop": "color: #c00; font-weight: bold;", - "warning": "color: #c93;" -}; - -function AcqLiTable() { - - var self = this; - this.liCache = {}; - this.plCache = {}; - this.poCache = {}; - this.relCache = {}; - this.haveFundClass = {} - this.fundBalanceState = {}; - this.realDfaCache = {}; - this.virtDfaCounts = {}; - this.virtDfaId = -1; - this.dfeOffset = 0; - this.claimEligibleLidByLi = {}; - this.claimEligibleLid = {}; - this.toggleState = false; - this.tbody = dojo.byId('acq-lit-tbody'); - this.selectors = []; - this.noteAcks = {}; - this.authtoken = openils.User.authtoken; - this.pcrud = new openils.PermaCrud(); - this.rowTemplate = this.tbody.removeChild(dojo.byId('acq-lit-row')); - this.copyTbody = dojo.byId('acq-lit-li-details-tbody'); - this.copyRow = this.copyTbody.removeChild(dojo.byId('acq-lit-li-details-row')); - this.copyBatchRow = dojo.byId('acq-lit-li-details-batch-row'); - this.copyBatchWidgets = {}; - this.liNotesTbody = dojo.byId('acq-lit-notes-tbody'); - this.liNotesRow = this.liNotesTbody.removeChild(dojo.byId('acq-lit-notes-row')); - this.realCopiesTbody = dojo.byId('acq-lit-real-copies-tbody'); - this.realCopiesRow = this.realCopiesTbody.removeChild(dojo.byId('acq-lit-real-copies-row')); - this._copy_fields_for_acqdf = ['owning_lib', 'location']; - this.skipInitialEligibilityCheck = false; - this.claimDialog = new ClaimDialogManager( - liClaimDialog, finalClaimDialog, this.claimEligibleLidByLi, - function(li) { /* callback that fires when claims are made */ - self.fetchClaimInfo(li.id(), /* force update */ true); - } - ); - this.vlAgent = new VLAgent(); - - if (dojo.byId('acq-lit-apply-idents')) { - dojo.byId('acq-lit-apply-idents').onclick = function() { - self.applyOrderIdentValues(); - }; - } - - this.focusLineitem = new openils.CGI().param('focus_li'); - - // capture the inline copy display wrapper and row template - this.inlineCopyContainer = - this.tbody.removeChild(dojo.byId('acq-inline-copies-row')); - var tb = dojo.query( - '[name=acq-li-inline-copies-tbody]', this.inlineCopyContainer)[0]; - this.inlineCopyTemplate = tb.removeChild( - dojo.query('[name=acq-li-inline-copies-template]', tb)[0]); - this.inlineNoCopies = tb.removeChild( - dojo.query('[name=acq-li-inline-copies-none]', tb)[0]); - - // list of LI IDs that should be refreshed at next display time - this.inlineCopiesNeedingRefresh = []; - - dojo.byId("acq-lit-li-actions-selector").onchange = function() { - self.applySelectedLiAction(this.options[this.selectedIndex].value); - this.selectedIndex = 0; - }; - - acqLitCreatePoSubmit.onClick = function() { - if (!self.createPoProviderSelector.attr("value") || - !self.createPoAgencySelector.attr("value")) { - alert(localeStrings.CREATE_PO_INVALID); - return false; - } else if (self._confirmPoPrepaySituation()) { - acqLitPoCreateDialog.hide(); - self._createPO(acqLitPoCreateDialog.getValues()); - } else { - return false; - } - } - - acqLitSavePlButton.onClick = function() { - acqLitSavePlDialog.hide(); - self._savePl(acqLitSavePlDialog.getValues()); - } - - acqLitCancelLiStateButton.onClick = function() { - acqLitChangeLiStateDialog.hide(); - } - acqLitSaveLiStateButton.onClick = function() { - acqLitChangeLiStateDialog.hide(); - self._updateLiState(acqLitChangeLiStateDialog.getValues(), acqLitChangeLiStateDialog.attr('state')); - } - - - dojo.byId('acq-lit-select-toggle').onclick = function(){self.toggleSelect()}; - dojo.byId('acq-inline-copies-toggle').onclick = function(){self.toggleInlineCopies()}; - dojo.byId('acq-lit-info-back-button').onclick = function(){self.show('list')}; - dojo.byId('acq-lit-copies-back-button').onclick = function(){self.show('list')}; - dojo.byId('acq-lit-notes-back-button').onclick = function(){self.show('list')}; - dojo.byId('acq-lit-real-copies-back-button').onclick = function(){self.show('list')}; - - this.afwCopyFieldArgs = function(field, perms) { - return { - "fmField" : field, - "fmClass": 'acqlid', - "labelFormat": (field == 'fund') ? fundLabelFormat : null, - "searchFormat": (field == 'fund') ? fundSearchFormat : null, - "searchFilter": (field == 'fund') ? {"active": "t"} : null, - "orgLimitPerms": [perms], - "dijitArgs": { - "required": false, - "labelType": (field == "fund") ? "html" : null - }, - "noCache": (field == "fund"), - "forceSync": true - }; - }; - - /* This is the "new" batch updater that sits atop all lineitems. It does - * use this.afwCopyFieldArgs() to borrow a little common code from the - * "old" batch updater atop the copy details view. */ - this.initBatchUpdater = function(disabled_fields) { - openils.Util.show("acq-batch-update", "table"); - - if (!dojo.isArray(disabled_fields)) disabled_fields = []; - - /* Note that this will directly contain dijits, not the AutoWidget - * wrapper object. */ - this.batchUpdateWidgets = {}; - - this.batchUpdateWidgets.item_count = new dijit.form.TextBox( - { - "style": {"width": "3em"}, - "disabled": Boolean( - dojo.indexOf(disabled_fields, "item_count") != -1 - ) - }, - "acq-bu-item_count" - ); - - (new openils.widget.AutoFieldWidget({ - "fmClass": "acqdf", - "selfReference": true, - "dijitArgs": { "required": false }, - "forceSync": true, - "parentNode": "acq-bu-distribution_formula" - })).build( - function(w) { - dojo.style(w.domNode, {"width": "12em"}); - /* dijitArgs to AutoFieldWidget won't work for 'disabled' */ - w.attr( - "disabled", - dojo.indexOf(disabled_fields, "distribution_formula") != -1 - ); - self.batchUpdateWidgets.distribution_formula = w; - } - ); - - dojo.forEach( - ["owning_lib","location","collection_code","circ_modifier","fund"], - function(field) { - var args = self.afwCopyFieldArgs(field,"CREATE_PURCHASE_ORDER"); - args.parentNode = dojo.byId("acq-bu-" + field); - - (new openils.widget.AutoFieldWidget(args)).build( - function(w, aw) { - if (field == "fund") { - dojo.connect( - w, "onChange", function(val) { - self._updateFundSelectorStyle(aw, val); - } - ); - if (w.store) - self._ensureCSSFundClasses(w.store); - } - - dojo.style(w.domNode, {"width": "10em"}); - w.attr( - "disabled", - dojo.indexOf(disabled_fields, field) != -1 - ); - self.batchUpdateWidgets[field] = w; - } - ); - } - ); - - acqBatchUpdateApply.onClick = function() { - var li_id_list = self.getSelected(false, null, true /* id list */); - if (!li_id_list.length) { - alert(localeStrings.NO_LI_TO_UPDATE); - return; - } - - progressDialog.show(true); - progressDialog.attr("title", localeStrings.LI_BATCH_UPDATE); - progressDialog.update({"maximum": li_id_list.length,"progress": 0}); - - var count = 0; - - var params = [ self.authtoken, {"lineitems": li_id_list}, - self.batchUpdateChanges(), self.batchUpdateFormula() ]; - console.log("batch update params: " + dojo.toJson(params)); - - fieldmapper.standardRequest( - ["open-ils.acq", "open-ils.acq.lineitem.batch_update"], { - "async": true, - "params": params, - "onresponse": function(r) { - if ((r = openils.Util.readResponse(r))) { // assignment - progressDialog.update({"progress": ++count}); - } else { - progressDialog.hide(); - progressDialog.attr("title", ""); - } - }, - "oncomplete": function() { - /* XXX Is the last call to onresponse guaranteed to - * finish before oncomplete is fired? */ - if (count != li_id_list.length) { - console.error("lineitem batch update operation failed"); - progressDialog.hide(); - progressDialog.attr("title", ""); - } else { - location.href = location.href; - } - } - } - ); - }; - }; - - this.batchUpdateChanges = function() { - var o = {}; - - dojo.forEach( - openils.Util.objectProperties(this.batchUpdateWidgets), - function(k) { - if (k == "distribution_formula") return; /* handled elsewhere */ - if (self.batchUpdateWidgets[k].attr("disabled")) return; - - /* It's important that a value of "" should mean that a field - * doesn't get used in the arguments to the batch updater API, - * but 0 should mean an actual 0. */ - var value = self.batchUpdateWidgets[k].attr("value"); - if (value !== "") - o[k] = value; - } - ); - - return o; - }; - - this.batchUpdateFormula = function() { - if (this.batchUpdateWidgets.distribution_formula.attr("disabled")) { - return null; - } else { - return ( - this.batchUpdateWidgets.distribution_formula.attr("value") || - null - ); - } - }; - - this.reset = function(keep_selectors) { - while(self.tbody.childNodes[0]) - self.tbody.removeChild(self.tbody.childNodes[0]); - self.noteAcks = {}; - self.relCache = {}; - - if (!keep_selectors) - self.selectors = []; - }; - - this.setNext = function(handler) { - var link = dojo.byId('acq-lit-next'); - if(handler) { - dojo.style(link, 'visibility', 'visible'); - link.onclick = handler; - } else { - dojo.style(link, 'visibility', 'hidden'); - } - }; - - this.setPrev = function(handler) { - var link = dojo.byId('acq-lit-prev'); - if(handler) { - dojo.style(link, 'visibility', 'visible'); - link.onclick = handler; - } else { - dojo.style(link, 'visibility', 'hidden'); - } - }; - - this.enableActionsDropdownOptions = function(mask) { - /* 'mask' is probably a misnomer the way I'm using it, but it needs to - * be one of pl,po,ao,gs,vp, or fs. */ - dojo.query("option", "acq-lit-li-actions-selector").forEach( - function(option) { - var opt_mask = dojo.attr(option, "mask"); - - /* For each