Toast component

This commit is contained in:
Adina Țeudan 2021-10-07 23:11:08 +03:00
parent 31f1ab09d9
commit 2ea838f572
5 changed files with 3 additions and 49 deletions

View File

@ -15,7 +15,6 @@ import { ServiceWorkerModule } from '@angular/service-worker';
import { environment } from '@environments/environment';
import { AuthModule } from './modules/auth/auth.module';
import { AuthErrorComponent } from '@components/auth-error/auth-error.component';
import { ToastComponent } from '@components/toast/toast.component';
import { HttpCacheInterceptor } from '@redaction/red-cache';
import { NotificationsComponent } from '@components/notifications/notifications.component';
import { DownloadsListScreenComponent } from '@components/downloads-list-screen/downloads-list-screen.component';
@ -35,7 +34,7 @@ import { SpotlightSearchComponent } from '@components/spotlight-search/spotlight
import { PruningTranslationLoader } from '@utils/pruning-translation-loader';
import { DatePipe } from '@shared/pipes/date.pipe';
import * as links from '../assets/help-mode/links.json';
import { HELP_DOCS, IqserHelpModeModule, MAX_RETRIES_ON_SERVER_ERROR, ServerErrorInterceptor } from '@iqser/common-ui';
import { HELP_DOCS, IqserHelpModeModule, MAX_RETRIES_ON_SERVER_ERROR, ServerErrorInterceptor, ToastComponent } from '@iqser/common-ui';
import { KeycloakService } from 'keycloak-angular';
export function httpLoaderFactory(httpClient: HttpClient): PruningTranslationLoader {
@ -54,7 +53,7 @@ function cleanupBaseUrl(baseUrl: string) {
const screens = [BaseScreenComponent, DownloadsListScreenComponent, UserProfileScreenComponent];
const components = [AppComponent, AuthErrorComponent, ToastComponent, NotificationsComponent, SpotlightSearchComponent, ...screens];
const components = [AppComponent, AuthErrorComponent, NotificationsComponent, SpotlightSearchComponent, ...screens];
@NgModule({
declarations: [...components],

View File

@ -1,20 +0,0 @@
<div [style.display]="state.value === 'inactive' ? 'none' : ''" class="row">
<div *ngIf="title" [attr.aria-label]="title" [class]="options.titleClass">
{{ title }}
</div>
<div *ngIf="message && options.enableHtml" [class]="options.messageClass" [innerHTML]="message" aria-live="polite" role="alert"></div>
<div *ngIf="message && !options.enableHtml" [attr.aria-label]="message" [class]="options.messageClass" aria-live="polite" role="alert">
{{ message }}
</div>
<div *ngIf="actions?.length" class="actions-wrapper">
<a (click)="callAction($event, action.action)" *ngFor="let action of actions">
{{ action.title }}
</a>
</div>
</div>
<div class="text-right">
<a (click)="remove()" *ngIf="options.closeButton" class="toast-close-button">
<mat-icon svgIcon="iqser:close"></mat-icon>
</a>
</div>

View File

@ -1,25 +0,0 @@
import { Component } from '@angular/core';
import { Toast, ToastPackage, ToastrService } from 'ngx-toastr';
import { ToasterOptions } from '@iqser/common-ui';
@Component({
templateUrl: './toast.component.html',
styleUrls: ['./toast.component.scss'],
})
export class ToastComponent extends Toast {
constructor(protected readonly _toastrService: ToastrService, readonly toastPackage: ToastPackage) {
super(_toastrService, toastPackage);
}
get actions() {
return (this.options as ToasterOptions)?.actions;
}
callAction($event: MouseEvent, action: () => void) {
$event.stopPropagation();
if (action) {
action();
}
this.remove();
}
}

@ -1 +1 @@
Subproject commit feaaa5d8dc9ebc1075e03a6e7b92f3ccec893fc3
Subproject commit cba1a476d3c78d49d7aa8d0f816ff92b2d073400