]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/eg2/src/app/staff/share/marc-edit/flat-editor.component.ts
LP1852782 Angular MARC enriched editor (first batch)
[working/Evergreen.git] / Open-ILS / src / eg2 / src / app / staff / share / marc-edit / flat-editor.component.ts
1 import {Component, Input, OnInit} from '@angular/core';
2 import {IdlService} from '@eg/core/idl.service';
3 import {OrgService} from '@eg/core/org.service';
4 import {ServerStoreService} from '@eg/core/server-store.service';
5 import {MarcRecord} from './marcrecord';
6 import {MarcEditContext} from './editor-context';
7
8 /**
9  * MARC Record flat text (marc-breaker) editor.
10  */
11
12 @Component({
13   selector: 'eg-marc-flat-editor',
14   templateUrl: './flat-editor.component.html',
15   styleUrls: ['flat-editor.component.css']
16 })
17
18 export class MarcFlatEditorComponent implements OnInit {
19
20     @Input() context: MarcEditContext;
21     get record(): MarcRecord {
22         return this.context.record;
23     }
24
25     constructor(
26         private idl: IdlService,
27         private org: OrgService,
28         private store: ServerStoreService
29     ) {}
30
31     ngOnInit() {
32         // Be sure changes made in the enriched editor are
33         // reflected here.
34         this.record.breakerText = this.record.toBreaker();
35     }
36
37     // When we have breaker text, limit the vertical expansion of the
38     // text area to the size of the data plus a little padding.
39     rowCount(): number {
40         if (this.record && this.record.breakerText) {
41             return this.record.breakerText.split(/\n/).length + 2;
42         }
43         return 40;
44     }
45 }
46
47
48