LP1849212: more of the same
authorJane Sandberg <sandbej@linnbenton.edu>
Tue, 1 Sep 2020 18:58:33 +0000 (11:58 -0700)
committerJane Sandberg <sandbej@linnbenton.edu>
Tue, 1 Sep 2020 19:01:57 +0000 (12:01 -0700)
Signed-off-by: Jane Sandberg <sandbej@linnbenton.edu>
Open-ILS/src/eg2/src/app/staff/share/marc-edit/simplified-editor/simplified-editor.component.html
Open-ILS/src/eg2/src/app/staff/share/marc-edit/simplified-editor/simplified-editor.component.ts

index c6bbf23..aeecb1c 100644 (file)
@@ -4,12 +4,12 @@
       <div class="row" *ngFor="let subfield of field.subfields">
         <ng-container *ngIf="!subfield[1]">
           <div class="col-lg-3">
-            <label for="{{idPrefix}}-{{field.tag}}{{subfield[0]}}">
-              {{subfieldLabels[field.tag + subfield[0]]}}
+            <label for="{{idPrefix}}-{{editorFieldIdentifier(field, subfield)}}">
+              {{subfieldLabels[editorFieldIdentifier(field, subfield)]}}
             </label>
           </div>
           <div class="col-lg-9">
-            <input id="{{idPrefix}}-{{field.tag}}{{subfield[0]}}" formControlName="{{field.fieldId}}" />
+            <input id="{{idPrefix}}-{{editorFieldIdentifier(field, subfield)}}" formControlName="{{editorFieldIdentifier(field, subfield)}}" />
           </div>
         </ng-container>
       </div>
index 9cb39a4..2675f25 100644 (file)
@@ -28,6 +28,8 @@ export class MarcSimplifiedEditorComponent implements AfterViewInit, OnInit {
 
     addField: (field: MarcField) => void;
 
+    editorFieldIdentifier: (field: MarcField, subfield: Array<any>) => string;
+
     constructor(
         private tagTable: TagTableService
     ) {}
@@ -41,17 +43,23 @@ export class MarcSimplifiedEditorComponent implements AfterViewInit, OnInit {
         this.addField = (field: MarcField) => {
             field.fieldId = this.fieldIndex;
             this.fields.push(field);
-            this.editor.addControl(String(this.fieldIndex), new FormControl(null, []));
+            field.subfields.forEach((subfield) => {
+                this.editor.addControl(this.editorFieldIdentifier(field, subfield), new FormControl(null, []));               
+            })
             this.fieldIndex++;
         };
 
+        this.editorFieldIdentifier = (field: MarcField, subfield: Array<any>) => {
+            return field.tag + subfield[0]; // e.g. 245a
+        }
+
     }
 
     ngAfterViewInit() {
         this.tagTable.loadTags({marcRecordType: 'biblio', ffType: 'BKS'}).then(table => {
             this.fields.forEach((field) => {
                 field.subfields.forEach((subfield) => {
-                    this.subfieldLabels[field.tag + subfield[0]] = table.getSubfieldLabel(field.tag, subfield[0]);
+                    this.subfieldLabels[this.editorFieldIdentifier(field, subfield)] = table.getSubfieldLabel(field.tag, subfield[0]);
                 })
             });
         });
@@ -63,7 +71,7 @@ export class MarcSimplifiedEditorComponent implements AfterViewInit, OnInit {
         this.fields.forEach((field) => {
             field.subfields.forEach((subfield) => {
                 if (subfield[1] === '') { // Default value has not been applied
-                    subfield[1] = this.editor.get(String(field.fieldId)).value;
+                    subfield[1] = this.editor.get(this.editorFieldIdentifier(field, subfield)).value;
                 }  
             })
         });