1 import {Directive, Host, Input, OnInit, AfterViewInit} from '@angular/core';
2 import {MarcSimplifiedEditorComponent} from './simplified-editor.component';
3 import {MarcField, MarcSubfield} from '../marcrecord';
4 import {MarcSimplifiedEditorSubfieldDirective} from './simplified-editor-subfield.directive';
7 * A field that a user can edit, which will later be
12 selector: 'eg-marc-simplified-editor-field',
14 export class MarcSimplifiedEditorFieldDirective implements OnInit, AfterViewInit {
22 marcVersion: MarcField;
24 addSubfield: (code: string, defaultValue?: string) => void;
26 constructor(@Host() private editor: MarcSimplifiedEditorComponent) {}
35 isControlfield: () => false,
36 indicator: (ind: number) => (ind === 1) ? this.ind1 : this.ind2,
37 deleteExactSubfields: (...subfield: MarcSubfield[]) => 0, // not used by the simplified editor
40 this.addSubfield = (code: string, defaultValue?: string) => {
41 this.marcVersion.subfields.push(
44 defaultValue ? defaultValue : '',
48 this.subfieldIndex += 1;
54 this.editor.addField(this.marcVersion);