webstaff: implement add to record bucket from catalog view
authorGalen Charlton <gmc@esilibrary.com>
Tue, 8 Sep 2015 19:16:28 +0000 (19:16 +0000)
committerJason Stephenson <jstephenson@mvlc.org>
Mon, 14 Sep 2015 19:44:20 +0000 (15:44 -0400)
Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/src/templates/staff/cat/catalog/t_add_to_bucket.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/cat/catalog/t_catalog.tt2
Open-ILS/web/js/ui/default/staff/cat/catalog/app.js

diff --git a/Open-ILS/src/templates/staff/cat/catalog/t_add_to_bucket.tt2 b/Open-ILS/src/templates/staff/cat/catalog/t_add_to_bucket.tt2
new file mode 100644 (file)
index 0000000..eb53d04
--- /dev/null
@@ -0,0 +1,34 @@
+<div class="modal-header">
+  <button type="button" class="close" ng-click="cancel()"
+    aria-hidden="true">&times;</button>
+  <h4 class="modal-title">[% l('Add To Bucket') %]</h4>
+</div>
+<div class="modal-body">
+  <div class="row">
+    <div class="form-inline">
+      <div class="form-gruop">
+        <label for="select-bucket">[% l('Copy this record into which bucket?') %]</label>
+        <select id="select-bucket" class="form-control" ng-model="bucket_id"
+                ng-options="bucket.name() for bucket in allBuckets track by bucket.id()">
+        </select>
+        <button class="btn btn-primary" ng-class="{disabled : !bucket_id}" 
+                ng-click="add_to_bucket()">[% l('Add To Selected Bucket') %]</button>
+      </div>
+    </div>
+  </div>
+  <div class="row">
+    <div class="form-inline">
+      <div class="form-gruop">
+        <label for="new-bucket-name">[% l('Name For New Bucket') %]</label>
+        <input type="text" class="form-control" id="new-bucket-name" ng-model="newBucketName" />
+        <button class="btn btn-primary" ng-class="{disabled : !newBucketName}"
+                ng-click="add_to_new_bucket()">[% l('Add To New Bucket') %]</button>
+      </div>
+  </div>
+  </div>
+</div>
+<div class="modal-footer">
+  <div class="col-md-6 pull-right">
+    <button class="btn btn-warning" ng-click="cancel($event)">[% l('Cancel') %]</button>
+  </div>
+</div>
index f7477b1..9b5eaba 100644 (file)
        [% l('Back To Results') %]
     </button>
   </div>
+  <div class="col-md-3">
+    <button type="button" class="btn btn-default" ng-click="add_to_record_bucket()">
+        [% l('Add To Bucket') %]
+    </button>
+  </div>
 </div>
 
 <ul class="nav nav-tabs">
index 4177943..5c8f917 100644 (file)
@@ -250,6 +250,63 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
         }
     }
 
+    $scope.add_to_record_bucket = function() {
+        var recId = $scope.record_id;
+        return $modal.open({
+            templateUrl: './cat/catalog/t_add_to_bucket',
+            animation: true,
+            size: 'md',
+            controller:
+                   ['$scope','$modalInstance',
+            function($scope , $modalInstance) {
+
+                $scope.bucket_id = 0;
+                $scope.newBucketName = '';
+                $scope.allBuckets = [];
+                egCore.net.request(
+                    'open-ils.actor',
+                    'open-ils.actor.container.retrieve_by_class.authoritative',
+                    egCore.auth.token(), egCore.auth.user().id(),
+                    'biblio', 'staff_client'
+                ).then(function(buckets) { $scope.allBuckets = buckets; });
+
+                $scope.add_to_bucket = function() {
+                    var item = new egCore.idl.cbrebi();
+                    item.bucket($scope.bucket_id);
+                    item.target_biblio_record_entry(recId);
+                    egCore.net.request(
+                        'open-ils.actor',
+                        'open-ils.actor.container.item.create',
+                        egCore.auth.token(), 'biblio', item
+                    ).then(function(resp) {
+                        $modalInstance.close();
+                    });
+                }
+
+                $scope.add_to_new_bucket = function() {
+                    var bucket = new egCore.idl.cbreb();
+                    bucket.owner(egCore.auth.user().id());
+                    bucket.name($scope.newBucketName);
+                    bucket.description('');
+                    bucket.btype('staff_client');
+
+                    egCore.net.request(
+                        'open-ils.actor',
+                        'open-ils.actor.container.create',
+                        egCore.auth.token(), 'biblio', bucket
+                    ).then(function(bucket) {
+                        $scope.bucket_id = bucket;
+                        $scope.add_to_bucket();
+                    });
+                }
+
+                $scope.cancel = function() {
+                    $modalInstance.dismiss();
+                }
+            }]
+        });
+    }
+
     $scope.stop_unload = false;
     $scope.$watch('stop_unload',
         function(newVal, oldVal) {