grid cell values may be rendered as hrefs
authorBill Erickson <berick@esilibrary.com>
Mon, 19 May 2014 14:42:31 +0000 (10:42 -0400)
committerBill Erickson <berick@esilibrary.com>
Mon, 19 May 2014 14:42:31 +0000 (10:42 -0400)
added links from item status -> title to catalog
added links from patron items out to item status and catalog.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/cat/item/t_list.tt2
Open-ILS/src/templates/staff/circ/patron/t_items_out.tt2
Open-ILS/src/templates/staff/share/t_autogrid.tt2
Open-ILS/web/js/ui/default/staff/services/grid.js

index d3fe261..220a853 100644 (file)
   <eg-grid-field label="[% l('Barcode') %]"     path='barcode' visible></eg-grid-field>
   <eg-grid-field label="[% l('Call Number') %]" path="call_number.label" visible></eg-grid-field>
   <eg-grid-field label="[% l('Location') %]"    path="location.name" visible></eg-grid-field>
-  <eg-grid-field label="[% l('Title') %]"       path="call_number.record.simple_record.title" visible></eg-grid-field>
+
+  <!-- linkpath value must be a quoted string to avoid compile-time 
+      interpolation, hence the &quot;'s -->
+  <eg-grid-field label="[% l('Title') %]"       
+    path="call_number.record.simple_record.title" visible
+    linkpath="&quot;[% ctx.base_path %]/opac/record/{{item['call_number.record.id']}}&quot;">
+  </eg-grid-field>
 </eg-grid>
 
index 612c732..d381e32 100644 (file)
@@ -8,11 +8,16 @@
   items-provider="gridDataProvider"
   persist-key="circ.patron.items_out">
   <eg-grid-field label="[% l('Circ ID') %]" path='id' visible></eg-grid-field>
-  <eg-grid-field label="[% l('Barcode') %]" path='target_copy.barcode' visible></eg-grid-field>
+  <eg-grid-field label="[% l('Barcode') %]" path='target_copy.barcode' 
+    visible linkpath="'./cat/item/{{item.target_copy().id()}}'">
+  </eg-grid-field>
   <eg-grid-field label="[% l('Due Date') %]" path='due_date' visible></eg-grid-field>
   <eg-grid-field label="[% l('Checkout / Renewal Library') %]" path='circ_lib.shortname' visible></eg-grid-field>
   <eg-grid-field label="[% l('Renewals Remaining') %]" path='renewal_remaining' visible></eg-grid-field>
   <eg-grid-field label="[% l('Fines Stopped') %]" path='stop_fines' visible></eg-grid-field>
-  <eg-grid-field label="[% l('Title') %]" path='target_copy.call_number.record.simple_record.title' visible></eg-grid-field>
+  <eg-grid-field label="[% l('Title') %]" 
+    path='target_copy.call_number.record.simple_record.title' visible
+    linkpath="'[% ctx.base_path %]/opac/record/{{item.target_copy().call_number().record().id()}}'">
+  </eg-grid-field>
 </eg-grid>
 
index 27439e9..06e8546 100644 (file)
           ng-repeat="col in columns"
           style="flex:{{col.flex}}"
           ng-show="col.visible">
-        {{itemFieldValue(item, col)}}
+          
+          <!-- TODO: add support for configurable intra-app routing via 
+               linkpath. i.e. don't always assume target=_self -->
+          <a ng-if="col.linkpath" target="_self"
+            ng-href="{{generateLinkPath(col, item)}}">
+            {{itemFieldValue(item, col)}}
+          </a>
+          <span ng-if="!col.linkpath">
+            {{itemFieldValue(item, col)}}
+          </span>
       </div>
     </div>
   </div>
index dcb4880..5051681 100644 (file)
@@ -662,6 +662,12 @@ angular.module('egGridMod',
                 return csvStr;
             }
 
+            // Interpolate the value for column.linkpath within the context
+            // of the row item to generate the final link URL.
+            $scope.generateLinkPath = function(col, item) {
+                return egCore.strings.$replace(col.linkpath, {item : item});
+            }
+
             $scope.collect = function() { grid.collect() }
 
             // asks the dataProvider for a page of data
@@ -694,12 +700,18 @@ angular.module('egGridMod',
     return {
         require : '^egGrid',
         restrict : 'AE',
-        transclude : true,
         scope : {
             name  : '@', // required; unique name
             path  : '@', // optional; flesh path
             label : '@', // optional; display label
-            flex  : '@'  // optional; default flex width
+            flex  : '@',  // optional; default flex width
+
+            // optional: url path string for generating links from grid cells.
+            // The path must be a quoted string and may include interpolation 
+            // expressions.  e.g.
+            // linkpath="'./cat/item/{{item.id()}}'"
+            linkpath : '=', 
+            
         },
         link : function(scope, element, attrs, egGridCtrl) {
 
@@ -830,6 +842,7 @@ angular.module('egGridMod',
                 flex  : Number(colSpec.flex) || 2,
                 sort  : Number(colSpec.sort) || 0,
                 required : colSpec.required,
+                linkpath : colSpec.linkpath,
                 visible  : colSpec.visible,
                 hidden   : colSpec.hidden,
                 datatype : colSpec.datatype,