fix(theme-shared): fix closing confirmation with esc

pull/2606/head
mehmet-erim 6 years ago
parent 75b32f21bc
commit 5246e60647

@ -38,12 +38,11 @@ export class ConfirmationComponent {
) {
this.confirmationService.confirmation$.subscribe(confirmation => {
this.data = confirmation;
this.visible = true;
this.visible = !!confirmation;
});
}
close(status: Toaster.Status) {
this.confirmationService.clear(status);
this.visible = false;
}
}

@ -2,6 +2,7 @@ import { Component, Input, OnInit } from '@angular/core';
import { Toaster } from '../../models';
import { ToasterService } from '../../services/toaster.service';
import { LocalizationService } from '@abp/ng.core';
import snq from 'snq';
@Component({
selector: 'abp-toast',
@ -38,8 +39,8 @@ export class ToastComponent implements OnInit {
) {}
ngOnInit() {
if (this.toast.options && this.toast.options.sticky) return;
const timeout = this.toast.options.life || 5000;
if (snq(() => this.toast.options.sticky)) return;
const timeout = snq(() => this.toast.options.life) || 5000;
setTimeout(() => {
this.close();
}, timeout);

@ -60,6 +60,7 @@ export class ConfirmationService {
}
clear(status?: Toaster.Status) {
this.confirmation$.next();
this.status$.next(status || Toaster.Status.dismiss);
}

@ -2,6 +2,7 @@ import { Injectable } from '@angular/core';
import { Toaster } from '../models';
import { ReplaySubject } from 'rxjs';
import { Config } from '@abp/ng.core';
import snq from 'snq';
@Injectable({
providedIn: 'root',
@ -81,7 +82,7 @@ export class ToasterService {
message: Config.LocalizationParam,
title: Config.LocalizationParam = null,
severity: Toaster.Severity = 'neutral',
options: Partial<Toaster.ToastOptions> = null,
options = {} as Partial<Toaster.ToastOptions>,
) {
const id = ++this.lastId;
this.toasts.push({
@ -99,7 +100,7 @@ export class ToasterService {
* @param id ID of the toast to be removed.
*/
remove(id: number) {
this.toasts = this.toasts.filter(toast => toast.options.id !== id);
this.toasts = this.toasts.filter(toast => snq(() => toast.options.id) !== id);
this.toasts$.next(this.toasts);
}
@ -107,7 +108,9 @@ export class ToasterService {
* Removes all open toasts at once.
*/
clear(key?: string) {
this.toasts = !key ? [] : this.toasts.filter(toast => toast.options.containerKey !== key);
this.toasts = !key
? []
: this.toasts.filter(toast => snq(() => toast.options.containerKey) !== key);
this.toasts$.next(this.toasts);
}
}

Loading…
Cancel
Save