<ng-container *ngIf="record && record.id">
<button *ngIf="!record.deleted" class="btn btn-warning"
- (click)="deleteRecord()" i18n>Delete Record</button>
+ [disabled]="inPlaceMode" (click)="deleteRecord()" i18n>Delete Record</button>
<button *ngIf="record.deleted" class="btn btn-info"
- (click)="undeleteRecord()" i18n>Undelete Record</button>
+ [disabled]="inPlaceMode" (click)="undeleteRecord()" i18n>Undelete Record</button>
</ng-container>
<button class="btn btn-success ml-2" (click)="saveRecord()"
<ngb-tab title="Enhanced MARC Editor" i18n-title id="rich">
<ng-template ngbTabContent>
<div class="alert alert-info mt-3" i18n>
- Enhanced MARC Editor is not yet implemented. See the
- <ng-container *ngIf="record && record.id">
- <a target="_blank"
- href="/eg/staff/cat/catalog/record/{{record.id}}/marc_edit">
- AngularJS MARC Editor.
- </a>
- </ng-container>
- <ng-container *ngIf="!record || !record.id">
- <a target="_blank" href="/eg/staff/cat/catalog/new_bib">
- AngularJS MARC Editor.
- </a>
- </ng-container>
+ Enhanced MARC Editor is not yet implemented.
+ <ng-container *ngIf="!hideFullEditorLink">
+ See the
+ <ng-container *ngIf="record && record.id">
+ <a target="_blank"
+ href="/eg/staff/cat/catalog/record/{{record.id}}/marc_edit">
+ AngularJS MARC Editor.
+ </a>
+ </ng-container>
+ <ng-container *ngIf="!record || !record.id">
+ <a target="_blank" href="/eg/staff/cat/catalog/new_bib">
+ AngularJS MARC Editor.
+ </a>
+ </ng-container>
+ </ng-container>
</div>
</ng-template>
</ngb-tab>
} from '@eg/share/combobox/combobox.component';
import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component';
+interface MarcSavedEvent {
+ marcXml: string;
+ bibSource?: number;
+}
/**
* MARC Record editor main interface.
record: MarcRecord;
editorTab: 'rich' | 'flat';
sources: ComboboxEntry[];
+ @Input() hideFullEditorLink: boolean;
@Input() set recordId(id: number) {
if (!id) { return; }
if (xml) { this.fromXml(xml); }
}
+ // Tell us which record source to select by default.
+ // Useful for new records and in-place editing from bare XML.
+ @Input() recordSource: number;
+
// If true, saving records to the database is assumed to
// happen externally. IOW, the record editor is just an
// in-place MARC modification interface.
- inPlaceMode: boolean;
+ @Input() inPlaceMode: boolean;
// In inPlaceMode, this is emitted in lieu of saving the record
// in th database. When inPlaceMode is false, this is emitted after
// the record is successfully saved.
- @Output() recordSaved: EventEmitter<string>;
+ @Output() recordSaved: EventEmitter<MarcSavedEvent>;
@ViewChild('sourceSelector') sourceSelector: ComboboxComponent;
@ViewChild('confirmDelete') confirmDelete: ConfirmDialogComponent;
private toast: ToastService
) {
this.sources = [];
- this.recordSaved = new EventEmitter<string>();
+ this.recordSaved = new EventEmitter<MarcSavedEvent>();
}
ngOnInit() {
this.sources = this.sources.sort((a, b) =>
a.label.toLowerCase() < b.label.toLowerCase() ? -1 : 1
);
+
+ if (this.recordSource) {
+ this.sourceSelector.applyEntryId(this.recordSource);
+ }
}
);
}
saveRecord(): Promise<any> {
const xml = this.record.toXml();
+ let sourceName: string = null;
+ let sourceId: number = null;
+
+ if (this.sourceSelector.selected) {
+ sourceName = this.sourceSelector.selected.label;
+ sourceId = this.sourceSelector.selected.id;
+ }
+
if (this.inPlaceMode) {
// Let the caller have the modified XML and move on.
- this.recordSaved.emit(xml);
+ this.recordSaved.emit({marcXml: xml, bibSource: sourceId});
return Promise.resolve();
}
- const source = this.sourceSelector.selected ?
- this.sourceSelector.selected.label : null; // 'label' not a typo
-
if (this.record.id) { // Editing an existing record
const method = 'open-ils.cat.biblio.record.marc.replace';
return this.net.request('open-ils.cat', method,
- this.auth.token(), this.record.id, xml, source
+ this.auth.token(), this.record.id, xml, sourceName
).toPromise().then(response => {
const evt = this.evt.parse(response);
}
this.successMsg.current().then(msg => this.toast.success(msg));
- this.recordSaved.emit(xml);
+ this.recordSaved.emit({marcXml: xml, bibSource: sourceId});
return response;
});
}
}
return this.fromId(this.record.id)
- .then(_ => this.recordSaved.emit(this.record.toXml()));
+ .then(_ => this.recordSaved.emit(
+ {marcXml: this.record.toXml()}));
});
});
}
if (evt) { console.error(evt); return alert(evt); }
return this.fromId(this.record.id)
- .then(_ => this.recordSaved.emit(this.record.toXml()));
+ .then(_ => this.recordSaved.emit(
+ {marcXml: this.record.toXml()}));
});
});
}