ff ui / list columns in template
authorBill Erickson <berick@esilibrary.com>
Tue, 5 Nov 2013 22:02:34 +0000 (17:02 -0500)
committerBill Erickson <berick@esilibrary.com>
Tue, 5 Nov 2013 22:03:16 +0000 (17:03 -0500)
Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/fulfillment/t_item_table.tt2
Open-ILS/src/templates/staff/fulfillment/t_status.tt2
Open-ILS/web/js/ui/default/staff/fulfillment/app.js

index 7238ee7..eb7ff3a 100644 (file)
@@ -5,75 +5,57 @@
   </div>
 </div>
 
+[%
+# define the full set of columns here for ease of sharing 
+# the data between the template and the JS env.
+COLUMNS = [
+    {name => 'index', label => l('#'), extra => ' + 1'},
+    {name => 'hold_id', label => l('Request ID'), tabs => 'tab_pending'},
+    {name => 'transit_id', label => l('Transit ID'), tabs => 'tab_inbound || tab_outbound'},
+    {name => 'circ_id', label => l('Circ ID'), tabs => 'tab_circulating'},
+    {name => 'copy_barcode', label => l('Item Barcode')},
+    {name => 'copy_circ_lib', label => l('Copy Library')},
+    {name => 'request_time', label => l('Request Date'), tabs => 'tab_pending', extra => '| date'},
+    {name => 'expire_time', label => l('Expire Date'), tabs => 'tab_pending', extra => '| date'},
+    {name => 'hold_request_lib', label => l('Requesting Library'), tabs => 'tab_pending'},
+    {name => 'hold_pickup_lib', label => l('Pickup Library'), tabs => 'tab_pending'}
+    {name => 'transit_time', label => l('Transit Date'), tabs => 'tab_inbound || tab_outbound', extra => '| date'},
+    {name => 'transit_source', label => l('Transit Source'), tabs => 'tab_inbound || tab_outbound'},
+    {name => 'transit_dest', label => l('Transit Destination'), tabs => 'tab_inbound || tab_outbound'},
+    {name => 'hold_shelf_time', label => l('Shelf Date'), tabs => 'tab_onshelf', extra => '| date'},
+    {name => 'patron_given_name', label => l('Patron First'), tabs => 'tab_circulating || tab_onshelf'},
+    {name => 'patron_family_name', label => l('Patron Last'), tabs => 'tab_circulating || tab_onshelf'},
+    {name => 'patron_barcode', label => l('Patron Barcode'), tabs => 'tab_circulating || tab_onshelf'},
+    {name => 'xact_start', label => l('Checkout Date'), tabs => 'tab_circulating', extra => '| date'},
+    {name => 'due_date',  label => l('Due Date'), tabs => 'tab_circulating', extra => '| date'},
+    {name => 'circ_circ_lib', label => l('Circulating Library'), tabs => 'tab_circulating'},
+    {name => 'title', label => l('Title')}
+];
+%]
+
 <table class="table table-striped table-hover table-condensed" ng-show="itemList.count()">
   <thead>
     <tr>
       <th><a href="javascript:;" ng-click="itemList.selectAll()">&#x2713;</a></th>
-
-      <th>#</th>
-      <th ng-show="tab_pending">[% l('Request ID') %]</th>
-      <th ng-show="tab_inbound || tab_outbound">[% l('Transit ID') %]</th>
-      <th ng-show="tab_circulating">[% l('Circ ID') %]</th>
-
-      <th>[% l('Item Barcode') %]</th>
-      <th>[% l('Copy Library') %]</th>
-
-      <!-- holds columns -->
-      <th ng-show="tab_pending">[% l('Request Date') %]</th>
-      <th ng-show="tab_pending">[% l('Expire Date') %]</th>
-      <th ng-show="tab_pending">[% l('Requesting Library') %]</th>
-      <th ng-show="tab_pending">[% l('Pickup Library') %]</th>
-
-      <!-- transit columns -->
-      <th ng-show="tab_inbound || tab_outbound">[% l('Transit Date') %]</th>
-      <th ng-show="tab_inbound || tab_outbound">[% l('Transit Source') %]</th>
-      <th ng-show="tab_inbound || tab_outbound">[% l('Transit Destination') %]</th>
-
-      <!-- shelf columns -->
-      <th ng-show="tab_onshelf">[% l('Shelf Date') %]</th>
-
-      <!-- circ columns -->
-      <th ng-show="tab_circulating || tab_onshelf">[% l('Patron Name') %]</th>
-      <th ng-show="tab_circulating || tab_onshelf">[% l('Patron Barcode') %]</th>
-      <th ng-show="tab_circulating">[% l('Checkout Date') %]</th>
-      <th ng-show="tab_circulating">[% l('Due Date') %]</th>
-      <th ng-show="tab_circulating">[% l('Circulating Library') %]</th>
-
-      <!-- titles can get long, so plop it onto the end of the table -->
-      <th>[% l('Title') %]</th>
-
+      [% FOREACH col IN COLUMNS %]
+      <th [% IF col.tabs %]ng-show="[% col.tabs %]"[% END %]>[% col.label %]</th>
+      [% END %]
     </tr>
   </thead>
   <tbody>
     <tr ng-repeat="item in itemList.items">
       <td><input type='checkbox' ng-model="itemList.selected[item.index]"/></td>
