Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 7x 7x 7x 6x 4x 4x | import { ChangeDetectionStrategy, Component, DestroyRef, Input, OnInit, inject } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { Router } from '@angular/router'; import { Observable } from 'rxjs'; import { map, take } from 'rxjs/operators'; import { AccountFacade } from 'ish-core/facades/account.facade'; import { ProductContextFacade } from 'ish-core/facades/product-context.facade'; import { GenerateLazyComponent } from 'ish-core/utils/module-loader/generate-lazy-component.decorator'; import { ProductNotification } from '../../models/product-notification/product-notification.model'; import { ProductNotificationEditDialogComponent } from '../product-notification-edit-dialog/product-notification-edit-dialog.component'; /** * The Product Notification Edit Component shows the customer a link to open the dialog to either create, * edit or delete a product notification. * * @example * <ish-product-notification-edit * cssClass="btn-link btn-tool" * [productNotification]="productNotification" * displayType="icon"></ish-product-notification-edit> */ @Component({ selector: 'ish-product-notification-edit', templateUrl: './product-notification-edit.component.html', changeDetection: ChangeDetectionStrategy.OnPush, }) @GenerateLazyComponent() export class ProductNotificationEditComponent implements OnInit { @Input() productNotification: ProductNotification; @Input() displayType: 'button' | 'icon' = 'button'; @Input() cssClass: string; visible$: Observable<boolean>; private destroyRef = inject(DestroyRef); constructor(private context: ProductContextFacade, private accountFacade: AccountFacade, private router: Router) {} ngOnInit() { this.visible$ = this.context.select('displayProperties', 'addToNotification'); } // keep-localization-pattern: ^product\.notification\..*\.notification\.button.* buttonKey(key: string): Observable<string> { return this.context .select('product', 'available') .pipe(map(available => `product.notification.${available ? 'price' : 'stock'}.notification.button.${key}`)); } // if the user is not logged in display login dialog, else open notification dialog openModal(modal: ProductNotificationEditDialogComponent) { this.accountFacade.isLoggedIn$.pipe(take(1), takeUntilDestroyed(this.destroyRef)).subscribe(isLoggedIn => { if (isLoggedIn) { modal.show(); } else { // stay on the same page after login const queryParams = { returnUrl: this.router.routerState.snapshot.url, messageKey: 'productnotification' }; this.router.navigate(['/login'], { queryParams }); } }); } } |