From 305bed905c48640e6b181a3e0fb9f614bbb32be8 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 14 Nov 2019 18:02:19 -0500 Subject: [PATCH] LPXXX MARC enriched editor WIP Signed-off-by: Bill Erickson --- .../app/staff/share/marc-edit/fixed-field.component.ts | 8 ++++++++ .../src/eg2/src/app/staff/share/marc-edit/marcrecord.ts | 15 +++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/fixed-field.component.ts b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/fixed-field.component.ts index b3f9654dcc..a7c1fdb6d8 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/fixed-field.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/fixed-field.component.ts @@ -32,6 +32,7 @@ export class FixedFieldComponent implements OnInit { ngOnInit() { this.init().then(_ => this.context.recordChange.subscribe(_ => this.init())); + } init(): Promise { @@ -55,6 +56,13 @@ export class FixedFieldComponent implements OnInit { this.fieldSize = this.fieldMeta.length || 1; this.fieldValue = this.context.record.extractFixedField(this.fieldCode); + + // Shuffling may occur wht our fixed field value based on + // external changes. + this.record.fixedFieldChange.subscribe(_ => + this.fieldValue = + this.context.record.extractFixedField(this.fieldCode) + ); }); } diff --git a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/marcrecord.ts b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/marcrecord.ts index f5c120cdd4..26a5ed9a18 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/marcrecord.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/marcrecord.ts @@ -1,6 +1,6 @@ -/** - * Simple wrapper class for our external MARC21.Record JS library. - */ +import {EventEmitter} from '@angular/core'; + +/* Wrapper class for our external MARC21.Record JS library. */ declare var MARC21; @@ -14,9 +14,14 @@ export class MarcRecord { record: any; // MARC21.Record object breakerText: string; + // Let clients know some fixed field shuffling may have occured. + // Emits the fixed field code. + fixedFieldChange: EventEmitter; + constructor(xml: string) { this.record = new MARC21.Record({marcxml: xml, delimiter: DELIMITER}); this.breakerText = this.record.toBreaker(); + this.fixedFieldChange = new EventEmitter(); } toXml(): string { @@ -41,7 +46,9 @@ export class MarcRecord { } setFixedField(fieldCode: string, fieldValue: string): string { - return this.record.setFixedField(fieldCode, fieldValue); + const response = this.record.setFixedField(fieldCode, fieldValue); + this.fixedFieldChange.emit(fieldCode); + return response; } } -- 2.11.0