LP1830923 Vandelay queued record MARC edit
authorBill Erickson <berickxx@gmail.com>
Thu, 17 Oct 2019 21:59:08 +0000 (17:59 -0400)
committerBill Erickson <berickxx@gmail.com>
Thu, 5 Dec 2019 15:22:42 +0000 (10:22 -0500)
Allow editing of Vandelay queued bib records (from the queue
interface) via the Angular MARC editor.

Note only the flat text editor is currently supportd in the
Angular MARC editor.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record.component.html
Open-ILS/src/eg2/src/app/staff/cat/vandelay/queued-record.component.ts
Open-ILS/src/eg2/src/app/staff/cat/vandelay/vandelay.module.ts

index d9e8534..ebb51b4 100644 (file)
@@ -1,4 +1,6 @@
 
+<eg-string #updateSuccess i18n-text text="Record Update Succeeded"></eg-string>
+
 <div class="row mb-3">
   <div class="col-lg-2">
     <button class="btn btn-info label-with-material-icon"
 </div>
 
 <ngb-tabset #recordTabs [activeId]="recordTab" (tabChange)="onTabChange($event)">
-       <ngb-tab title="Queued Record MARC" i18n-title id="marc">
-               <ng-template ngbTabContent>
+  <ngb-tab title="Queued Record MARC" i18n-title id="marc">
+    <ng-template ngbTabContent>
       <eg-marc-html [recordId]="recordId" [recordType]="'vandelay-'+queueType">
       </eg-marc-html>
-               </ng-template>
-       </ngb-tab>
-       <ngb-tab title="Record Matches" i18n-title id="matches">
-               <ng-template ngbTabContent>
+    </ng-template>
+  </ngb-tab>
+  <ngb-tab title="Edit Record" i18n-title id="edit">
+    <ng-template ngbTabContent>
+      <ng-container *ngIf="queuedRecord">
+        <eg-marc-editor [inPlaceMode]="true" [recordXml]="queuedRecord.marc()" 
+          [hideFullEditorLink]="true"
+          [recordSource]="queuedRecord.bib_source()"
+          (recordSaved)="handleMarcRecordSaved($event)"></eg-marc-editor>   
+      </ng-container>
+    </ng-template>
+  </ngb-tab>
+  <ngb-tab title="Record Matches" i18n-title id="matches">
+    <ng-template ngbTabContent>
       <eg-queued-record-matches [recordId]="recordId" [queueType]="queueType">
       </eg-queued-record-matches>
-               </ng-template>
-       </ngb-tab>
-       <ngb-tab title="Import Items" i18n-title id="items">
-               <ng-template ngbTabContent>
+    </ng-template>
+  </ngb-tab>
+  <ngb-tab title="Import Items" i18n-title id="items">
+    <ng-template ngbTabContent>
       <eg-queued-record-items [recordId]="recordId">
       </eg-queued-record-items>
-               </ng-template>
-       </ngb-tab>
+    </ng-template>
+  </ngb-tab>
 </ngb-tabset>
index 7bbf5a8..3b5ba4c 100644 (file)
@@ -1,6 +1,10 @@
 import {Component, OnInit, ViewChild} from '@angular/core';
 import {Router, ActivatedRoute, ParamMap} from '@angular/router';
 import {NgbTabset, NgbTabChangeEvent} from '@ng-bootstrap/ng-bootstrap';
+import {PcrudService} from '@eg/core/pcrud.service';
+import {IdlObject} from '@eg/core/idl.service';
+import {ToastService} from '@eg/share/toast/toast.service';
+import {StringComponent} from '@eg/share/string/string.component';
 
 @Component({
   templateUrl: 'queued-record.component.html'
@@ -11,16 +15,24 @@ export class QueuedRecordComponent {
     queueType: string;
     recordId: number;
     recordTab: string;
+    queuedRecord: IdlObject;
+
+    @ViewChild('updateSuccess') updateSuccess: StringComponent;
 
     constructor(
         private router: Router,
-        private route: ActivatedRoute) {
+        private route: ActivatedRoute,
+        private toast: ToastService,
+        private pcrud: PcrudService) {
 
         this.route.paramMap.subscribe((params: ParamMap) => {
             this.queueId = +params.get('id');
             this.recordId = +params.get('recordId');
             this.queueType = params.get('qtype');
             this.recordTab = params.get('recordTab');
+            if (this.recordTab === 'edit') {
+                this.loadRecord();
+            }
         });
     }
 
@@ -38,5 +50,23 @@ export class QueuedRecordComponent {
 
         this.router.navigate([url]);
     }
+
+    loadRecord() {
+        this.queuedRecord = null;
+        this.pcrud.retrieve('vqbr', this.recordId)
+        .subscribe(rec => this.queuedRecord = rec);
+    }
+
+    handleMarcRecordSaved(saveEvent: any) {
+        this.queuedRecord.marc(saveEvent.marcXml);
+        this.queuedRecord.bib_source(saveEvent.bibSource);
+        this.pcrud.update(this.queuedRecord).subscribe(
+            response => this.toast.success(this.updateSuccess.text),
+            error => {
+                console.error(error);
+                this.toast.danger(error);
+            }
+        );
+    }
 }
 
index 9bbfd46..1b561c0 100644 (file)
@@ -23,6 +23,7 @@ import {MatchSetExpressionComponent} from './match-set-expression.component';
 import {MatchSetQualityComponent} from './match-set-quality.component';
 import {MatchSetNewPointComponent} from './match-set-new-point.component';
 import {RecentImportsComponent} from './recent-imports.component';
+import {MarcEditModule} from '@eg/staff/share/marc-edit/marc-edit.module';
 
 @NgModule({
   declarations: [
@@ -48,6 +49,7 @@ import {RecentImportsComponent} from './recent-imports.component';
   imports: [
     TreeModule,
     StaffCommonModule,
+    MarcEditModule,
     CatalogCommonModule,
     VandelayRoutingModule,
     HttpClientModule,