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 67 68 69 | 47x 1x 1x 1x 1x 1x 16x 16x 2x 2x 34x 1x 6x 2x 4x 4x 2x | import { Component, inject, signal, input, OnInit } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { LucideAngularModule, X, Trash2 } from 'lucide-angular';
import { TranslocoModule } from '@jsverse/transloco';
import { ModalService } from '../../services/modal.service';
export interface EditListData {
name: string;
description: string;
aloneInList: boolean;
}
export interface EditListResult {
action: 'save' | 'delete' | 'leave';
name?: string;
description?: string;
}
@Component({
selector: 'app-edit-list-modal',
imports: [FormsModule, LucideAngularModule, TranslocoModule],
templateUrl: './edit-list-modal.html',
styleUrl: './edit-list-modal.scss',
})
export class EditListModal implements OnInit {
private readonly modalService = inject(ModalService);
readonly data = input<EditListData>();
readonly icons = { X, Trash2, UserX: X };
readonly name = signal('');
readonly description = signal('');
ngOnInit(): void {
const inputData = this.data();
if (inputData) {
this.name.set(inputData.name);
this.description.set(inputData.description);
}
}
getAloneInList(): boolean {
return this.data()?.aloneInList ?? false;
}
close(): void {
this.modalService.dismiss();
}
submit(): void {
if (!this.name().trim()) {
return;
}
const result: EditListResult = {
action: 'save',
name: this.name().trim(),
description: this.description().trim()
};
this.modalService.close(result);
}
deleteList(): void {
this.modalService.close({ action: this.getAloneInList() ? 'delete' : 'leave' });
}
}
|