LP1776736 Record merge marc edit repairs
authorBill Erickson <berickxx@gmail.com>
Thu, 14 Mar 2019 16:03:58 +0000 (12:03 -0400)
committerDan Wells <dbw2@calvin.edu>
Wed, 20 Mar 2019 19:10:05 +0000 (15:10 -0400)
1. Fixes issues where edits to MARC records would fail to save during
   merge.

2. Provide options to select flat or non-flat text editor in edit mode
   for record merges.

3. Allow record editor action buttons/selectors to flow down
   horizontally when they don't fit in a narrow space.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>

Open-ILS/src/templates/staff/cat/bucket/record/t_merge_records.tt2
Open-ILS/src/templates/staff/cat/share/t_marcedit.tt2
Open-ILS/src/templates/staff/css/cat.css.tt2
Open-ILS/web/js/ui/default/staff/cat/bucket/record/app.js
Open-ILS/web/js/ui/default/staff/cat/services/marcedit.js

index 1a5ee26..cdfed19 100644 (file)
@@ -42,8 +42,7 @@
               <button class="btn btn-default btn-sm" ng-class="{disabled : editing_inplace}" 
                 ng-click="edit_lead()">[% l('Edit using full editor') %]</button>
               <eg-marc-edit-record dirty-flag="dirty_flag" marc-xml="lead.marc_xml"
-                 in-place-mode="true"
-                 record-type="bre" flat-only="true" embedded="true" 
+                 in-place-mode="true" record-type="bre" embedded="true" 
                  ng-show="editing_inplace" on-save="post_edit_inplace">
               </eg-marc-edit-record>
               <eg-record-breaker record-id="lead_id" marc-xml="lead.marc_xml" 
index dc6b11d..5ba7859 100644 (file)
     </div>
   </div>
 
-  <div class="pad-vert row marctypesource">
-    <div class="col-md-2 form-group" ng-show="!flatOnly">
+  <div class="pad-vert pad-left row flex-row marctypesource">
+    <div class="form-group pad-horiz" ng-show="!flatOnly">
       <label>
         <input type="checkbox" ng-model="flatEditor.isEnabled" ng-change="refreshVisual()"/>
         [% l('Flat Text Editor') %]
       </label>
     </div>
-    <div class="col-md-2 form-group" ng-show="!flatOnly">
+    <div class="form-group pad-horiz" ng-show="!flatOnly">
       <label>
         <input type="checkbox" ng-model="stackSubfields.enabled" />
         [% l('Stack subfields') %]
       </label>
     </div>
-    <div class="col-md-3">
-      <div class="input-group">
+    <div class="">
+      <div class="input-group pad-horiz">
         <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">
+    <div ng-if="bre" class="pad-horiz">
       <eg-marc-edit-bibsource/>
     </div>
-    <div class="col-md-3">
+    <div class="pad-horiz">
       <div class="btn-group">
         <span class="btn-group">
           <button class="btn btn-default" ng-show="record_type == 'bre' && !flatOnly" ng-click="validateHeadings()">[% l('Validate') %]</button>
index cbbdfba..4a05b28 100644 (file)
@@ -18,6 +18,7 @@
 
 .marcfastitemadd, .marctypesource {
     border-bottom: solid thin gray;
+    flex-wrap: wrap;
 }
 
 .marcedit {
index 769f9f8..a9fa25e 100644 (file)
@@ -557,6 +557,25 @@ function($scope,  $q , $routeParams,  bucketSvc,  egCore,  $window,
         egHolds.transfer_all_bib_holds_to_marked_title(bib_ids);
     }
 
+    // Refresh and update a single bib record.
+    // Returns a promise.
+    function updateOneRecord(recId, marcXml) {
+
+        return egCore.net.request(
+            'open-ils.cat',
+            'open-ils.cat.biblio.record.xml.update',
+            egCore.auth.token(), recId, marcXml
+        ).then(function(result) {
+            var evt = egCore.evt.parse(result);
+            if (evt) {
+                alert(evt);
+                return $q.reject(evt);
+            } else {
+                return result; // bib record
+            }
+        });
+    }
+
     // opens the record merge dialog
     $scope.openRecordMergeDialog = function(records) {
         $uibModal.open({
@@ -642,19 +661,15 @@ function($scope,  $q , $routeParams,  bucketSvc,  egCore,  $window,
                 }
                 $scope.post_edit_inplace = function() {
                     $scope.editing_inplace = false;
+                    updateOneRecord($scope.lead_id, $scope.lead.marc_xml);
                 }
+
                 $scope.edit_lead_inplace = function() {
                     $scope.editing_inplace = true;
                 }
                 $scope.edit_lead = function() {
                     var lead = { marc_xml : $scope.lead.marc_xml };
-
-                    // passing the on-save callback this way is a
-                    // hack - this invocation of the MARC editor doesn't
-                    // need it, but for some reason using this stomps
-                    // over the callback set by the other MARC editor
-                    // instance
-                    var callback = $scope.post_edit_inplace;
+                    var parentScope = $scope;
 
                     $uibModal.open({
                         templateUrl: './cat/bucket/record/t_edit_lead_record',
@@ -667,7 +682,10 @@ function($scope,  $q , $routeParams,  bucketSvc,  egCore,  $window,
                             $scope.dirty_flag = false;
                             $scope.ok = function() { $uibModalInstance.close() }
                             $scope.cancel = function () { $uibModalInstance.dismiss() }
-                            $scope.on_save = callback;
+                            $scope.on_save = function() {
+                                parentScope.lead.marc_xml = $scope.lead.marc_xml;
+                                parentScope.post_edit_inplace();
+                            }
                         }]
                     }).result.then(function() {
                         $scope.lead.marc_xml = lead.marc_xml;
@@ -680,13 +698,7 @@ function($scope,  $q , $routeParams,  bucketSvc,  egCore,  $window,
 
             function update_bib() {
                 if (args.merge_profile) {
-                    return egCore.pcrud.retrieve('bre', args.lead_id)
-                    .then(function(rec) {
-                        rec.marc(args.lead.marc_xml);
-                        rec.edit_date('now');
-                        rec.editor(egCore.auth.user().id());
-                        return egCore.pcrud.update(rec);
-                    });
+                    return updateOneRecord(args.lead_id, args.lead.marc_xml);
                 } else {
                     return $q.when();
                 }
index d288669..4d2f9c9 100644 (file)
@@ -709,7 +709,7 @@ angular.module('egMarcMod', ['egCoreMod', 'ui.bootstrap'])
                 $scope.enable_fast_add = false;
                 $scope.fast_item_callnumber = '';
                 $scope.fast_item_barcode = '';
-                
+
                 $scope.flatEditor = { isEnabled : $scope.flatOnly ? true : false };
                 
                 egCore.hatch.getItem('cat.marcedit.flateditor').then(function(val) {