import { MatDialogRef, MAT_DIALOG_DATA } from "@angular/material"; import { Inject, Component } from "@angular/core"; import { I18nService } from "../../services/internationalisation/internationalisation.service"; @Component({ selector: "dialog-save-session", templateUrl: "dialog-save-session.component.html", styleUrls: ["dialog-save-session.component.scss"] }) export class DialogSaveSessionComponent { public calculators: any[]; public fileName = "session"; constructor( public dialogRef: MatDialogRef<DialogSaveSessionComponent>, private intlService: I18nService, @Inject(MAT_DIALOG_DATA) public data: any ) { this.calculators = data.calculators; } public selectAll() { for (const c of this.calculators) { c.selected = true; } } public selectNone() { for (const c of this.calculators) { c.selected = false; } } public saveSession() { this.dialogRef.close({ calculators: this.calculators, filename: this.fileName }); } public get atLeastOneCheckboxSelected() { let ok = false; for (const c of this.calculators) { ok = (ok || c.selected); } return ok; } public get uitextSave() { return this.intlService.localizeText("INFO_OPTION_SAVE"); } public get uitextCancel() { return this.intlService.localizeText("INFO_OPTION_CANCEL"); } public get uitextAll() { return this.intlService.localizeText("INFO_OPTION_ALL"); } public get uitextNone() { return this.intlService.localizeText("INFO_OPTION_NONE"); } public get uitextSaveSessionTitle() { return this.intlService.localizeText("INFO_DIALOG_SAVE_SESSION_TITLE"); } public get uitextFilenameInput() { return this.intlService.localizeText("INFO_DIALOG_SAVE_SESSION_FILENAME"); } }