LP#1929749: tweaks to import template management
authorGalen Charlton <gmc@equinoxOLI.org>
Tue, 17 May 2022 15:35:31 +0000 (15:35 +0000)
committerGalen Charlton <gmc@equinoxOLI.org>
Tue, 17 May 2022 15:35:31 +0000 (15:35 +0000)
- toast now displayed when a template is saved, deleted, or
  marked as default
- fixed bug with making another template be the new default
  one

Signed-off-by: Galen Charlton <gmc@equinoxOLI.org>
Open-ILS/src/eg2/src/app/staff/acq/picklist/upload.component.html
Open-ILS/src/eg2/src/app/staff/acq/picklist/upload.component.ts

index 8265892..1ccc883 100644 (file)
@@ -5,6 +5,9 @@
   <div class="ml-auto mr-3"><a i18n href="/eg/staff/acq/legacy/picklist/upload">Legacy Upload Interface</a></div>
 </div>
 
+<eg-string #loadMarcOrderTemplateSavedString i18n-text text="Load MARC Order Record Template Saved"></eg-string>
+<eg-string #loadMarcOrderTemplateDeletedString i18n-text text="Load MARC Order Record Template Deleted"></eg-string>
+<eg-string #loadMarcOrderTemplateSetAsDefaultString i18n-text text="Load MARC Order Record Template Set As Default"></eg-string>
 
 <eg-alert-dialog #dupeQueueAlert i18n-dialogBody 
   dialogBody="A queue with the requested name already exists.">
index d5785e0..ef12730 100644 (file)
@@ -7,6 +7,7 @@ import {NetService} from '@eg/core/net.service';
 import {EventService} from '@eg/core/event.service';
 import {OrgService} from '@eg/core/org.service';
 import {AuthService} from '@eg/core/auth.service';
+import {StringComponent} from '@eg/share/string/string.component';
 import {ToastService} from '@eg/share/toast/toast.service';
 import {ComboboxComponent,
     ComboboxEntry} from '@eg/share/combobox/combobox.component';
@@ -140,6 +141,13 @@ export class UploadComponent implements OnInit, AfterViewInit, OnDestroy {
         private fallThruMergeProfileSelector: ComboboxComponent;
     @ViewChild('dupeQueueAlert', { static: true })
         private dupeQueueAlert: AlertDialogComponent;
+    @ViewChild('loadMarcOrderTemplateSavedString', { static: false })
+        private loadMarcOrderTemplateSavedString: StringComponent;
+    @ViewChild('loadMarcOrderTemplateDeletedString', { static: false })
+        private loadMarcOrderTemplateDeletedString: StringComponent;
+    @ViewChild('loadMarcOrderTemplateSetAsDefaultString', { static: false })
+        private loadMarcOrderTemplateSetAsDefaultString: StringComponent;
+
 
     constructor(
         private http: HttpClient,
@@ -591,21 +599,25 @@ export class UploadComponent implements OnInit, AfterViewInit, OnDestroy {
         const template = {};
         TEMPLATE_ATTRS.forEach(key => template[key] = this[key]);
 
-        console.debug('Saving import profile', template);
-
         this.formTemplates[this.selectedTemplate] = template;
-        return this.store.setItem(TEMPLATE_SETTING_NAME, this.formTemplates);
+        this.store.setItem(TEMPLATE_SETTING_NAME, this.formTemplates).then(x =>
+            this.loadMarcOrderTemplateSavedString.current()
+                .then(str => this.toast.success(str))
+        );
     }
 
     markTemplateDefault() {
 
         Object.keys(this.formTemplates).forEach(
-            name => delete this.formTemplates.default
+            name => delete this.formTemplates[name].default
         );
 
         this.formTemplates[this.selectedTemplate].default = true;
 
-        return this.store.setItem(TEMPLATE_SETTING_NAME, this.formTemplates);
+        this.store.setItem(TEMPLATE_SETTING_NAME, this.formTemplates).then(x =>
+            this.loadMarcOrderTemplateSetAsDefaultString.current()
+                .then(str => this.toast.success(str))
+        );
     }
 
     templateSelectorChange(entry: ComboboxEntry) {
@@ -640,7 +652,10 @@ export class UploadComponent implements OnInit, AfterViewInit, OnDestroy {
     deleteTemplate() {
         delete this.formTemplates[this.selectedTemplate];
         this.formTemplateSelector.selected = null;
-        return this.store.setItem(TEMPLATE_SETTING_NAME, this.formTemplates);
+        this.store.setItem(TEMPLATE_SETTING_NAME, this.formTemplates).then(x =>
+            this.loadMarcOrderTemplateDeletedString.current()
+                .then(str => this.toast.success(str))
+        );
     }
 }