webstaff: Z39.50 - yet more improvements
authorGalen Charlton <gmc@esilibrary.com>
Tue, 28 Jul 2015 15:04:16 +0000 (15:04 +0000)
committerJason Stephenson <jstephenson@mvlc.org>
Wed, 19 Aug 2015 17:39:20 +0000 (13:39 -0400)
* change binding of marc_xml
* implement edit-then-overlay
* add search-in-progress indicator
* implement display of total hit count
* implement remove fields on import

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Open-ILS/src/templates/staff/cat/z3950/t_edit_overlay_record.tt2 [new file with mode: 0644]
Open-ILS/src/templates/staff/cat/z3950/t_list.tt2
Open-ILS/src/templates/staff/cat/z3950/t_marc_edit.tt2
Open-ILS/src/templates/staff/cat/z3950/t_overlay.tt2
Open-ILS/web/js/ui/default/staff/cat/z3950/app.js

diff --git a/Open-ILS/src/templates/staff/cat/z3950/t_edit_overlay_record.tt2 b/Open-ILS/src/templates/staff/cat/z3950/t_edit_overlay_record.tt2
new file mode 100644 (file)
index 0000000..3372bcf
--- /dev/null
@@ -0,0 +1,16 @@
+<div>
+  <div class="modal-header">
+    <button type="button" class="close"
+      ng-click="cancel()" aria-hidden="true">&times;</button>
+    <h4 class="modal-title">[% l('Edit Overlay Record') %]</h4>
+  </div>
+  <div class="modal-body">
+    <eg-marc-edit-record dirty-flag="dirty_flag" record-id="record_id" marc-xml="args.marc_xml"
+                         in-place-mode="true" />
+  </div>
+  <div class="modal-footer">
+    <input type="submit" ng-click="ok(args)"
+        class="btn btn-primary" value="[% l('Use Edits') %]"/>
+    <button class="btn btn-warning" ng-click="cancel()">[% l('Cancel') %]</button>
+  </div>
+</div>
index 23349b9..86292c9 100644 (file)
     </form>
 </div>
 
-<div class="text-right" ng-if="local_overlay_target">
-[% l('Record with TCN [_1] marked for overlay.', '{{local_overlay_target}}') %]"
+<div class="panel panel-default" ng-show="field_strip_groups.length">
+  <div class="panel-heading">[% l('Remove Fields on Import') %]</div>
+  <div class="panel-body">
+    <div class="row">
+      <div class="col-sm-3 checkbox-inline" ng-repeat="grp in field_strip_groups">
+        <label for="strip-grp-{{grp.id()}}">{{grp.label()}}</label>
+        <input id='strip-grp-{{grp.id()}}' ng-model="grp.selected" type="checkbox"/>
+      </div>
+    </div>
+  </div>
+</div>
+
+<div class="row" ng-show="searchInProgress">
+  <div class="col-md-6">
+    <div class="progress progress-striped active">
+        <div class="progress-bar"  role="progressbar" aria-valuenow="100"
+              aria-valuemin="0" aria-valuemax="100" style="width: 100%">
+            <span class="sr-only">[% l('Searching...') %]</span>
+        </div>
+    </div>
+  </div>
 </div>
-<div class="text-right" ng-if="!local_overlay_target">
-[% l('No record marked for overlay.') %]
+
+<div class="row">
+    <div class="col-md-6">
+        [% l('Total hits: [_1]', '{{total_hits}}') %]
+    </div>
+    <div class="col-md-6 text-right" ng-if="local_overlay_target">
+        [% l('Record with TCN [_1] marked for overlay.', '{{local_overlay_target}}') %]"
+    </div>
+    <div class="col-md-6 text-right" ng-if="!local_overlay_target">
+        [% l('No record marked for overlay.') %]
+    </div>
 </div>
 
 
index 97e448c..214aaa3 100644 (file)
@@ -5,7 +5,7 @@
     <h4 class="modal-title">[% l('Import Record') %]</h4>
   </div>
   <div class="modal-body">