-      <td>{{item.index + 1}}</td>
-
-      <td ng-show="tab_pending">{{item.hold_id}}</td>
-      <td ng-show="tab_inbound || tab_outbound">{{item.transit_id}}</td>
-      <td ng-show="tab_circulating">{{item.circ_id}}</td>
-
-      <td><a 
-        href="./fulfillment/status/{{item.copy_barcode_enc}}">
-          {{item.copy_barcode}}</a>
+      [% FOREACH col IN COLUMNS %]
+      <td 
+        [% IF col.tabs %]ng-show="[% col.tabs %]"[% END %]
+        ng-init="addColumn({name : '[% col.name %]', label : '[% col.label %]'})">
+        [% IF col.name == 'copy_barcode' %]
+        <a href="./fulfillment/status/{{item.copy_barcode_enc}}">{{item.copy_barcode}}</a>
+        [% ELSE %]
+          {{item.[% col.name %][% col.extra IF col.extra %]}}
+        [% END %]
       </td>
-      <td>{{item.copy_circ_lib}}</td>
-
-      <td ng-show="tab_pending">{{item.request_time | date}}</td>
-      <td ng-show="tab_pending">{{item.expire_time | date}}</td>
-      <td ng-show="tab_pending">{{item.request_lib}}</td>
-      <td ng-show="tab_pending">{{item.pickup_lib}}</td>
-
-      <td ng-show="tab_inbound || tab_outbound">{{item.transit_time | date}}</td>
-      <td ng-show="tab_inbound || tab_outbound">{{item.transit_source}}</td>
-      <td ng-show="tab_inbound || tab_outbound">{{item.transit_dest}}</td>
-      <td ng-show="tab_onshelf">{{item.hold_shelf_time | date}}</td>
-      <td ng-show="tab_circulating">{{item.patron_given_name}} {{item.patron_family_name}}</td>
-      <td ng-show="tab_circulating">{{item.patron_barcode}}</td>
-      <td ng-show="tab_circulating">{{item.xact_start | date}}</td>
-      <td ng-show="tab_circulating">{{item.due_date | date}}</td>
-      <td ng-show="tab_circulating">{{item.circ_circ_lib}}</td>
-      <td>{{item.title}}</td>
+      [% END %]
     </tr>
   </tbody>
 </table>
index 76e633d..223789f 100644 (file)
@@ -80,7 +80,7 @@
         </thead>
         <tbody>
           <tr ng-show='item.circ'><td>Circulating Library:</td><td>{{item.circ_circ_lib}}</td></tr>
-          <tr ng-show='item.circ'><td>Circulating Patron:</td><td>{{item.circ_usr}}</td></tr>
+          <tr ng-show='item.circ'><td>Circulating Patron:</td><td>{{item.patron_name}}</td></tr>
           <tr ng-show='item.circ'><td>Checkout date:</td><td>{{item.circ_xact_start | date}}</td></tr>
           <tr ng-show='item.circ'><td>Due Date:</td><td>{{item.due_date | date}}</td></tr>
           <tr ng-show='item.circ_stop_fines'><td>Circ Status:</td>
index 2766c06..c475d0a 100644 (file)
@@ -144,7 +144,11 @@ function ($scope,  $q,  $compile,  $timeout,  $rootScope, $location,
     $scope.illRouteParams = $routeParams;
 
     $scope.itemList = egList.create({limit : 10}); // limit TBD
-  
+    $scope.columns = [];
+    $scope.addColumn = function(col) {
+        $scope.columns.push(col);
+    }
+
     // map of flattener fields to retrieve for each query type
     $scope.flatFields = {
         ahr : {
@@ -156,8 +160,8 @@ function ($scope,  $q,  $compile,  $timeout,  $rootScope, $location,
             patron_barcode : {path : 'usr.card.barcode'},
             patron_given_name : {path : 'usr.first_given_name'},
             patron_family_name : {path : 'usr.family_name'},
-            request_lib : {path : 'request_lib.shortname'}, // TODO: causes query problem, wha?
-            pickup_lib : {path : 'pickup_lib.shortname'},
+            hold_request_lib : {path : 'request_lib.shortname'}, // TODO: causes query problem, wha?
+            hold_pickup_lib : {path : 'pickup_lib.shortname'},
             title : {path : 'bib_rec.bib_record.simple_record.title'},
             author : {path : 'bib_rec.bib_record.simple_record.author'},
             copy_id : {path : 'current_copy.id'},
@@ -189,8 +193,8 @@ function ($scope,  $q,  $compile,  $timeout,  $rootScope, $location,
             id : {path : 'id'},
             transit_id : {path : 'id'},
             hold_id : {path : 'hold_transit_copy.hold.id'},
-            request_lib : {path : 'hold_transit_copy.hold.request_lib'},
-            pickup_lib : {path : 'hold_transit_copy.hold.pickup_lib.shortname'},
+            hold_request_lib : {path : 'hold_transit_copy.hold.request_lib.shortname'},
+            hold_pickup_lib : {path : 'hold_transit_copy.hold.pickup_lib.shortname'},
             patron_id : {path : 'hold_transit_copy.hold.usr.id'},
             patron_barcode : {path : 'hold_transit_copy.hold.usr.card.barcode'},
             patron_given_name : {path : 'hold_transit_copy.hold.usr.first_given_name'},