From 914d7d98769a03f44d5b8e8e1a38f6522725f60a Mon Sep 17 00:00:00 2001 From: yinonov Date: Sat, 28 Nov 2020 21:13:27 +0200 Subject: [PATCH] feat(snackbar): global settings for snackbar --- apps/joie/src/app/core/material.module.ts | 7 ++++++- .../session-form/session-form.component.ts | 11 ++--------- .../joie/src/app/session-form/session-form.module.ts | 2 -- .../session-list/session-list.component.html | 2 +- .../session-list/session-list.component.ts | 6 +++++- .../session-enroll-dialog.component.ts | 12 ++---------- .../session-owner-links.component.ts | 6 +----- .../session-details/session-details.component.ts | 2 +- 8 files changed, 18 insertions(+), 30 deletions(-) diff --git a/apps/joie/src/app/core/material.module.ts b/apps/joie/src/app/core/material.module.ts index e36b05128..e46250cff 100644 --- a/apps/joie/src/app/core/material.module.ts +++ b/apps/joie/src/app/core/material.module.ts @@ -26,6 +26,7 @@ import { MatSelectModule } from '@angular/material/select'; import { MatSidenavModule } from '@angular/material/sidenav'; import { MatSlideToggleModule } from '@angular/material/slide-toggle'; import { MatSliderModule } from '@angular/material/slider'; +import { MatSnackBarModule } from '@angular/material/snack-bar'; import { MatSortModule } from '@angular/material/sort'; import { MatStepperModule } from '@angular/material/stepper'; import { MatTableModule } from '@angular/material/table'; @@ -33,6 +34,8 @@ import { MatTabsModule } from '@angular/material/tabs'; import { MatToolbarModule } from '@angular/material/toolbar'; import { MatTooltipModule } from '@angular/material/tooltip'; +import { MAT_SNACK_BAR_DEFAULT_OPTIONS } from '@angular/material/snack-bar'; +const snackBarOptions = { duration: 4000, horizontalPosition: 'end', verticalPosition: 'top' }; @NgModule({ imports: [ OverlayModule, @@ -67,6 +70,7 @@ import { MatTooltipModule } from '@angular/material/tooltip'; MatStepperModule, MatSidenavModule, MatIconModule, + MatSnackBarModule, CdkStepperModule, ], exports: [ @@ -102,8 +106,9 @@ import { MatTooltipModule } from '@angular/material/tooltip'; MatStepperModule, MatSidenavModule, MatIconModule, - + MatSnackBarModule, CdkStepperModule, ], + providers: [{ provide: MAT_SNACK_BAR_DEFAULT_OPTIONS, useValue: snackBarOptions }], }) export class MaterialModule {} diff --git a/apps/joie/src/app/session-form/containers/session-form/session-form.component.ts b/apps/joie/src/app/session-form/containers/session-form/session-form.component.ts index cbd33f446..49544aec7 100644 --- a/apps/joie/src/app/session-form/containers/session-form/session-form.component.ts +++ b/apps/joie/src/app/session-form/containers/session-form/session-form.component.ts @@ -103,15 +103,8 @@ export class SessionFormComponent extends DynaFormBaseComponent implements OnIni .subscribe( (res) => { this.showLoader = false; - this.snackBar.open( - `Session ${get(this.data, 'sessionId', false) ? 'updated' : 'created'} successfully`, - 'View', - { - duration: 4000, - horizontalPosition: 'end', - verticalPosition: 'bottom', - }, - ); + const sessionId = get(this.data, 'sessionId', false); + this.snackBar.open(`Session ${sessionId ? 'updated' : 'created'} successfully`, 'View'); if (!get(this.data, 'session', false)) { this.form.reset(); } diff --git a/apps/joie/src/app/session-form/session-form.module.ts b/apps/joie/src/app/session-form/session-form.module.ts index b4d04db3e..c210599dd 100644 --- a/apps/joie/src/app/session-form/session-form.module.ts +++ b/apps/joie/src/app/session-form/session-form.module.ts @@ -20,7 +20,6 @@ import { SessionFormDateTimeComponent } from './components/session-form-date-tim import { SessionFormComponent } from './containers/session-form/session-form.component'; import { KalturaPlayerModule } from '../kaltura-player/kaltura-player.module'; import { SessionFormRepetitionsComponent } from './components/session-form-repetitions/session-form-repetitions.component'; -import { MatSnackBarModule } from '@angular/material/snack-bar'; import { SessionFormDurationComponent } from './components/session-form-duration/session-form-duration.component'; @NgModule({ @@ -44,7 +43,6 @@ import { SessionFormDurationComponent } from './components/session-form-duration MatSelectModule, MatInputModule, MatNativeDateModule, - MatSnackBarModule, DynaFormModule, KalturaPlayerModule, ], diff --git a/apps/joie/src/app/session-list/components/session-list/session-list.component.html b/apps/joie/src/app/session-list/components/session-list/session-list.component.html index 44c5eb1b7..6f298b6e5 100644 --- a/apps/joie/src/app/session-list/components/session-list/session-list.component.html +++ b/apps/joie/src/app/session-list/components/session-list/session-list.component.html @@ -1,3 +1,3 @@ - + diff --git a/apps/joie/src/app/session-list/components/session-list/session-list.component.ts b/apps/joie/src/app/session-list/components/session-list/session-list.component.ts index abf3cc5df..be36d0fdb 100644 --- a/apps/joie/src/app/session-list/components/session-list/session-list.component.ts +++ b/apps/joie/src/app/session-list/components/session-list/session-list.component.ts @@ -29,6 +29,11 @@ export class SessionListComponent implements OnInit { ); } + getData(snapshot: QueryDocumentSnapshot) { + const { id } = snapshot; + return { ...snapshot.data(), id }; + } + private initListQuery() { queryFn$.next( (ref: CollectionReference): firebase.firestore.Query => @@ -45,7 +50,6 @@ export class SessionListComponent implements OnInit { queryFn$.next( (ref: CollectionReference): firebase.firestore.Query => this.optionalQueryFn(ref) - .where('status', '==', Status.Public) .orderBy(this.#field) .startAfter(last) diff --git a/apps/joie/src/app/sessions/components/session-enroll-dialog/session-enroll-dialog.component.ts b/apps/joie/src/app/sessions/components/session-enroll-dialog/session-enroll-dialog.component.ts index 9ddafbdbb..e6d23186d 100644 --- a/apps/joie/src/app/sessions/components/session-enroll-dialog/session-enroll-dialog.component.ts +++ b/apps/joie/src/app/sessions/components/session-enroll-dialog/session-enroll-dialog.component.ts @@ -25,17 +25,9 @@ export class SessionEnrollDialogComponent { const resp = await this.paymentService.sessionCharge(this.sessionId).toPromise(); this.dialogRef.close(); if (resp && resp.type === 'success') { - this.snackBar.open(`Session Enrolment sucessful`, 'Close', { - duration: 4000, - horizontalPosition: 'end', - verticalPosition: 'bottom', - }); + this.snackBar.open(`Session Enrolment sucessful`, 'Close'); return; } - this.snackBar.open(`Session Enrolment failed`, 'Close', { - duration: 4000, - horizontalPosition: 'end', - verticalPosition: 'bottom', - }); + this.snackBar.open(`Session Enrolment failed`, 'Close'); } } diff --git a/apps/joie/src/app/sessions/components/session-owner-links/session-owner-links.component.ts b/apps/joie/src/app/sessions/components/session-owner-links/session-owner-links.component.ts index e93900c23..8ea181219 100644 --- a/apps/joie/src/app/sessions/components/session-owner-links/session-owner-links.component.ts +++ b/apps/joie/src/app/sessions/components/session-owner-links/session-owner-links.component.ts @@ -44,11 +44,7 @@ export class SessionOwnerLinksComponent { if (type === 'success') { this.router.navigate(['/account', 'sessions']); } - this.snackBar.open(message, undefined, { - duration: 8000, - horizontalPosition: 'end', - verticalPosition: 'bottom', - }); + this.snackBar.open(message, undefined); } @Confirmable( diff --git a/apps/joie/src/app/sessions/containers/session-details/session-details.component.ts b/apps/joie/src/app/sessions/containers/session-details/session-details.component.ts index 43fbdb7af..87041e0ec 100644 --- a/apps/joie/src/app/sessions/containers/session-details/session-details.component.ts +++ b/apps/joie/src/app/sessions/containers/session-details/session-details.component.ts @@ -14,7 +14,7 @@ import { Pillar, PillarsIconsMap } from '../../../../../../../libs/schemes/src'; }) export class SessionDetailsComponent { sessionId$: Observable = this.activatedRoute.params.pipe(pluck('sessionId')); - session$ = this.sessionId$.pipe(switchMap(this.sessionsFacade.getSession), shareReplay(1)); + session$ = this.sessionId$.pipe(switchMap(this.sessionsFacade.getSession.bind(this.sessionsFacade)), shareReplay(1)); owner$ = this.session$.pipe(pluck('owner'), shareReplay(1)); sessionOwnerId$ = this.owner$.pipe(pluck('uid'), shareReplay(1)); isOwner$ = this.sessionOwnerId$.pipe(