From ce3b4cd8170b40011751581c92ff63a3e870b6dd Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 26 Jun 2018 09:04:12 -0400 Subject: [PATCH] save button for options --- src/app/settings/options.component.html | 39 ++++++++++++++----------- src/app/settings/options.component.ts | 28 +++++++++--------- src/locales/en/messages.json | 3 ++ 3 files changed, 38 insertions(+), 32 deletions(-) diff --git a/src/app/settings/options.component.html b/src/app/settings/options.component.html index f4edad1870..9297146bbe 100644 --- a/src/app/settings/options.component.html +++ b/src/app/settings/options.component.html @@ -2,23 +2,28 @@

{{'options' | i18n}}

{{'optionsDesc' | i18n}}

-
-
-
- - - {{'languageDesc' | i18n}} +
+
+
+
+ + + {{'languageDesc' | i18n}} +
-
-
-
- - +
+
+ + +
+ {{'disableIconsDesc' | i18n}}
- {{'disableIconsDesc' | i18n}} -
+ + diff --git a/src/app/settings/options.component.ts b/src/app/settings/options.component.ts index b7ac63888d..c42ce620fd 100644 --- a/src/app/settings/options.component.ts +++ b/src/app/settings/options.component.ts @@ -3,6 +3,7 @@ import { OnInit, } from '@angular/core'; +import { ToasterService } from 'angular2-toaster'; import { Angulartics2 } from 'angulartics2'; import { I18nService } from 'jslib/abstractions/i18n.service'; @@ -20,8 +21,11 @@ export class OptionsComponent implements OnInit { locale: string; localeOptions: any[]; + private startingLocale: string; + constructor(private storageService: StorageService, private stateService: StateService, - private analytics: Angulartics2, i18nService: I18nService) { + private analytics: Angulartics2, private i18nService: I18nService, + private toasterService: ToasterService) { this.localeOptions = [{ name: i18nService.t('default'), value: null }]; i18nService.supportedTranslationLocales.forEach((locale) => { this.localeOptions.push({ name: locale, value: locale }); @@ -30,24 +34,18 @@ export class OptionsComponent implements OnInit { async ngOnInit() { this.disableIcons = await this.storageService.get(ConstantsService.disableFaviconKey); - this.locale = await this.storageService.get(ConstantsService.localeKey); + this.locale = this.startingLocale = await this.storageService.get(ConstantsService.localeKey); } - async saveIcons() { + async submit() { await this.storageService.save(ConstantsService.disableFaviconKey, this.disableIcons); await this.stateService.save(ConstantsService.disableFaviconKey, this.disableIcons); - this.callAnalytics('Website Icons', !this.disableIcons); - } - - async saveLocale() { await this.storageService.save(ConstantsService.localeKey, this.locale); - this.analytics.eventTrack.next({ action: 'Set Locale ' + this.locale }); - window.location.reload(); + this.analytics.eventTrack.next({ action: 'Saved Options' }); + if (this.locale !== this.startingLocale) { + window.location.reload(); + } else { + this.toasterService.popAsync('success', null, this.i18nService.t('optionsUpdated')); + } } - - private callAnalytics(name: string, enabled: boolean) { - const status = enabled ? 'Enabled' : 'Disabled'; - this.analytics.eventTrack.next({ action: `${status} ${name}` }); - } - } diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json index 23b2f6d6c7..dfd6b3eec8 100644 --- a/src/locales/en/messages.json +++ b/src/locales/en/messages.json @@ -900,6 +900,9 @@ "optionsDesc": { "message": "Customize your web vault experience." }, + "optionsUpdated": { + "message": "Options updated" + }, "language": { "message": "Language" },