removed commented code, updated 'close' and 'changeTab' methods
This commit is contained in:
parent
08902fe3e0
commit
6ec57b9953
@ -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;
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@ -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'])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user