Skip to content

Commit

Permalink
fix(core): add hasIcon for notificationServices (#274)
Browse files Browse the repository at this point in the history
* fix(core): add hasIcon for notificationServices

* fix(core): fixed default value

* fix(core): fixed default value

* fix(core): delete some getters

Co-authored-by: Дубинский Никита Игоревич <n.dubinskiy@tcsbank.ru>
  • Loading branch information
nikitadubinsk and Дубинский Никита Игоревич committed Mar 10, 2021
1 parent a753a5e commit 0519af6
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import {
export class NotificationAlert<O, I> {
readonly status: TuiNotification;

readonly hasIcon: boolean;

readonly autoClose: boolean;

readonly hasCloseButton: boolean;
Expand All @@ -30,6 +32,7 @@ export class NotificationAlert<O, I> {
const {
label = '',
status = TuiNotification.Info,
hasIcon = true,
autoClose = true,
hasCloseButton = true,
} = options;
Expand All @@ -39,6 +42,7 @@ export class NotificationAlert<O, I> {

this.label = label;
this.status = status;
this.hasIcon = hasIcon;
this.autoClose = autoClose;
this.hasCloseButton = hasCloseButton;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import {ChangeDetectionStrategy, Component, Inject, Input} from '@angular/core';
import {TuiDestroyService, tuiPure} from '@taiga-ui/cdk';
import {TuiNotification} from '@taiga-ui/core/enums';
import {timer} from 'rxjs';
import {takeUntil} from 'rxjs/operators';

Expand Down Expand Up @@ -45,14 +44,6 @@ export class TuiNotificationAlertComponent<O, I> {
return this.calculateContext(this.safeItem);
}

get hasCloseButton(): boolean {
return this.safeItem.hasCloseButton;
}

get status(): TuiNotification {
return this.safeItem.status;
}

closeDialog() {
this.safeItem.observer.complete();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<tui-notification
*ngIf="hasCloseButton else noClose"
[status]="status"
*ngIf="safeItem.hasCloseButton else noClose"
[status]="safeItem.status"
[hasIcon]="safeItem.hasIcon"
(close)="closeDialog()"
>
<label
Expand All @@ -19,7 +20,7 @@
></div>
</tui-notification>
<ng-template #noClose>
<tui-notification [status]="status">
<tui-notification [status]="safeItem.status" [hasIcon]="safeItem.hasIcon">
<label
*ngIf="safeItem.label"
automation-id="tui-notification-alert__heading"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {TuiNotification} from '@taiga-ui/core/enums';
export interface TuiNotificationOptions {
readonly label?: string;
readonly status?: TuiNotification;
readonly hasIcon?: boolean;
readonly autoClose?: boolean;
readonly hasCloseButton?: boolean;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export class ExampleTuiNotificationsComponent {

hasCloseButton = true;

hasIcon = true;

readonly component: PolymorpheusComponent<
AlertExampleWithDataComponent,
TuiNotificationContentContext<number, number>
Expand Down Expand Up @@ -114,6 +116,7 @@ export class ExampleTuiNotificationsComponent {
status: this.status,
autoClose: this.autoClose,
hasCloseButton: this.hasCloseButton,
hasIcon: this.hasIcon,
})
.pipe(
switchMap(response =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,14 @@
>
Has close button
</ng-template>
<ng-template
i18n
documentationPropertyName="hasIcon"
documentationPropertyType="boolean"
[(documentationPropertyValue)]="hasIcon"
>
Has icon
</ng-template>
</tui-doc-documentation>
</ng-template>
<ng-template pageTab>
Expand Down

0 comments on commit 0519af6

Please sign in to comment.