-    <eg-marc-edit-record dirty-flag="dirty_flag" record-id="record_id" marc-xml="{{marc_xml}}"/>
+    <eg-marc-edit-record dirty-flag="dirty_flag" record-id="record_id" marc-xml="marc_xml"/>
   </div>
   <div class="modal-footer">
     <button class="btn btn-warning" ng-click="cancel()">[% l('Cancel') %]</button>
index c7290b1..bb51345 100644 (file)
@@ -1,26 +1,28 @@
-<form class="form-validated" novalidate name="form" ng-submit="ok(args)">
-  <div>
-    <div class="modal-header">
-      <button type="button" class="close"
-        ng-click="cancel()" aria-hidden="true">&times;</button>
-      <h4 class="modal-title">[% l('Overlay record?') %]</h4>
-    </div>
-    <div class="modal-body">
-        <div class="row">
-            <div class="col-xs-6">
-                <div>[% l('Replace TCN [_1] ...', '{{overlay_target}}') %]</div>
-                <eg-record-html record-id="overlay_target" />
-            </div>
-            <div class="col-xs-6">
-                <div>[% l('With this?') %]</div>
-                <eg-record-html marc-xml="{{marc_xml}}" />
-            </div>
-        </div>
-    </div>
-    <div class="modal-footer">
-      <input type="submit" ng-disabled="form.$invalid"
-          class="btn btn-primary" value="[% l('Overlay') %]"/>
-      <button class="btn btn-warning" ng-click="cancel()">[% l('Cancel') %]</button>
-    </div>
+<div>
+  <div class="modal-header">
+    <button type="button" class="close"
+      ng-click="cancel()" aria-hidden="true">&times;</button>
+    <h4 class="modal-title">[% l('Overlay record?') %]</h4>
   </div>
