ff ui : orientation as url component
authorBill Erickson <berick@esilibrary.com>
Mon, 28 Oct 2013 18:11:39 +0000 (14:11 -0400)
committerBill Erickson <berick@esilibrary.com>
Mon, 28 Oct 2013 18:11:39 +0000 (14:11 -0400)
maintain our lender vs borrower filter orientation within the url so
that browser-back returns the user to the correct list of items.  it
also helps simplify the code.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Open-ILS/src/templates/staff/fulfillment/t_actions.tt2
Open-ILS/src/templates/staff/fulfillment/t_circulating.tt2
Open-ILS/src/templates/staff/fulfillment/t_ill.tt2
Open-ILS/src/templates/staff/fulfillment/t_inbound.tt2
Open-ILS/src/templates/staff/fulfillment/t_outbound.tt2
Open-ILS/src/templates/staff/fulfillment/t_pending.tt2
Open-ILS/web/js/ui/default/staff/fulfillment/app.js

index c1743ff..64674a0 100644 (file)
     </button>
     <ul class="dropdown-menu">
       <li><a href="javascript:;" ng-click="checkin()"
-        ng-show="tab_pending && itemList.filterLender">Capture Item</a></li>
+        ng-show="tab_pending && orientation_lender">Capture Item</a></li>
       <li><a href="javascript:;" ng-click="retarget()"
         ng-show="tab_pending">Retarget Request</a></li>
       <li><a href="javascript:;" ng-click="cancel()"
-        ng-show="(tab_pending || tab_inbound) && itemList.filterBorrower">Cancel Request</a></li>
+        ng-show="(tab_pending || tab_inbound) && orientation_borrower">Cancel Request</a></li>
       <li><a href="javascript:;" ng-click="abort_transit()"
         ng-show="tab_inbound || tab_outbound">Abort Transit</a></li>
       <li><a href="javascript:;" ng-click="checkin()"
         ng-show="tab_inbound">Receive Item</a></li>
       <li><a href="javascript:;" ng-click="checkin()"
-        ng-show="tab_circulating && itemList.filterBorrower">Check In</a></li>
+        ng-show="tab_circulating && orientation_borrower">Check In</a></li>
       <!-- We need an on-shelf tab for this action to have a home
       <li><a href="javascript:;"
         ng-show="">Check Out</a></li>
       -->
       <li><a href="javascript:;" ng-click="mark_lost()"
-        ng-show="tab_circulating && itemList.filterBorrower">Mark Lost</a></li>
+        ng-show="tab_circulating && orientation_borrower">Mark Lost</a></li>
       <li><a href="javascript:;" ng-click="print()">Print</a></li>
     </ul>
   </div>
index 9728e8f..f82e649 100644 (file)
@@ -3,11 +3,11 @@
   <div class="row command-bar">
     <div class="col-lg-6">
       <ul class="nav nav-pills">
-        <li ng-class="{active : itemList.filterBorrower}">
-          <a href="javascript:;" ng-click="drawTable()">For My Patrons</a>
+        <li ng-class="{active : orientation_borrower}">
+          <a href="./fulfillment/borrower/{{tabname}}">For My Patrons</a>
         </li>
-        <li ng-class="{active : itemList.filterLender}">
-          <a href="javascript:;" ng-click="drawTable(true)">For Other Libraries</a>
+        <li ng-class="{active : orientation_lender}">
+          <a  href="./fulfillment/lender/{{tabname}}">For Other Libraries</a>
         </li>
       </ul>
     </div>
index bd60714..854756c 100644 (file)
@@ -1,12 +1,13 @@
 <ul class="nav nav-tabs">
   <li ng-class="{active : tab_pending}">
-    <a href="./fulfillment/pending">Pending Requests</a></li>
+    <a href="./fulfillment/borrower/pending">Pending Requests</a></li>
   <li ng-class="{active : tab_inbound}">
-    <a href="./fulfillment/inbound">Inbound Transits</a></li>
+    <a href="./fulfillment/borrower/inbound">Inbound Transits</a></li>
   <li ng-class="{active : tab_outbound}">
-    <a href="./fulfillment/outbound">Outbound Transits</a></li>
+    <!-- only one where default view is lender - could be confusing? -->
+    <a href="./fulfillment/lender/outbound">Outbound Transits</a></li>
   <li ng-class="{active : tab_circulating}">
