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 66 | 2x 2x 2x 2x 2x 2x 2x 2x 1x | import {
ChangeDetectionStrategy,
Component,
DestroyRef,
EventEmitter,
Input,
OnChanges,
Output,
inject,
} from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { TranslateService } from '@ngx-translate/core';
import { take } from 'rxjs/operators';
import { ModalDialogComponent } from 'ish-shared/components/common/modal-dialog/modal-dialog.component';
import { Wishlist } from '../../../models/wishlist/wishlist.model';
/**
* The Account Wishlist List Component show the customer an overview list over his wishlists.
*
* @example
* <ish-account-wishlist-list [wishlists]="wishlists" (deleteWishlist)="deleteWishlist($event)"></ish-account-wishlist-list>
*/
@Component({
selector: 'ish-account-wishlist-list',
templateUrl: './account-wishlist-list.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AccountWishlistListComponent implements OnChanges {
/**
* The list of wishlists of the customer.
*/
@Input() wishlists: Wishlist[];
/**
* Emits the id of the wishlist, which is to be deleted.
*/
@Output() deleteWishlist = new EventEmitter<string>();
preferredWishlist: Wishlist;
private destroyRef = inject(DestroyRef);
constructor(private translate: TranslateService) {}
ngOnChanges() {
// determine preferred wishlist
this.preferredWishlist = this.wishlists?.length ? this.wishlists.find(wishlist => wishlist.preferred) : undefined;
}
/** Emits the id of the wishlist to delete. */
delete(wishlistId: string) {
this.deleteWishlist.emit(wishlistId);
}
/** Determine the heading of the delete modal and opens the modal. */
openDeleteConfirmationDialog(wishlist: Wishlist, modal: ModalDialogComponent<string>) {
this.translate
.get('account.wishlists.delete_wishlist_dialog.header', { 0: wishlist.title })
.pipe(take(1), takeUntilDestroyed(this.destroyRef))
.subscribe(res => (modal.options.titleText = res));
modal.show(wishlist.id);
}
}
|