webstaff: Conjoined item attach-inator
authorMike Rylander <mrylander@gmail.com>
Tue, 8 Sep 2015 19:27:22 +0000 (15:27 -0400)
committerJason Stephenson <jstephenson@mvlc.org>
Mon, 14 Sep 2015 19:44:20 +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/catalog/t_conjoined_selector.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/cat/catalog/t_holdings.tt2
Open-ILS/web/js/ui/default/staff/cat/catalog/app.js

diff --git a/Open-ILS/src/templates/staff/cat/catalog/t_conjoined_selector.tt2 b/Open-ILS/src/templates/staff/cat/catalog/t_conjoined_selector.tt2
new file mode 100644 (file)
index 0000000..377c426
--- /dev/null
@@ -0,0 +1,25 @@
+<form ng-submit="ok(type)" role="form">
+    <div class="modal-header">
+      <button type="button" class="close" ng-click="cancel()" 
+        aria-hidden="true">&times;</button>
+      <h4 class="modal-title">[% l('Attach conjoined items') %]</h4>
+    </div>
+    <div class="modal-body">
+      <div class="row">
+        <div class="col-md-6">
+            <b>[% l('Peer Type:') %]</b>
+        </div>
+        <div class="col-md-6">
+          <select class="form-control" ng-options="t.id() as t.name() for t in peer_type_list" ng-model="type"></select>
+        </div>
+      </div>
+    </div>
+    <div class="modal-footer">
+      <div class="row">
+        <div class="col-md-12 pull-right">
+          <input type="submit" class="btn btn-primary" value="[% l('OK') %]"/>
+          <button class="btn btn-warning" ng-click="cancel($event)">[% l('Cancel') %]</button>
+        </div>
+      </div>
+    </div>
+</form>
index c5ab768..c7a1142 100644 (file)
@@ -35,6 +35,8 @@
 
     <eg-grid-action handler="requestItems"
       label="[% l('Request Items') %]"></eg-grid-action>
+    <eg-grid-action handler="attach_to_peer_bib"
+      label="[% l('Link as Conjoined to Previously Marked Bib Record') %]"></eg-grid-action>
 
     <eg-grid-action handler="selectedHoldingsItemStatus" group="[% l('Show') %]"
       label="[% l('Item Status (list)') %]"></eg-grid-action>
index 5c8f917..a5331d7 100644 (file)
@@ -814,6 +814,49 @@ function($scope , $routeParams , $location , $window , $q , egCore , egHolds , e
         });
     }
 
+    $scope.attach_to_peer_bib = function() {
+        var copy_list = gatherSelectedHoldingsIds();
+        if (copy_list.length == 0) return;
+
+        egCore.hatch.getItem('eg.cat.marked_conjoined_record').then(function(target_record) {
+            if (!target_record) return;
+
+            return $modal.open({
+                templateUrl: './cat/catalog/t_conjoined_selector',
+                animation: true,
+                controller:
+                       ['$scope','$modalInstance',
+                function($scope , $modalInstance) {
+                    $scope.peer_type = null;
+                    $scope.peer_type_list = [];
+                    holdingsSvc.get_peer_types().then(function(list){
+                        $scope.peer_type_list = list;
+                    });
+    
+                    $scope.ok = function(type) {
+                        var promises = [];
+    
+                        angular.forEach(copy_list, function (cp) {
+                            var n = new egCore.idl.bpbcm();
+                            n.isnew(true);
+                            n.peer_record(target_record);
+                            n.target_copy(cp);
+                            n.peer_type(type);
+                            promises.push(egCore.pcrud.create(n));
+                        });
+    
+                        return $q.all(promises).then(function(){$modalInstance.close()});
+                    }
+    
+                    $scope.cancel = function($event) {
+                        $modalInstance.dismiss();
+                        $event.preventDefault();
+                    }
+                }]
+            });
+        });
+    }
+
 
     // ------------------------------------------------------------------
     // Holds 
@@ -1285,6 +1328,18 @@ function(egCore , $q) {
         );
     }
 
+    // returns a promise resolved with the list of peer bib types
+    service.get_peer_types = function() {
+        if (egCore.env.bpt)
+            return $q.when(egCore.env.bpt.list);
+
+        return egCore.pcrud.retrieveAll('bpt', null, {atomic : true})
+        .then(function(list) {
+            egCore.env.absorbList(list, 'bpt');
+            return list;
+        });
+    };
+
     return service;
 }])