-    <a href="./fulfillment/circulating">Currently Circulating</a></li>
+    <a href="./fulfillment/borrower/circulating">Currently Circulating</a></li>
   <li ng-class="{active : tab_status}">
     <a href="./fulfillment/status">Item Status</a></li>
 </ul>
index 5f59793..6d5e780 100644 (file)
@@ -4,11 +4,11 @@
   <div class="row command-bar">
     <div class="col-lg-6">
       <ul class="nav nav-pills">
-        <li ng-class="{active : itemList.filterBorrower}">
-          <a href="javascript:;" ng-click="drawTable()">Items For My Patrons</a>
+        <li ng-class="{active : orientation_borrower}">
+          <a  href="./fulfillment/borrower/{{tabname}}">Items For My Patrons</a>
         </li>
-        <li ng-class="{active : itemList.filterLender}">
-          <a href="javascript:;" ng-click="drawTable(true)">My Returns</a>
+        <li ng-class="{active : orientation_lender}">
+          <a  href="./fulfillment/lender/{{tabname}}">My Returns</a>
         </li>
       </ul>
     </div>
index d9f6547..7e61161 100644 (file)
@@ -3,11 +3,11 @@
   <div class="row command-bar">
     <div class="col-lg-6">
       <ul class="nav nav-pills">
-        <li ng-class="{active : itemList.filterLender}">
-          <a href="javascript:;" ng-click="drawTable(true)">Items For Other Libraries</a>
+        <li ng-class="{active : orientation_lender}">
+          <a  href="./fulfillment/lender/{{tabname}}">Items For Other Libraries</a>
         </li>
-        <li ng-class="{active : itemList.filterBorrower}">
-          <a href="javascript:;" ng-click="drawTable()">Returns to Other Libraries</a>
+        <li ng-class="{active : orientation_borrower}">
+          <a  href="./fulfillment/borrower/{{tabname}}">Returns to Other Libraries</a>
         </li>
       </ul>
     </div>
index f079322..25e9ba3 100644 (file)
@@ -5,11 +5,11 @@
   <div class="row command-bar">
     <div class="col-lg-6">
       <ul class="nav nav-pills">
-        <li ng-class="{active : itemList.filterBorrower}">
-          <a href="javascript:;" ng-click="drawTable()">Hold for My Patrons</a>
+        <li ng-class="{active : orientation_borrower}">
+          <a href="./fulfillment/borrower/{{tabname}}">Hold for My Patrons</a>
         </li>
-        <li ng-class="{active : itemList.filterLender}">
-          <a href="javascript:;" ng-click="drawTable(true)">Holds for Other Libraries</a>
+        <li ng-class="{active : orientation_lender}">
+          <a href="./fulfillment/lender/{{tabname}}">Holds for Other Libraries</a>
         </li>
       </ul>
     </div>
index 78db9fb..0a5dde8 100644 (file)
@@ -22,22 +22,30 @@ angular.module('ffMain', ['ngRoute', 'egCoreMod', 'egUiMod', 'egUserMod'])
         controller: 'RecordsCtrl',
         resolve : resolver
     });
-    
-    // Default to ILL management tabs
+
     $routeProvider.when('/fulfillment/status/:barcode', {
         templateUrl: './fulfillment/t_ill',
         controller: 'ILLCtrl',
         resolve : resolver
     });
 
+    $routeProvider.when('/fulfillment/status', {
+        templateUrl: './fulfillment/t_ill',
+        controller: 'ILLCtrl',
+        resolve : resolver
+    });
 
-    // Default to ILL management tabs
-    $routeProvider.otherwise({
+    $routeProvider.when('/fulfillment/:orientation/:tab', {
         templateUrl: './fulfillment/t_ill',
         controller: 'ILLCtrl',
         resolve : resolver
     });
 
+    // Default to ILL management tabs
+    $routeProvider.otherwise({
+        redirectTo : '/fulfillment/borrower/pending'
+    });
+
     $locationProvider.html5Mode(true);
 })
 
