import {OrgService} from '@eg/core/org.service';
import {PcrudService} from '@eg/core/pcrud.service';
import {ToastService} from '@eg/share/toast/toast.service';
+import {ServerStoreService} from '@eg/core/server-store.service';
import {StringComponent} from '@eg/share/string/string.component';
import {MarcRecord} from './marcrecord';
import {ComboboxEntry, ComboboxComponent
} from '@eg/share/combobox/combobox.component';
import {ConfirmDialogComponent} from '@eg/share/dialog/confirm.component';
import {MarcEditContext} from './editor-context';
+import {NgbTabset, NgbTabChangeEvent} from '@ng-bootstrap/ng-bootstrap';
interface MarcSavedEvent {
marcXml: string;
// the record is successfully saved.
@Output() recordSaved: EventEmitter<MarcSavedEvent>;
- // Fired when our underlying source record changes.
- recordChange: EventEmitter<MarcRecord>;
-
@ViewChild('sourceSelector', { static: true }) sourceSelector: ComboboxComponent;
@ViewChild('confirmDelete', { static: true }) confirmDelete: ConfirmDialogComponent;
@ViewChild('confirmUndelete', { static: true }) confirmUndelete: ConfirmDialogComponent;
private auth: AuthService,
private org: OrgService,
private pcrud: PcrudService,
- private toast: ToastService
+ private toast: ToastService,
+ private store: ServerStoreService
) {
this.sources = [];
this.recordSaved = new EventEmitter<MarcSavedEvent>();
}
ngOnInit() {
- // Default to flat for now since it's all that's supported.
- // this.editorTab = 'flat';
+
+ this.store.getItem('cat.marcedit.flateditor').then(
+ useFlat => this.editorTab = useFlat ? 'flat' : 'rich')
this.pcrud.retrieveAll('cbs').subscribe(
src => this.sources.push({id: +src.id(), label: src.source()}),
);
}
+ // Remember the last used tab as the preferred tab.
+ tabChange(evt: NgbTabChangeEvent) {
+ if (evt.nextId === 'flat') {
+ this.store.setItem('cat.marcedit.flateditor', true);
+ } else {
+ this.store.removeItem('cat.marcedit.flateditor');
+ }
+ }
+
saveRecord(): Promise<any> {
const xml = this.record.toXml();