<ng-template #menuTemplate>
+ <!-- apply (click) to div so user can click anywhere in the row -->
<div *ngFor="let entry of menuEntries; first as isFirst"
- class="menu-entry {{entryClasses}}">
- <a
- [attr.id]="isFirst ? randId : ''"
- (click)="entryClicked(entry)">{{entry.label}}</a>
+ (click)="entryClicked(entry)" class="menu-entry {{entryClasses}}">
+ <a>{{entry.label}}</a>
</div>
</ng-template>
/* match angjs color */
color: rgb(0, 0, 255)!important;
/* snuggle up to my subfield code */
- margin-right: -1rem;
+ margin-right: -0.5rem;
}
.sf-code {
<div contenteditable
id='{{randId}}'
spellcheck="false"
- class="d-inline-block p-1 pt-2 text-dark text-break {{moreClasses}}"
+ class="d-inline-block text-dark text-break {{moreClasses}}"
[attr.tabindex]="fieldText ? -1 : ''"
[egContextMenu]="contextMenuEntries()"
(menuItemSelected)="contextMenuChange($event.value)"
<input
id='{{randId}}'
spellcheck="false"
- class="p-0 pl-1 text-dark rounded-0 form-control {{moreClasses}}"
+ class="text-dark rounded-0 form-control {{moreClasses}}"
[size]="inputSize()"
[maxlength]="maxLength || ''"
[disabled]="fieldText"
import {TagTableService} from './tagtable.service';
/**
- * MARC Tag Editor Component
+ * MARC Editable Content Component
*/
@Component({
@Input() context: MarcEditContext;
@Input() field: MarcField;
- @Input() fieldType: 'ldr' | 'tag' | 'cfld' | 'ind' | 'sfc' | 'sfv' = null;
-
- // used when the fieldType is ambiguous. E.g. 'ind1'
- @Input() fieldName: string = null;
+ @Input() fieldType: 'ldr' | 'tag' | 'cfld' | 'ind1' | 'ind2' | 'sfc' | 'sfv' = null;
// read-only field text. E.g. 'LDR'
@Input() fieldText: string = null;
if (req.sfOffset !== undefined &&
req.sfOffset !== this.subfield[2]) {
- // subfield focus request, but we are not this subfield
+ // this is not the subfield you are looking for.
return;
}
this.watchForFocusRequests();
break;
- case 'ind':
+ case 'ind1':
+ case 'ind2':
this.maxLength = 1;
break;
if (!this.field) { return; } // LDR tag
switch(this.fieldType) {
- case 'tag': return [];
+ case 'tag':
+ return this.tagTable.getFieldTags();
case 'sfc':
return this.tagTable.getSubfieldCodes(this.field.tag);
case 'sfv':
return this.tagTable.getSubfieldValues(
this.field.tag, this.subfield[0]);
+
+ case 'ind1':
+ case 'ind2':
+ return this.tagTable.getIndicatorValues(
+ this.field.tag, this.fieldType);
}
return null;
case 'ldr': return this.record.leader;
case 'cfld': return this.field.data;
case 'tag': return this.field.tag;
- case 'ind': return this.field[this.fieldName];
case 'sfc': return this.subfield[0];
case 'sfv': return this.subfield[1];
+ case 'ind1': // thunk
+ case 'ind2': return this.field[this.fieldType];
}
}
case 'ldr': this.record.leader = value; break;
case 'cfld': this.field.data = value; break;
case 'tag': this.field.tag = value; break;
- case 'ind': this.field[this.fieldName] = value; break;
case 'sfc': this.subfield[0] = value; break;
case 'sfv': this.subfield[1] = value; break;
+ case 'ind1': // thunk
+ case 'ind2': this.field[this.fieldType] = value; break;
}
}
contextMenuChange(value: string) {
this.setContent(value);
+ if (this.bigText) {
+ // propagate to div
+ this.editInput.innerText = value;
+ }
}
}
<ngb-tabset [activeId]="editorTab" (tabChange)="tabChange($event)">
<ngb-tab title="Enhanced MARC Editor" i18n-title id="rich">
<ng-template ngbTabContent>
- <eg-marc-rich-editor [context]="context"></eg-marc-rich-editor>
+ <ng-container *ngIf="context && context.record">
+ <eg-marc-rich-editor [context]="context"></eg-marc-rich-editor>
+ </ng-container>
</ng-template>
</ngb-tab>
<ngb-tab title="Flat Text Editor" i18n-title id="flat">
<ng-template ngbTabContent>
- <eg-marc-flat-editor [context]="context"></eg-marc-flat-editor>
+ <ng-container *ngIf="context && context.record">
+ <eg-marc-flat-editor [context]="context"></eg-marc-flat-editor>
+ </ng-container>
</ng-template>
</ngb-tab>
</ngb-tabset>
<!-- LEADER -->
<div class="row pt-0 pb-0 pl-3 form-horizontal">
<eg-marc-editable-content [context]="context" fieldType="tag"
- fieldText="LDR" i18n-fieldText>
+ fieldText="LDR" i18n-fieldText moreClasses="p-1">
</eg-marc-editable-content>
- <eg-marc-editable-content [context]="context" fieldType="ldr">
+ <eg-marc-editable-content [context]="context" fieldType="ldr"
+ moreClasses="p-1">
</eg-marc-editable-content>
</div>
<!-- CONTROL FIELDS -->
<div class="row pt-0 pb-0 pl-3 form-horizontal"
*ngFor="let field of controlFields()">
- <eg-marc-editable-content [context]="context" fieldType="tag" [field]="field">
+
+ <eg-marc-editable-content [context]="context" fieldType="tag"
+ [field]="field" moreClasses="p-1">
</eg-marc-editable-content>
- <eg-marc-editable-content [context]="context" fieldType="cfld" [field]="field">
+ <eg-marc-editable-content [context]="context" fieldType="cfld"
+ [field]="field" moreClasses="p-1">
</eg-marc-editable-content>
</div>
*ngFor="let field of dataFields()">
<!-- TAG -->
- <eg-marc-editable-content [context]="context" fieldType="tag" [field]="field">
+ <eg-marc-editable-content [context]="context" fieldType="tag"
+ [field]="field" moreClasses="p-1">
</eg-marc-editable-content>
<!-- INDICATOR 1 -->
- <eg-marc-editable-content [context]="context" fieldType="ind"
- [field]="field" fieldName="ind1">
+ <eg-marc-editable-content [context]="context" fieldType="ind1"
+ [field]="field" moreClasses="p-1">
</eg-marc-editable-content>
<!-- INDICATOR 2 -->
- <eg-marc-editable-content [context]="context" fieldType="ind"
- [field]="field" fieldName="ind2">
+ <eg-marc-editable-content [context]="context" fieldType="ind2"
+ [field]="field" moreClasses="p-1">
</eg-marc-editable-content>
<!-- SUBFIELDS -->
<!-- SUBFIELD DECORATOR/DELIMITER -->
<eg-marc-editable-content fieldText="‡" i18n-fieldText
- moreClasses="sf-delimiter border-right-0 bg-transparent">
+ moreClasses="sf-delimiter border-right-0 bg-transparent p-1 pr-0">
</eg-marc-editable-content>
<!-- SUBFIELD CHARACTER -->
<eg-marc-editable-content [context]="context" fieldType="sfc"
[field]="field" [subfield]="subfield"
- moreClasses="sf-code border-left-0">
+ moreClasses="sf-code border-left-0 p-1 pl-0">
</eg-marc-editable-content>
<!-- SUBFIELD VALUE -->
<eg-marc-editable-content [context]="context" fieldType="sfv"
- [field]="field" [subfield]="subfield">
+ [field]="field" [subfield]="subfield" moreClasses="p-1 pt-2">
</eg-marc-editable-content>
</ng-container>
</div>
ffPosMap: {[rtype: string]: any[]} = {};
ffValueMap: {[rtype: string]: any} = {};
+ extractedValuesCache:
+ {[valueType: string]: {[which: string]: any}} = {};
+
constructor(
private store: StoreService,
private auth: AuthService,
private net: NetService,
private pcrud: PcrudService,
private evt: EventService
- ) {}
+ ) {
+ this.extractedValuesCache.fieldtags = {};
+ this.extractedValuesCache.indicators = {};
+ this.extractedValuesCache.sfcodes = {};
+ this.extractedValuesCache.sfvalues = {};
+ }
+
+ // Various data needs munging for display. Cached the modified
+ // values since they are refernced repeatedly by the UI code.
+ fromCache(dataType: string, which?: string, which2?: string): ValueLabelPair[] {
+ const part1 = this.extractedValuesCache[dataType][which];
+ if (which2) {
+ if (part1) {
+ return part1[which2];
+ }
+ } else {
+ return part1;
+ }
+ }
+
+ toCache(dataType: string, which: string,
+ which2: string, values: ValueLabelPair[]): ValueLabelPair[] {
+ const base = this.extractedValuesCache[dataType];
+ const part1 = base[which];
+
+ if (which2) {
+ if (!base[which]) { base[which] = {}; }
+ base[which][which2] = values;
+ } else {
+ base[which] = values;
+ }
+
+ return values;
+ }
getFFPosTable(rtype: string): Promise<any> {
const storeKey = 'FFPosTable_' + rtype;
getSubfieldCodes(tag: string): ValueLabelPair[] {
if (!tag || !this.tagMap[tag]) { return null; }
- return this.tagMap[tag].subfields.map(sf => ({
+ const cached = this.fromCache('sfcodes', tag);
+
+ const list = this.tagMap[tag].subfields.map(sf => ({
value: sf.code,
label: `${sf.code}: ${sf.description}`
}))
.sort((a, b) => a.label < b.label ? -1 : 1);
+
+ return this.toCache('sfcodes', tag, null, list);
}
getFieldTags(): ValueLabelPair[] {
+
+ const cached = this.fromCache('fieldtags');
+ if (cached) { return cached; }
+
return Object.keys(this.tagMap)
+ .filter(tag => Boolean(this.tagMap[tag]))
.map(tag => ({
value: tag,
label: `${tag}: ${this.tagMap[tag].name}`
getSubfieldValues(tag: string, sfCode: string): ValueLabelPair[] {
if (!tag || !this.tagMap[tag]) { return []; }
+ const cached = this.fromCache('sfvalues', tag, sfCode)
+ if (cached) { return cached; }
+
const list: ValueLabelPair[] = [];
this.tagMap[tag].subfields
})
});
- return list.sort((a, b) => a.label < b.label ? -1 : 1);
+ return this.toCache('sfvalues', tag, sfCode, list);
}
- getIndicatorValues(tag: string, pos: number): ValueLabelPair[] {
+ getIndicatorValues(tag: string, which: 'ind1' | 'ind2'): ValueLabelPair[] {
if (!tag || !this.tagMap[tag]) { return }
- const value = this.tagMap[tag][`ind${pos}`];
- if (!value) { return; }
+ const cached = this.fromCache('indicators', tag, which);
+ if (cached) { return cached; }
- return value.map(tag => ({
+ let values = this.tagMap[tag][which];
+ if (!values) { return; }
+
+ values = values.map(value => ({
value: value.code,
label: `${value.code}: ${value.description}`
}))
.sort((a, b) => a.label < b.label ? -1 : 1);
+
+ return this.toCache('indicators', tag, which, values);
}
}