1 import {Component, OnInit, Input, ViewEncapsulation} from '@angular/core';
2 import {NetService} from '@eg/core/net.service';
3 import {OrgService} from '@eg/core/org.service';
4 import {AuthService} from '@eg/core/auth.service';
5 import {BibRecordService, BibRecordSummary
6 } from '@eg/share/catalog/bib-record.service';
8 /* Display content from a bib summary display field. If highlight
9 * data is avaialble, it will be used in lieu of the plan display string.
11 * <eg-bib-display-field field="title" [summary]="summary"
12 * [usePlaceholder]="true"></eg-bib-display-field>
15 // non-collapsing space
16 const PAD_SPACE = ' '; // U+2007
19 selector: 'eg-bib-display-field',
20 templateUrl: 'bib-display-field.component.html',
21 styleUrls: ['bib-display-field.component.css'],
22 encapsulation: ViewEncapsulation.None // required for search highlighting
24 export class BibDisplayFieldComponent implements OnInit {
26 @Input() summary: BibRecordSummary;
27 @Input() field: string; // display field name
29 // Used to join multi fields
30 @Input() joiner: string;
32 // If true, replace empty values with a non-collapsing space.
33 @Input() usePlaceholder: boolean;
39 // Returns an array of display values which may either be
40 // plain string values or strings with embedded HTML markup
41 // for search results highlighting.
42 getDisplayStrings(): string[] {
43 const replacement = this.usePlaceholder ? PAD_SPACE : '';
45 if (!this.summary) { return [replacement]; }
47 const scrunch = (value) => {
48 if (Array.isArray(value)) {
51 return [value || replacement];
56 this.summary.displayHighlights[this.field] ||
57 this.summary.display[this.field]