@@ -125,9 +133,16 @@ function ($scope, $route, egStartup, ffService, egAuth, egUser) {
 function ($scope, $q, $compile, $timeout, $rootScope, $location, 
     $route, $routeParams, egNet, egAuth, ffService, egOrg) {
 
-    // tabs
-    var mytab = $location.path().match(/\/fulfillment\/([^\/]+)/)[1];
-    $scope['tab_' + mytab] = true;
+    $scope.tabname = $routeParams.tab;
+    $scope.orientation = $routeParams.orientation;
+
+    // URL format for /status needs a wee bit of manual handling
+    if (!$scope.tabname) $scope.tabname = 'status';
+
+    // bools useful for templates
+    $scope['tab_' + $scope.tabname] = true;
+    $scope['orientation_' + $scope.orientation] = true;
+
 
     // so our child controllers can access our route info
     $scope.illRouteParams = $routeParams;
@@ -139,13 +154,6 @@ function ($scope, $q, $compile, $timeout, $rootScope, $location,
         selected : {},
         limit : 10, // TODO UI
         offset : 0, // TODO UI
-        filter_borrwer : true,
-        filterLender : false,
-
-        toggleFilters : function(lender) {
-            $scope.itemList.filterBorrower = !lender;
-            $scope.itemList.filterLender = lender;
-        },
 
         // select all rows in the list.  if any are 
         // already selected, de-select all.
@@ -506,17 +514,16 @@ function ($scope, $q, $compile, $timeout, $rootScope, $location,
 ['$scope', '$q', 'egPCRUD', 'ffService',
 function ($scope, $q, egPCRUD, ffService) {
 
-    $scope.drawTable = function(filterLender) {
+    $scope.drawTable = function() {
         var deferred = $q.defer();
         $scope.itemList.items = [];
-        $scope.itemList.toggleFilters(filterLender);
 
         var fullPath = ffService.relatedOrgs();
 
         var dest = fullPath; // inbound transits
         var circ_lib = fullPath; // our copies
 
-        if ($scope.itemList.filterBorrower) {
+        if ($scope.orientation_borrower) {
             // borrower always means not-our-copies
             circ_lib = {'not in' : fullPath};
         }
@@ -563,17 +570,16 @@ function ($scope, $q, egPCRUD, ffService) {
 ['$scope', '$q', 'egPCRUD', 'ffService',
 function ($scope, $q, egPCRUD, ffService) {
 
-    $scope.drawTable = function(filterLender) {
+    $scope.drawTable = function() {
         var deferred = $q.defer();
         $scope.itemList.items = [];
-        $scope.itemList.toggleFilters(filterLender);
 
         var fullPath = ffService.relatedOrgs();
 
         var copy_lib = fullPath; // our copies
         var circ_lib = fullPath; // circulating here
 
-        if ($scope.itemList.filterLender) {
+        if ($scope.orientation_lender) {
             // borrower always means not-our-copies
             circ_lib = {'not in' : fullPath};
         } else {
@@ -691,7 +697,7 @@ function ($scope, $q, $route, egNet, egAuth, egPCRUD, egOrg, ffService) {
         if (hold_blob.volume) {
             display.call_number = hold_blob.volume.label();
         }
-        if ($scope.itemList.filterLender) 
+        if ($scope.orientation_lender) 
             display.next_action = 'ill-home-capture';
     };
 
@@ -725,10 +731,8 @@ function ($scope, $q, $route, egNet, egAuth, egPCRUD, egOrg, ffService) {
     );
     */
 
-    $scope.drawTable = function(filterLender) {
+    $scope.drawTable = function() {
         $scope.itemList.items = [];
-        $scope.itemList.toggleFilters(filterLender);
-
         var fullPath = ffService.relatedOrgs();
 
         var query = {   
@@ -737,7 +741,7 @@ function ($scope, $q, $route, egNet, egAuth, egPCRUD, egOrg, ffService) {
             frozen : 'f'
         };
 
-        if ($scope.itemList.filterBorrower) {
+        if ($scope.orientation_borrower) {
             // holds for my patrons originate "here"
             // current_copy is not relevant
             query.request_lib = fullPath;
@@ -791,17 +795,17 @@ function ($scope, $q, $route, egNet, egAuth, egPCRUD, egOrg, ffService) {
 
     $scope.firstPage = function() {
         $scope.itemList.offset = 0;
-        $scope.drawTable($scope.itemList.filterLender == true);
+        $scope.drawTable();
     };
 
     $scope.nextPage = function() {
         $scope.itemList.offset += $scope.itemList.limit;
-        $scope.drawTable($scope.itemList.filterLender == true);
+        $scope.drawTable();
     };
 
     $scope.prevPage = function() {
         $scope.itemList.offset -= $scope.itemList.limit;
-        $scope.drawTable($scope.itemList.filterLender == true);
+        $scope.drawTable();
     };
 
     $scope.drawTable();