LP#1270289 Show cancel reason labels for lineitems/copies
authorBill Erickson <berick@esilibrary.com>
Tue, 3 Jun 2014 13:38:46 +0000 (09:38 -0400)
committerBen Shum <bshum@biblio.org>
Thu, 7 Aug 2014 21:06:41 +0000 (17:06 -0400)
In the standard lineitem list page, display lineitem states as
translatable strings instead of displaying the raw lineitem state code.
Additionally, when the state is 'cancelled', display the cancel_reason
label instead of "cancelled" to help differentiate between canceled and
delayed items.

Similarly, display the cancel reason label for canceled copies in the
copy edit grid.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Signed-off-by: Ben Shum <bshum@biblio.org>
Open-ILS/src/templates/acq/common/li_table.tt2
Open-ILS/web/js/ui/default/acq/common/li_table.js

index 0a2151a..fd33741 100644 (file)
                             <option name='action_view_history'>[% l('View History') %]</option>
                         </select>
                     </td>
-                    <td><span name='li_state'></span></td>
+                    <td>
+                      <span class="hidden" state-label name='li_state_new'>[% l('New') %]</span>
+                      <span class="hidden" state-label name='li_state_selector-ready'>[% l('Selector-Ready') %]</span>
+                      <span class="hidden" state-label name='li_state_order-ready'>[% l('Order-Ready') %]</span>
+                      <span class="hidden" state-label name='li_state_approved'>[% l('Approved') %]</span>
+                      <span class="hidden" state-label name='li_state_pending-order'>[% l('Pending-Order') %]</span>
+                      <span class="hidden" state-label name='li_state_on-order'>[% l('On-Order') %]</span>
+                      <span class="hidden" state-label name='li_state_received'>[% l('Received') %]</span>
+                      <span class="hidden" state-label name='li_state_cancelled'>[% l('Canceled') %]</span>
+                    </td>
                     <td><input type='text' size='8' name='price'/></td>
                 </tr>
                 <tr id='acq-inline-copies-row' class='acq-inline-copies-row'>
index c98cec4..913f354 100644 (file)
@@ -1207,41 +1207,45 @@ function AcqLiTable() {
                 self.generateMakeRecTab( li.eg_bib_id(), 'copy_browser', row );
         }
 
-        var state_cell = nodeByName("li_state", row);
+        var state_cell = nodeByName("li_state_" + li.state(), row);
 
-        switch(li.state()) {
+        // re-hide any state label nodes which may have been un-hidden
+        // through previous actions.
+        dojo.query('[state-label]', row).forEach(function(node) {
+            openils.Util.hide(node)
+        });
 
-            case 'cancelled':
-                if(typeof li.cancel_reason() == "object") {
-                    var holds_state = dojo.create(
-                        "span", {
-                            "style": "border-bottom: 1px dashed #000;",
-                            "innerHTML": li.state()
-                        }, state_cell, "only"
-                    );
-                    new dijit.Tooltip(
-                        {
-                            "label": "<em>" + li.cancel_reason().label() +
-                                "</em><br />" + li.cancel_reason().description(),
-                            "connectId": [holds_state]
-                        }, dojo.create("span", null, state_cell, "last")
-                    );
+        if (li.state() == 'cancelled') {
+            if(typeof li.cancel_reason() == "object") {
 
-                    if (li.cancel_reason().keep_debits() == 't') {
-                        openils.Util.removeCSSClass(row, /^oils-acq-li-state-/);
-                        openils.Util.addCSSClass(row, "oils-acq-li-state-delayed");
-                    }
-                }
-                return; // all done
+                // clear the stock "Canceled" label, since we have more
+                // information to replace it with.
+                state_cell.innerHTML = '';
 
-            case "on-order":
-                break;
+                var holds_state = dojo.create(
+                    "span", {
+                        "style": "border-bottom: 1px dashed #000;",
+                        "innerHTML": li.cancel_reason().label()
+                    }, state_cell, "only"
+                );
+                new dijit.Tooltip(
+                    {
+                        "label": "<em>" + li.cancel_reason().label() +
+                            "</em><br />" + li.cancel_reason().description(),
+                        "connectId": [holds_state]
+                    }, dojo.create("span", null, state_cell, "last")
+                );
 
-            case "received":
-                break;
-        }
+                if (li.cancel_reason().keep_debits() == 't') {
+                    openils.Util.removeCSSClass(row, /^oils-acq-li-state-/);
+                    openils.Util.addCSSClass(row, "oils-acq-li-state-delayed");
+                }
+            } else {
+                console.log('li cancel_reason is un-fleshed.  Please fix');
+            }
+        } 
 
-        state_cell.innerHTML = li.state(); // TODO i18n state labels
+        openils.Util.show(state_cell);
     };
 
 
@@ -2468,7 +2472,7 @@ function AcqLiTable() {
                 var holds_reason = dojo.create(
                     "span", {
                         "style": "border-bottom: 1px dashed #000;",
-                        "innerHTML": "Cancelled" /* XXX [sic] and i18n */
+                        "innerHTML": copy.cancel_reason().label()
                     }, cxl_reason_link, "only"
                 );
                 new dijit.Tooltip(