]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/eg2/src/app/staff/share/marc-edit/marcrecord.ts
df1a49276252e2966a322222c7a463295b32f580
[working/Evergreen.git] / Open-ILS / src / eg2 / src / app / staff / share / marc-edit / marcrecord.ts
1 /**
2   * Simple wrapper class for our external MARC21.Record JS library.
3   */
4
5 declare var MARC21;
6
7 // MARC breaker delimiter
8 const DELIMITER = '$';
9
10 export class MarcRecord {
11
12     id: number; // Database ID when known.
13     deleted: boolean;
14     record: any; // MARC21.Record object
15     breakerText: string;
16
17     constructor(xml: string) {
18         this.record = new MARC21.Record({marcxml: xml, delimiter: DELIMITER});
19         this.breakerText = this.record.toBreaker();
20     }
21
22     toXml(): string {
23         return this.record.toXmlString();
24     }
25
26     toBreaker(): string {
27         return this.record.toBreaker();
28     }
29
30     absorbBreakerChanges() {
31         this.record = new MARC21.Record(
32             {marcbreaker: this.breakerText, delimiter: DELIMITER});
33     }
34 }
35