Acq: Use scope to constrain choice of lineitem alerts
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Tue, 8 May 2012 18:20:24 +0000 (14:20 -0400)
committerBill Erickson <berick@esilibrary.com>
Fri, 25 May 2012 17:32:53 +0000 (13:32 -0400)
This commit addresses this launchpad bug:
https://bugs.launchpad.net/evergreen/+bug/996033

The controlled vocabulary of acq lineitem alert text is set up in an
interface labeled "Line Item Alerts" in the staff client admin menu. In
the PO and selection list interfaces (where alerts can be applied), we
will limit the user to selecting alerts from those owned at the user's
workstation org unit (or its ancestors).

When we display applied alerts, we can also display the shortname of the
org unit at which the alert text is defined (the owning_lib column).
This should help clarify what's going on with alerts that have already
been applied using alert text from another org unit.

[Amended since original reference on Launchpad to also show the
owning_lib's shortname when confirming alerts at receive time.]

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/web/js/ui/default/acq/common/li_table.js

index 9e3e350..8215946 100644 (file)
@@ -691,7 +691,11 @@ function AcqLiTable() {
             {
                 "data": acqliat.toStoreData(
                     this.pcrud.search(
-                        "acqliat", {"id": {"!=": null}}
+                        "acqliat", {
+                            "owning_lib": aou.orgNodeTrail(
+                                aou.findOrgUnit(openils.User.user.ws_ou())
+                            ).map(function(o) { return o.id(); })
+                        }
                     )
                 )
             }
@@ -771,7 +775,12 @@ function AcqLiTable() {
         nodeByName("value", row).innerHTML = note.value();
         var alert_node = nodeByName("alert_code", row);
         if (note.alert_text()) {
-            alert_node.innerHTML = note.alert_text().code();
+            alert_node.innerHTML = dojo.string.substitute(
+                "[${0}] ${1}", [
+                    aou.findOrgUnit(note.alert_text().owning_lib()).shortname(),
+                    note.alert_text().code()
+                ]
+            );
             if (note.alert_text().description()) {
                 new dijit.Tooltip(
                     {
@@ -1868,8 +1877,17 @@ function AcqLiTable() {
                 localeStrings.CONFIRM_LI_ALERT, [
                     (new openils.acq.Lineitem({"lineitem": li})).findAttr(
                         "title", "lineitem_marc_attr_definition"
+                    ), (
+                        /* XXX it's really better add a parameter and to adjust
+                         * the format string rather than do this concatenation
+                         * here, but if someone wants this for 2.2 in a hurry,
+                         * we can sidestep the problem of updating the strings
+                         * while the translators are working. */
+                        "[" +
+                        aou.findOrgUnit(lin.alert_text().owning_lib()).shortname() +
+                        "] " +
+                        lin.alert_text().code()
                     ),
-                    lin.alert_text().code(),
                     lin.alert_text().description() || "",
                     lin.value()
                 ]