webstaff: Enable Fast Item Add functionality in the MARC editor, and improve button...
authorMike Rylander <mrylander@gmail.com>
Fri, 4 Sep 2015 12:47:03 +0000 (08:47 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Mon, 14 Sep 2015 19:44:19 +0000 (15:44 -0400)
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/src/templates/staff/cat/share/t_marcedit.tt2
Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js
Open-ILS/web/js/ui/default/staff/cat/volcopy/app.js

index eef0f6a..eba2c17 100644 (file)
@@ -1,34 +1,48 @@
 <div>
-  <div ng-if="bre" class="row col-md-12 pad-vert marcfastitemadd" ng-hide="brandNewRecord">
-    <input id="mfiacn" type="text" placeholder="[% l('Call Number') %]" ng-model="fast_item_callnumber"/>
-    <input id="mfiabc" type="text" placeholder="[% l('Barcode') %]" ng-model="fast_item_barcode"/>
-    <button class="btn btn-default" ng-click="saveFastItem()">Add Item</button>
+  <div ng-show="bre" class="row pad-vert marcfastitemadd" ng-hide="brandNewRecord">
+    <div class="col-md-2">
+      <label><input type="checkbox" ng-model="enable_fast_add"/> [% l('Add Item') %]</label>
+    </div>
+    <div class="col-md-2">
+      <input id="mfiacn" class="form-control" ng-show="enable_fast_add" type="text" placeholder="[% l('Call Number') %]" ng-model="fast_item_callnumber"/>
+    </div>
+    <div class="col-md-2">
+      <input id="mfiabc" class="form-control" ng-show="enable_fast_add" type="text" placeholder="[% l('Barcode') %]" ng-model="fast_item_barcode"/>
+    </div>
   </div>
 
-  <div class="pad-vert row col-md-12 marctypesource">
+  <div class="pad-vert row marctypesource">
     <div class="col-md-2">
-      <label>Flat Text Editor:</label>
-      <input type="checkbox" ng-model="flatEditor" ng-change="refreshVisual()"/>
+      <label>
+        <input type="checkbox" ng-model="flatEditor" ng-change="refreshVisual()"/>
+        [% l('Flat Text Editor') %]
+      </label>
     </div>
     <div class="col-md-2">
-      <label>Record Type:</label>
-      {{calculated_record_type}}
+      <div class="input-group">
+        <span class="input-group-addon"><b>[% l('Record Type') %]</b></span>
+        <span class="input-group-addon">{{calculated_record_type}}</span>
+      </div>
     </div>
     <div ng-if="bre" class="col-md-2">
       <eg-marc-edit-bibsource/>
     </div>
-    <div class="col-md-1">
-      <button class="btn btn-default" ng-show="record_type == 'bre'" ng-click="validateHeadings()">[% l('Validate') %]</button>
-    </div>
-    <div class="col-md-1">
-      <button class="btn btn-default" ng-click="saveRecord()">Save</button>
-    </div>
-    <div class="col-md-1">
-      <button class="btn btn-default" ng-click="seeBreaker()">Breaker</button>
-    </div>
-    <div class="col-md-1" ng-hide="brandNewRecord">
-      <button ng-hide="Record().deleted()" class="btn btn-default" ng-click="deleteRecord()">Delete</button>
-      <button ng-show="Record().deleted()" class="btn btn-default" ng-click="undeleteRecord()">Undelete</button>
+    <div class="col-md-6">
+      <div class="btn-group">
+        <span class="btn-group">
+          <button class="btn btn-default" ng-show="record_type == 'bre'" ng-click="validateHeadings()">[% l('Validate') %]</button>
+        </span>
+        <span class="btn-group">
+          <button class="btn btn-default" ng-click="saveRecord()">[% l('Save') %]</button>
+        </span>
+        <span class="btn-group">
+          <button class="btn btn-default" ng-click="seeBreaker()">[% l('Breaker') %]</button>
+        </span>
+        <span class="btn-group">
+          <button ng-hide="brandNewRecord || Record().deleted()" class="btn btn-default" ng-click="deleteRecord()">[% l('Delete') %]</button>
+          <button ng-if="!brandNewRecord && Record().deleted()" class="btn btn-default" ng-click="undeleteRecord()">[% l('Undelete') %]</button>
+        </span>
+      </div>
     </div>
   </div>
 
index 119644d..056c34e 100644 (file)
@@ -502,11 +502,14 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
             });
 
         },
-        controller : ['$timeout','$scope','$q','egCore', 'egTagTable',
-            function ( $timeout , $scope , $q,  egCore ,  egTagTable ) {
+        controller : ['$timeout','$scope','$q','$window','egCore', 'egTagTable',
+            function ( $timeout , $scope , $q,  $window , egCore ,  egTagTable ) {
 
                 MARC21.Record.delimiter = '$';
 
+                $scope.enable_fast_add = false;
+                $scope.fast_item_callnumber = '';
+                $scope.fast_item_barcode = '';
                 $scope.flatEditor = false;
                 $scope.brandNewRecord = false;
                 $scope.bib_source = null;
@@ -1044,7 +1047,30 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
                     if ($scope.recordId) {
                         return egCore.pcrud.update(
                             $scope.Record()
-                        ).then(loadRecord);
+                        ).then(function() {
+                            if ($scope.enable_fast_add) {
+                                egCore.net.request(
+                                    'open-ils.actor',
+                                    'open-ils.actor.anon_cache.set_value',
+                                    null, 'edit-these-copies', {
+                                        record_id: $scope.recordId,
+                                        raw: [{
+                                            label : $scope.fast_item_callnumber,
+                                            barcode : $scope.fast_item_barcode,
+                                        }],
+                                        hide_vols : false,
+                                        hide_copies : false
+                                    }
+                                ).then(function(key) {
+                                    if (key) {
+                                        var url = egCore.env.basePath + 'cat/volcopy/' + key;
+                                        $timeout(function() { $window.open(url, '_blank') });
+                                    } else {
+                                        alert('Could not create anonymous cache key!');
+                                    }
+                                });
+                            }
+                        }).then(loadRecord);
                     } else {
                         $scope.Record().creator(egCore.auth.user().id());
                         $scope.Record().create_date('now');
@@ -1052,8 +1078,32 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
                             $scope.Record()
                         ).then(function(bre) {
                             $scope.recordId = bre.id(); 
+                            if ($scope.enable_fast_add) {
+                                egCore.net.request(
+                                    'open-ils.actor',
+                                    'open-ils.actor.anon_cache.set_value',
+                                    null, 'edit-these-copies', {
+                                        record_id: $scope.recordId,
+                                        raw: [{
+                                            label : $scope.fast_item_callnumber,
+                                            barcode : $scope.fast_item_barcode,
+                                        }],
+                                        hide_vols : false,
+                                        hide_copies : false
+                                    }
+                                ).then(function(key) {
+                                    if (key) {
+                                        var url = egCore.env.basePath + 'cat/volcopy/' + key;
+                                        $timeout(function() { $window.open(url, '_blank') });
+                                    } else {
+                                        alert('Could not create anonymous cache key!');
+                                    }
+                                });
+                            }
                         }).then(loadRecord);
                     }
+
+
                 };
 
                 $scope.seeBreaker = function () {
index 8cd4b78..0a3bafa 100644 (file)
@@ -809,6 +809,7 @@ function($scope , $q , $window , $routeParams , $location , $timeout , egCore ,
                     return itemSvc.fetchIds(data.copies);
 
                 if (data.raw && data.raw.length) {
+                    $scope.dirty = true;
 
                     /* data.raw data structure looks like this:
                      * [{