-</form>
+  <div class="modal-body">
+      <div class="row">
+          <div class="col-xs-6">
+              <div>[% l('Replace TCN [_1] ...', '{{overlay_target}}') %]</div>
+              <eg-record-html record-id="overlay_target" />
+          </div>
+          <div class="col-xs-6">
+              <div>[% l('With this?') %]
+                  <button class="btn btn-default" ng-click="editOverlayRecord()">
+                      [% l('Edit') %]
+                  </button>
+              </div>
+              <eg-record-html marc-xml="{{args.marc_xml}}" />
+          </div>
+      </div>
+  </div>
+  <div class="modal-footer">
+    <input type="submit" ng-click="ok(args)"
+        class="btn btn-primary" value="[% l('Overlay') %]"/>
+    <button class="btn btn-warning" ng-click="cancel()">[% l('Cancel') %]</button>
+  </div>
+</div>
index ffc0866..3b39d30 100644 (file)
@@ -33,6 +33,39 @@ function($scope , $q , $location , $timeout , $window,  egCore , egGridDataProvi
     egZ3950TargetSvc.loadTargets();
     egZ3950TargetSvc.loadActiveSearchFields();
 
+    $scope.field_strip_groups = [];
+    egCore.startup.go().then(function() {
+        // and list of field strip groups; need to ensure
+        // that enough of the startup has happened so that
+        // we have the user WS
+        egCore.pcrud.search('vibtg',
+            {
+                always_apply : 'f',
+                owner : {
+                    'in' : {
+                        select : {
+                            aou : [{
+                                column : 'id',
+                                transform : 'actor.org_unit_ancestors',
+                                result_field : 'id'
+                            }]
+                        },
+                        from : 'aou',
+                        where : {
+                            id : egCore.auth.user().ws_ou()
+                        }
+                    }
+                }
+            },
+            { order_by : { vibtq : ['label'] } }
+        ).then(null, null, function(strip_group) {
+            strip_group.selected = false;
+            $scope.field_strip_groups.push(strip_group);
+        });
+    });
+
+    $scope.total_hits = 0;
+
     var provider = egGridDataProvider.instance({});
 
     provider.get = function(offset, count) {
@@ -60,15 +93,22 @@ function($scope , $q , $location , $timeout , $window,  egCore , egGridDataProvi
         query['offset'] = offset;
 
         var resultIndex = offset;
+        $scope.total_hits = 0;
+        $scope.searchInProgress = true;
         egCore.net.request(
             'open-ils.search',
             method,
             egCore.auth.token(),
             query
         ).then(
-            function() { deferred.resolve() },
+            function() { $scope.searchInProgress = false; deferred.resolve() },
             null, // onerror
             function(result) {
+                // FIXME when the search offset is > 0, the
+                // total hits count can be wrong if one of the
+                // Z39.50 targets has fewer than $offset hits; in that
+                // case, result.count is not supplied.
+                $scope.total_hits += (result.count || 0);
                 for (var i in result.records) {
                     result.records[i].mvr['service'] = result.service;
                     result.records[i].mvr['index'] = resultIndex++;
@@ -155,6 +195,15 @@ function($scope , $q , $location , $timeout , $window,  egCore , egGridDataProvi
         return false;
     }
 
+    $scope.selectFieldStripGroups = function() {
+        var groups = [];
+        angular.forEach($scope.field_strip_groups, function(grp, idx) {
+            if (grp.selected) {
+                groups.push(grp.id());
+            }
+        });
+        return groups;
+    };
     $scope.import = function() {
         var deferred = $q.defer();
         var items = $scope.gridControls.selectedItems();
@@ -162,8 +211,11 @@ function($scope , $q , $location , $timeout , $window,  egCore , egGridDataProvi
             'open-ils.cat',
             'open-ils.cat.biblio.record.xml.import',
             egCore.auth.token(),
-            items[0]['marcxml']
-            // FIXME and more
+            items[0]['marcxml'],
+            null, // FIXME bib source
+            null,
+            null,
+            $scope.selectFieldStripGroups()
         ).then(
             function() { deferred.resolve() },
             null, // onerror
@@ -220,6 +272,9 @@ function($scope , $q , $location , $timeout , $window,  egCore , egGridDataProvi
     $scope.overlay_record = function() {
         var items = $scope.gridControls.selectedItems();
         var overlay_target = $scope.local_overlay_target;
+        var args = {
+            'marc_xml' : items[0]['marcxml']
+        };
         $modal.open({
             templateUrl: './cat/z3950/t_overlay',
             size: 'lg',
@@ -227,9 +282,26 @@ function($scope , $q , $location , $timeout , $window,  egCore , egGridDataProvi
                 ['$scope', '$modalInstance', function($scope, $modalInstance) {
                 $scope.focusMe = true;
                 $scope.overlay_target = overlay_target;
-                $scope.marc_xml = items[0]['marcxml'];
-                $scope.ok = function(args) { $modalInstance.close(args) }
-                $scope.cancel = function () { $modalInstance.dismiss() }
+                $scope.args = args;
+                $scope.ok = function(args) { $modalInstance.close(args) };
+                $scope.cancel = function () { $modalInstance.dismiss() };
+                $scope.editOverlayRecord = function() {
+                    $modal.open({
+                        templateUrl: './cat/z3950/t_edit_overlay_record',
+                        size: 'lg',
+                        controller:
+                            ['$scope', '$modalInstance', function($scope, $modalInstance) {
+                            $scope.focusMe = true;
+                            $scope.record_id = 0;
+                            $scope.dirty_flag = false;
+                            $scope.args = args;
+                            $scope.ok = function(args) { $modalInstance.close(args) }
+                            $scope.cancel = function () { $modalInstance.dismiss() }
+                        }]
+                    }).result.then(function (args) {
+                        if (!args || !args.name) return;
+                    });
+                };
             }]
         }).result.then(function (args) {
             egCore.net.request(
@@ -237,8 +309,10 @@ function($scope , $q , $location , $timeout , $window,  egCore , egGridDataProvi
                 'open-ils.cat.biblio.record.marc.replace',
                 egCore.auth.token(),
                 overlay_target,
-                items[0]['marcxml']
-                // FIXME and more
+                args.marc_xml,
+                null, // FIXME bib source
+                null,
+                $scope.selectFieldStripGroups()
             ).then(
                 function(result) {
                     console.debug('overlay complete');