LPXXX MARC enriched editor WIP
authorBill Erickson <berickxx@gmail.com>
Fri, 15 Nov 2019 18:59:31 +0000 (13:59 -0500)
committerBill Erickson <berickxx@gmail.com>
Fri, 6 Dec 2019 15:37:03 +0000 (10:37 -0500)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor.component.html
Open-ILS/src/eg2/src/app/staff/share/marc-edit/editor.component.ts

index be68455..557b04e 100644 (file)
@@ -40,8 +40,8 @@
 
 <div class="row">
   <div class="col-lg-12">
-    <ngb-tabset [activeId]="editorTab">
-      <ngb-tab title="Enhanced MARC Editor" i18n-title id="rich" *ngIf="!inPlaceMode">
+    <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-template>
index 3294f1e..361a4fb 100644 (file)
@@ -6,12 +6,14 @@ import {AuthService} from '@eg/core/auth.service';
 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;
@@ -63,9 +65,6 @@ export class MarcEditorComponent implements OnInit {
     // 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;
@@ -80,7 +79,8 @@ export class MarcEditorComponent implements OnInit {
         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>();
@@ -88,8 +88,9 @@ export class MarcEditorComponent implements OnInit {
     }
 
     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()}),
@@ -106,6 +107,15 @@ export class MarcEditorComponent implements OnInit {
         );
     }
 
+    // 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();