LP#1402797 Implement retrieve record by id and tcn
authorMike Rylander <mrylander@gmail.com>
Wed, 14 Jan 2015 22:20:23 +0000 (17:20 -0500)
committerBill Erickson <berickxx@gmail.com>
Wed, 25 Feb 2015 16:16:05 +0000 (11:16 -0500)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/templates/staff/cat/catalog/t_retrieve_by_id.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/cat/catalog/t_retrieve_by_tcn.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/navbar.tt2
Open-ILS/web/js/ui/default/staff/cat/catalog/app.js

diff --git a/Open-ILS/src/templates/staff/cat/catalog/t_retrieve_by_id.tt2 b/Open-ILS/src/templates/staff/cat/catalog/t_retrieve_by_id.tt2
new file mode 100644 (file)
index 0000000..785b52d
--- /dev/null
@@ -0,0 +1,22 @@
+
+<form ng-submit="submitId(args)" role="form" class="form-inline">
+  <div class="input-group">
+
+    <label class="input-group-addon" 
+      for="record-retreive-id" >[% l('Bib Record Id') %]</label>
+
+    <input select-me="selectMe" class="form-control"
+      ng-model="args.record_id" focus-me="focusMe"
+      placeholder="[% l('Bib Record Id') %]"
+      id="record-retreive-id" type="text"/> 
+
+  </div>
+  <input class="btn btn-default" type="submit" value="[% l('Submit') %]"/>
+</form>
+
+<br/>
+<div class="alert alert-warning" ng-show="recordNotFound">
+  [% l('Bib Record Not Found: [_1]', '{{recordNotFound}}') %]
+</div>
+
+
diff --git a/Open-ILS/src/templates/staff/cat/catalog/t_retrieve_by_tcn.tt2 b/Open-ILS/src/templates/staff/cat/catalog/t_retrieve_by_tcn.tt2
new file mode 100644 (file)
index 0000000..e8a86a6
--- /dev/null
@@ -0,0 +1,25 @@
+
+<form ng-submit="submitTCN(args)" role="form" class="form-inline">
+  <div class="input-group">
+
+    <label class="input-group-addon" 
+      for="record-retreive-tcn" >[% l('Bib Record TCN') %]</label>
+
+    <input select-me="selectMe" class="form-control"
+      ng-model="args.record_tcn" focus-me="focusMe"
+      placeholder="[% l('Bib Record TCN') %]"
+      id="record-retreive-tcn" type="text"/> 
+
+  </div>
+  <input class="btn btn-default" type="submit" value="[% l('Submit') %]"/>
+</form>
+
+<br/>
+<div class="alert alert-warning" ng-show="moreRecordsFound">
+  [% l('More than one Bib Record found with TCN: [_1]', '{{recordNotFound}}') %]
+</div>
+<div class="alert alert-warning" ng-show="recordNotFound">
+  [% l('Bib Record Not Found: [_1]', '{{recordNotFound}}') %]
+</div>
+
+
index 018a93f..e94b1ea 100644 (file)
               [% l('Record Buckets') %]
             </a>
           </li>
+          <li class="divider"></li>
+          <li>
+            <a href="./cat/catalog/retrieve_by_id" target="_self">
+              <span class="glyphicon glyphicon-file"></span>
+              [% l('Retrieve Bib Record by ID') %]
+            </a>
+          </li>
+          <li>
+            <a href="./cat/catalog/retrieve_by_tcn" target="_self">
+              <span class="glyphicon glyphicon-tag"></span>
+              [% l('Retrieve Bib Record by TCN') %]
+            </a>
+          </li>
           <li>
             <a href="" ng-click="retrieveLastRecord()" target="_self">
               <span class="glyphicon glyphicon-share-alt"></span>
index 9e9ad7d..f41a3fe 100644 (file)
@@ -22,6 +22,18 @@ angular.module('egCatalogApp', ['ui.bootstrap','ngRoute','egCoreMod','egGridMod'
         resolve : resolver
     });
 
+    $routeProvider.when('/cat/catalog/retrieve_by_id', {
+        templateUrl: './cat/catalog/t_retrieve_by_id',
+        controller: 'CatalogRecordRetrieve',
+        resolve : resolver
+    });
+
+    $routeProvider.when('/cat/catalog/retrieve_by_tcn', {
+        templateUrl: './cat/catalog/t_retrieve_by_tcn',
+        controller: 'CatalogRecordRetrieve',
+        resolve : resolver
+    });
+
     // create some catalog page-specific mappings
     $routeProvider.when('/cat/catalog/record/:record_id', {
         templateUrl: './cat/catalog/t_catalog',
@@ -42,6 +54,68 @@ angular.module('egCatalogApp', ['ui.bootstrap','ngRoute','egCoreMod','egGridMod'
 
 /**
  * */
+.controller('CatalogRecordRetrieve',
+       ['$scope','$routeParams','$location','$q','egCore',
+function($scope , $routeParams , $location , $q , egCore ) {
+
+    $scope.focusMe = true;
+
+    // jump to the patron checkout UI
+    function loadRecord(record_id) {
+        $location
+        .path('/cat/catalog/record/' + record_id);
+    }
+
+    $scope.submitId = function(args) {
+        $scope.recordNotFound = null;
+        if (!args.record_id) return;
+
+        // blur so next time it's set to true it will re-apply select()
+        $scope.selectMe = false;
+
+        return loadRecord(args.record_id);
+    }
+
+    $scope.submitTCN = function(args) {
+        $scope.recordNotFound = null;
+        $scope.moreRecordsFound = null;
+        if (!args.record_tcn) return;
+
+        // blur so next time it's set to true it will re-apply select()
+        $scope.selectMe = false;
+
+        // lookup TCN
+        egCore.net.request(
+            'open-ils.search',
+            'open-ils.search.biblio.tcn',
+            args.record_tcn)
+
+        .then(function(resp) { // get_barcodes
+
+            if (evt = egCore.evt.parse(resp)) {
+                alert(evt); // FIXME
+                return;
+            }
+
+            if (!resp.count) {
+                $scope.recordNotFound = args.record_tcn;
+                $scope.selectMe = true;
+                return;
+            }
+
+            if (resp.count > 1) {
+                $scope.moreRecordsFound = args.record_tcn;
+                $scope.selectMe = true;
+                return;
+            }
+
+            var record_id = resp.ids[0];
+            return loadRecord(record_id);
+        });
+    }
+
+}])
+
 .controller('CatalogCtrl',
        ['$scope','$routeParams','$location','$q','egCore','egHolds',
         'egGridDataProvider','egHoldGridActions',