webstaff: teach the merge record dialog how to edit volumes
authorGalen Charlton <gmc@esilibrary.com>
Mon, 5 Oct 2015 22:02:44 +0000 (22:02 +0000)
committerKathy Lussier <klussier@masslnc.org>
Tue, 2 Feb 2016 19:58:48 +0000 (14:58 -0500)
This adds an "edit volumes" button under each record in the
merge records interface that opens a modal embedding the
volume editor.

The embedding is done via an iframe in lieu of splitting the
relevant bits of the volume/copy editor into an independent
service.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Open-ILS/src/templates/staff/cat/bucket/record/index.tt2
Open-ILS/src/templates/staff/cat/share/t_embedded_volcopy.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/cat/share/t_volume_list.tt2
Open-ILS/web/js/ui/default/staff/cat/services/holdings.js

index 82d087b..24b5ac9 100644 (file)
@@ -8,6 +8,7 @@
 [% BLOCK APP_JS %]
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/services/grid.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/services/ui.js"></script>
+<script src="[% ctx.media_prefix %]/js/ui/default/staff/services/eframe.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/marcrecord.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/cat/services/record.js"></script>
 <script src="[% ctx.media_prefix %]/js/ui/default/staff/cat/services/tagtable.js"></script>
diff --git a/Open-ILS/src/templates/staff/cat/share/t_embedded_volcopy.tt2 b/Open-ILS/src/templates/staff/cat/share/t_embedded_volcopy.tt2
new file mode 100644 (file)
index 0000000..4c704d7
--- /dev/null
@@ -0,0 +1,14 @@
+<div>
+  <div class="modal-header">
+    <button type="button" class="close"
+      ng-click="cancel()" aria-hidden="true">&times;</button>
+    <h4 class="modal-title">[% l('Edit volumes') %]</h4>
+  </div>
+  <div class="modal-body">
+    <eg-embed-frame save-space="500" url="volcopy_url"></eg-embed-frame>
+  </div>
+  <div class="modal-footer">
+    <input type="submit" ng-click="ok()"
+        class="btn btn-primary" value="[% l('Done') %]"/>
+  </div>
+</div>
index db77586..56f1c07 100644 (file)
@@ -1,10 +1,12 @@
 <eg-grid
     id-field="index"
-    features="-menu,-index,-picker,-pagination,-action,-display,-sort,-multisort,-multiselect"
+    features="-index,-picker,-pagination,-action,-display,-sort,-multisort,-multiselect"
     items-provider="holdingsGridDataProvider"
     grid-controls="holdingsGridControls"
     persist-key="cat.record_overlay.holdings">
 
+    <eg-grid-menu-item handler="edit_volumes" label="[% l('Edit volumes') %]" />
+
     <eg-grid-field label="[% l('Owning Library') %]" path="owner_label" flex="4" align="right" visible></eg-grid-field>
     <eg-grid-field label="[% l('Call Number') %]"    path="call_number.label" visible></eg-grid-field>
     <eg-grid-field label="[% l('# Copies') %]"       path="copy_count" visible></eg-grid-field>
index 74ba520..0bebe6c 100644 (file)
@@ -281,8 +281,8 @@ function(egCore , $q) {
         },
         templateUrl: './cat/share/t_volume_list',
         controller:
-                   ['$scope','holdingsSvc','egCore','egGridDataProvider',
-            function($scope , holdingsSvc , egCore , egGridDataProvider) {
+                   ['$scope','holdingsSvc','egCore','egGridDataProvider','$modal',
+            function($scope , holdingsSvc , egCore , egGridDataProvider,  $modal) {
                 var holdingsSvcInst = new holdingsSvc();
 
                 $scope.holdingsGridControls = {};
@@ -291,6 +291,45 @@ function(egCore , $q) {
                         return this.arrayNotifier(holdingsSvcInst.copies, offset, count);
                     }
                 });
+
+                function gatherHoldingsIds () {
+                    var cp_id_list = [];
+                    angular.forEach(
+                        $scope.holdingsGridControls.allItems(),
+                        function (item) { cp_id_list = cp_id_list.concat(item.id_list) }
+                    );
+                    return cp_id_list;
+                }
+
+                $scope.edit_volumes = function () {
+                    egCore.net.request(
+                        'open-ils.actor',
+                        'open-ils.actor.anon_cache.set_value',
+                        null, 'edit-these-copies', {
+                            record_id: $scope.recordId,
+                            copies: gatherHoldingsIds(),
+                            hide_vols : false,
+                            hide_copies : true
+                        }
+                    ).then(function(key) {
+                        if (key) {
+                            $modal.open({
+                                templateUrl: './cat/share/t_embedded_volcopy',
+                                size: 'lg',
+                                controller:
+                                    ['$scope', '$modalInstance', function($scope, $modalInstance) {
+                                    $scope.volcopy_url = 
+                                        egCore.env.basePath + 'cat/volcopy/' + key + '/embedded';
+                                    $scope.ok = function(args) { $modalInstance.close(args) }
+                                    $scope.cancel = function () { $modalInstance.dismiss() }
+                                }]
+                            }).result.then(function() {
+                                load_holdings();
+                            });
+                        }
+                    });
+                }
+
                 function load_holdings() {
                     holdingsSvcInst.fetch({
                         rid   : $scope.recordId,