emit toast upon saving a default search
authorGalen Charlton <gmc@equinoxinitiative.org>
Tue, 25 Feb 2020 17:55:19 +0000 (12:55 -0500)
committerGalen Charlton <gmc@equinoxinitiative.org>
Tue, 25 Feb 2020 17:55:19 +0000 (12:55 -0500)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/eg2/src/app/staff/acq/search/acq-search-form.component.html
Open-ILS/src/eg2/src/app/staff/acq/search/acq-search-form.component.ts

index 91b70c7..a039578 100644 (file)
@@ -1,3 +1,5 @@
+<eg-string #defaultSearchSavedString i18n-text text="Default search saved"></eg-string>
+
 <div id="acq-search-form" class="pl-3 pr-3 pt-3 pb-3 mb-3">
 <form>
   <div class="row mb-1">
index d9cbdbe..eed2227 100644 (file)
@@ -1,9 +1,11 @@
-import {Component, OnInit, AfterViewInit, Input, Output, EventEmitter} from '@angular/core';
+import {Component, OnInit, AfterViewInit, Input, Output, EventEmitter, ViewChild} from '@angular/core';
 import {NgbTabset, NgbTabChangeEvent} from '@ng-bootstrap/ng-bootstrap';
 import {Router, ActivatedRoute} from '@angular/router';
 import {StaffCommonModule} from '@eg/staff/common.module';
 import {IdlService, IdlObject} from '@eg/core/idl.service';
 import {PcrudService} from '@eg/core/pcrud.service';
+import {StringComponent} from '@eg/share/string/string.component';
+import {ToastService} from '@eg/share/toast/toast.service';
 import {AcqSearchTerm, AcqSearch} from './acq-search.service';
 import {ServerStoreService} from '@eg/core/server-store.service';
 
@@ -22,6 +24,8 @@ export class AcqSearchFormComponent implements OnInit, AfterViewInit {
 
     @Output() searchSubmitted = new EventEmitter<AcqSearch>();
 
+    @ViewChild('defaultSearchSavedString', { static: true}) defaultSearchSavedString: StringComponent;
+
     showForm = true;
 
     hints = ['jub', 'acqpl', 'acqpo', 'acqinv', 'acqlid'];
@@ -42,6 +46,7 @@ export class AcqSearchFormComponent implements OnInit, AfterViewInit {
         private pcrud: PcrudService,
         private store: ServerStoreService,
         private idl: IdlService,
+        private toast: ToastService,
     ) {}
 
     ngOnInit() {
@@ -169,7 +174,11 @@ export class AcqSearchFormComponent implements OnInit, AfterViewInit {
         return this.store.setItem(this.defaultSearchSetting, {
             terms: this.searchTerms,
             conjunction: this.searchConjunction
-        });
+        }).then(() =>
+            this.defaultSearchSavedString.current().then(msg =>
+                this.toast.success(msg)
+            )
+        );
     }
     saveRunImmediately() {
         return this.store.setItem(this.runImmediatelySetting, this.runImmediately);