1 import {Component, Input, Output, OnInit, EventEmitter} from '@angular/core';
2 import {IdlObject} from '@eg/core/idl.service';
3 import {MarcRecord} from './marcrecord';
4 import {MarcEditContext} from './editor-context';
5 import {TagTableService} from './tagtable.service';
8 * MARC Fixed Field Editing Component
12 selector: 'eg-fixed-field',
13 templateUrl: './fixed-field.component.html',
14 styleUrls: ['fixed-field.component.css']
17 export class FixedFieldComponent implements OnInit {
19 @Input() fieldCode: string;
20 @Input() fieldLabel: string;
21 @Input() context: MarcEditContext;
23 get record(): MarcRecord { return this.context.record; }
26 randId = Math.floor(Math.random() * 10000000);
32 this.context.recordChange.subscribe(__ => this.init()));
35 init(): Promise<any> {
36 if (!this.record) { return Promise.resolve(); }
38 // If no field metadata is found for this fixed field code and
39 // record type combo, the field will be hidden in the UI.
40 return this.context.tagTable.getFfFieldMeta(this.fieldCode)
41 .then(fieldMeta => this.fieldMeta = fieldMeta);