removed commented code, updated 'close' and 'changeTab' methods

This commit is contained in:
Valentin 2022-01-05 12:27:01 +02:00 committed by Timo Bejan
parent 08902fe3e0
commit 6ec57b9953
4 changed files with 32 additions and 44 deletions

View File

@ -54,14 +54,10 @@ export class AddEditDossierTemplateDialogComponent extends BaseDialogComponent {
});
this.addSubscription = this.form.controls['validFrom'].valueChanges.subscribe(value => {
if (value) {
this._lastValidFrom = value;
}
this._lastValidFrom = value ? value : this._lastValidFrom;
});
this.addSubscription = this.form.controls['validTo'].valueChanges.subscribe(value => {
if (value) {
this._lastValidTo = value;
}
this._lastValidFrom = value ? value : this._lastValidFrom;
});
}

View File

@ -84,7 +84,7 @@
</div>
</div>
<div class="dialog-actions">
<button (click)="save()" [disabled]="!valid" color="primary" mat-flat-button>
<button (click)="save()" [disabled]="!valid || !changed" color="primary" mat-flat-button>
{{ 'add-edit-file-attribute.save' | translate }}
</button>
</div>

View File

@ -148,24 +148,19 @@ export class EditDossierDialogComponent extends BaseDialogComponent {
changeTab(key: Section) {
if (this.changed) {
this._waitingForConfirmation = true;
const dialogRef = this._dialogService.openDialog({ disableConfirm: !this.valid });
dialogRef
.afterClosed()
.toPromise()
.then(async result => {
if (result in ConfirmOptions) {
if (result === ConfirmOptions.CONFIRM) {
await this.save();
} else {
this.revert();
}
this.activeNav = key;
this._openConfirmDialog().then(async result => {
if (result in ConfirmOptions) {
if (result === ConfirmOptions.CONFIRM) {
await this.save();
} else {
this.revert();
}
this._waitingForConfirmation = false;
});
return;
this.activeNav = key;
}
this._waitingForConfirmation = false;
});
} else {
this.activeNav = key;
}
this.activeNav = key;
}
}

View File

@ -42,10 +42,6 @@ export abstract class BaseDialogComponent extends AutoUnsubscribe implements OnI
}
get changed(): boolean {
// console.log('-------------------------------------------------------');
// console.log('initialForm: ', this.initialForm.value);
// console.log('form: ', this.form.value);
for (const key of Object.keys(this.form.getRawValue())) {
const initialValue = this.initialForm.get(key).value;
const updatedValue = this.form.get(key).value;
@ -78,24 +74,25 @@ export abstract class BaseDialogComponent extends AutoUnsubscribe implements OnI
close(): void {
if (this.changed) {
this._waitingForConfirmation = true;
const dialogRef = this._dialogService.openDialog({ disableConfirm: !this.valid });
dialogRef
.afterClosed()
.toPromise()
.then(result => {
if (result in ConfirmOptions) {
if (result === ConfirmOptions.CONFIRM) {
this.save(true);
} else {
this._dialogRef.close();
}
this._openConfirmDialog().then(result => {
if (result in ConfirmOptions) {
if (result === ConfirmOptions.CONFIRM) {
this.save(true);
} else {
this._dialogRef.close();
}
this._waitingForConfirmation = false;
});
return;
}
this._waitingForConfirmation = false;
});
} else {
this._dialogRef.close();
}
this._dialogRef.close();
}
protected _openConfirmDialog() {
this._waitingForConfirmation = true;
const dialogRef = this._dialogService.openDialog({ disableConfirm: !this.valid });
return dialogRef.afterClosed().toPromise();
}
@HostListener('window:keydown.Enter', ['$event'])