</eg-marc-editor-dialog>
<!-- display a single heading as MARC or as the human friendlier string -->
-<ng-template #headingField let-field="field" let-from="from" let-also="also">
+<ng-template #headingField
+ let-field="field" let-from="from" let-also="also" let-authId="authId">
<button class="btn btn-sm p-1 mr-1"
[ngClass]="{'btn-outline-primary': !(from || also), 'btn-outline-info': (from || also)}"
- (click)="applyHeading(field)" i18n>Apply</button>
+ (click)="applyHeading(field, authId)" i18n>Apply</button>
<ng-container *ngIf="showAs == 'heading'">
<span *ngIf="from" i18n>See From: {{field.heading}}</span>
<span *ngIf="also" i18n>See Also: {{field.heading}}</span>
<li class="d-flex">
<div class="flex-1">
<ng-container
- *ngTemplateOutlet="headingField;context:{field:entry.main_heading}">
+ *ngTemplateOutlet="headingField;context:{field:entry.main_heading, authId: entry.authority_id}">
</ng-container>
</div>
<div class="font-italic" i18n-title i18n
).subscribe(entry => this.browseData.push(entry));
}
- applyHeading(authField: MarcField) {
+ applyHeading(authField: MarcField, authId?: number) {
this.net.request(
'open-ils.cat',
'open-ils.cat.authority.bib_field.overlay_authority',
this.fieldHash(), this.fieldHash(authField), this.controlSet
- ).subscribe(field => this.close(field));
+ ).subscribe(field => {
+ if (authId) {
+ // If an authId is provided, it means we are using
+ // a main entry heading and we should set the bib
+ // field's subfield 0 to refer to the main entry record.
+ this.setSubfieldZero(authId, field);
+ }
+ this.close(field);
+ });
}
isControlledBibSf(sf: string): boolean {
this.authMeta.sf_list().includes(sf) : false;
}
- setSubfieldZero(authId: number) {
- const sfZero = this.bibField.subfields.filter(sf => sf[0] === '0')[0];
+ setSubfieldZero(authId: number, bibField?: MarcField) {
+
+ if (!bibField) { bibField = this.bibField; }
+
+ const sfZero = bibField.subfields.filter(sf => sf[0] === '0')[0];
if (sfZero) {
- this.context.deleteSubfield(this.bibField, sfZero);
+ this.context.deleteSubfield(bibField, sfZero);
}
- this.context.insertSubfield(this.bibField,
- ['0', `(${this.cni})${authId}`, this.bibField.subfields.length]);
+ this.context.insertSubfield(bibField,
+ ['0', `(${this.cni})${authId}`, bibField.subfields.length]);
// Reset the validation state.
- this.bibField.authChecked = null;
- this.bibField.authValid = null;
+ bibField.authChecked = null;
+ bibField.authValid = null;
}
createNewAuthority(editFirst?: boolean) {