Browse Source

refactor: toaster localization types

pull/2119/head
mehmet-erim 7 years ago
parent
commit
e06ef46698
  1. 2
      npm/ng-packs/packages/core/src/lib/models/config.ts
  2. 2
      npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts
  3. 18
      npm/ng-packs/packages/theme-shared/src/lib/abstracts/toaster.ts

2
npm/ng-packs/packages/core/src/lib/models/config.ts

@ -35,4 +35,6 @@ export namespace Config {
key: string;
defaultValue: string;
}
export type LocalizationParam = string | LocalizationWithDefault;
}

2
npm/ng-packs/packages/identity/src/lib/components/users/users.component.ts

@ -163,7 +163,7 @@ export class UsersComponent implements OnInit {
}
save() {
if (!this.form.valid) return;
if (!this.form.valid || this.modalBusy) return;
this.modalBusy = true;
const { roleNames } = this.form.value;

18
npm/ng-packs/packages/theme-shared/src/lib/abstracts/toaster.ts

@ -1,6 +1,7 @@
import { MessageService } from 'primeng/components/common/messageservice';
import { Observable, Subject } from 'rxjs';
import { Toaster } from '../models/toaster';
import { Config } from '@abp/ng.core';
export abstract class AbstractToaster<T = Toaster.Options> {
status$: Subject<Toaster.Status>;
@ -11,23 +12,28 @@ export abstract class AbstractToaster<T = Toaster.Options> {
constructor(protected messageService: MessageService) {}
info(message: string, title: string, options?: T): Observable<Toaster.Status> {
info(message: Config.LocalizationParam, title: Config.LocalizationParam, options?: T): Observable<Toaster.Status> {
return this.show(message, title, 'info', options);
}
success(message: string, title: string, options?: T): Observable<Toaster.Status> {
success(message: Config.LocalizationParam, title: Config.LocalizationParam, options?: T): Observable<Toaster.Status> {
return this.show(message, title, 'success', options);
}
warn(message: string, title: string, options?: T): Observable<Toaster.Status> {
warn(message: Config.LocalizationParam, title: Config.LocalizationParam, options?: T): Observable<Toaster.Status> {
return this.show(message, title, 'warn', options);
}
error(message: string, title: string, options?: T): Observable<Toaster.Status> {
error(message: Config.LocalizationParam, title: Config.LocalizationParam, options?: T): Observable<Toaster.Status> {
return this.show(message, title, 'error', options);
}
protected show(message: string, title: string, severity: Toaster.Severity, options?: T): Observable<Toaster.Status> {
protected show(
message: Config.LocalizationParam,
title: Config.LocalizationParam,
severity: Toaster.Severity,
options?: T,
): Observable<Toaster.Status> {
this.messageService.clear(this.key);
this.messageService.add({
@ -36,7 +42,7 @@ export abstract class AbstractToaster<T = Toaster.Options> {
summary: title || '',
...options,
key: this.key,
...(typeof (options || ({} as any)).sticky === 'undefined' && { sticky: this.sticky })
...(typeof (options || ({} as any)).sticky === 'undefined' && { sticky: this.sticky }),
});
this.status$ = new Subject<Toaster.Status>();
return this.status$;

Loading…
Cancel
Save