From dfe56547d235d65298ab4e4322621a1afba28f30 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Wed, 11 Dec 2019 15:28:04 -0500 Subject: [PATCH] LP1852782 Prevents data fields swapping to control fields Prevent an existing data field from swapping to a control field while editing the tag. This way if a tag is cleared the field won't jump from the data fields section up to the control fields section mid-edit. Signed-off-by: Bill Erickson Signed-off-by: Jane Sandberg --- Open-ILS/src/eg2/src/app/staff/share/marc-edit/marcrecord.ts | 10 ++++++++++ .../eg2/src/app/staff/share/marc-edit/rich-editor.component.ts | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) 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 69e095518d..cdc99aac4b 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 @@ -19,6 +19,11 @@ export interface MarcField { ind2?: string; subfields?: MarcSubfield[]; + // Fields are immutable when it comes to controlfield vs. + // data field. Stamp the value when stamping field IDs. + isCtrlField: boolean; + + // Pass-through to marcrecord.js isControlfield(): boolean; deleteExactSubfields(...subfield: MarcSubfield[]): number; @@ -89,10 +94,15 @@ export class MarcRecord { this.fields.forEach(f => this.stampFieldId(f)); } + // Stamp field IDs the the initial isCtrlField state. stampFieldId(field: MarcField) { if (!field.fieldId) { field.fieldId = Math.floor(Math.random() * 10000000); } + + if (field.isCtrlField === undefined) { + field.isCtrlField = field.isControlfield(); + } } field(spec: string, wantArray?: boolean): MarcField | MarcField[] { diff --git a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/rich-editor.component.ts b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/rich-editor.component.ts index 6b79fe2415..a1a7d552eb 100644 --- a/Open-ILS/src/eg2/src/app/staff/share/marc-edit/rich-editor.component.ts +++ b/Open-ILS/src/eg2/src/app/staff/share/marc-edit/rich-editor.component.ts @@ -93,11 +93,11 @@ export class MarcRichEditorComponent implements OnInit { } controlFields(): MarcField[] { - return this.record.fields.filter(f => f.isControlfield()); + return this.record.fields.filter(f => f.isCtrlField); } dataFields(): MarcField[] { - return this.record.fields.filter(f => !f.isControlfield()); + return this.record.fields.filter(f => !f.isCtrlField); } } -- 2.11.0