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 => {
|
this.addSubscription = this.form.controls['validFrom'].valueChanges.subscribe(value => {
|
||||||
if (value) {
|
this._lastValidFrom = value ? value : this._lastValidFrom;
|
||||||
this._lastValidFrom = value;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
this.addSubscription = this.form.controls['validTo'].valueChanges.subscribe(value => {
|
this.addSubscription = this.form.controls['validTo'].valueChanges.subscribe(value => {
|
||||||
if (value) {
|
this._lastValidFrom = value ? value : this._lastValidFrom;
|
||||||
this._lastValidTo = value;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -84,7 +84,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="dialog-actions">
|
<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 }}
|
{{ 'add-edit-file-attribute.save' | translate }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -148,12 +148,7 @@ export class EditDossierDialogComponent extends BaseDialogComponent {
|
|||||||
|
|
||||||
changeTab(key: Section) {
|
changeTab(key: Section) {
|
||||||
if (this.changed) {
|
if (this.changed) {
|
||||||
this._waitingForConfirmation = true;
|
this._openConfirmDialog().then(async result => {
|
||||||
const dialogRef = this._dialogService.openDialog({ disableConfirm: !this.valid });
|
|
||||||
dialogRef
|
|
||||||
.afterClosed()
|
|
||||||
.toPromise()
|
|
||||||
.then(async result => {
|
|
||||||
if (result in ConfirmOptions) {
|
if (result in ConfirmOptions) {
|
||||||
if (result === ConfirmOptions.CONFIRM) {
|
if (result === ConfirmOptions.CONFIRM) {
|
||||||
await this.save();
|
await this.save();
|
||||||
@ -164,8 +159,8 @@ export class EditDossierDialogComponent extends BaseDialogComponent {
|
|||||||
}
|
}
|
||||||
this._waitingForConfirmation = false;
|
this._waitingForConfirmation = false;
|
||||||
});
|
});
|
||||||
return;
|
} else {
|
||||||
}
|
|
||||||
this.activeNav = key;
|
this.activeNav = key;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,10 +42,6 @@ export abstract class BaseDialogComponent extends AutoUnsubscribe implements OnI
|
|||||||
}
|
}
|
||||||
|
|
||||||
get changed(): boolean {
|
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())) {
|
for (const key of Object.keys(this.form.getRawValue())) {
|
||||||
const initialValue = this.initialForm.get(key).value;
|
const initialValue = this.initialForm.get(key).value;
|
||||||
const updatedValue = this.form.get(key).value;
|
const updatedValue = this.form.get(key).value;
|
||||||
@ -78,12 +74,7 @@ export abstract class BaseDialogComponent extends AutoUnsubscribe implements OnI
|
|||||||
|
|
||||||
close(): void {
|
close(): void {
|
||||||
if (this.changed) {
|
if (this.changed) {
|
||||||
this._waitingForConfirmation = true;
|
this._openConfirmDialog().then(result => {
|
||||||
const dialogRef = this._dialogService.openDialog({ disableConfirm: !this.valid });
|
|
||||||
dialogRef
|
|
||||||
.afterClosed()
|
|
||||||
.toPromise()
|
|
||||||
.then(result => {
|
|
||||||
if (result in ConfirmOptions) {
|
if (result in ConfirmOptions) {
|
||||||
if (result === ConfirmOptions.CONFIRM) {
|
if (result === ConfirmOptions.CONFIRM) {
|
||||||
this.save(true);
|
this.save(true);
|
||||||
@ -93,10 +84,16 @@ export abstract class BaseDialogComponent extends AutoUnsubscribe implements OnI
|
|||||||
}
|
}
|
||||||
this._waitingForConfirmation = false;
|
this._waitingForConfirmation = false;
|
||||||
});
|
});
|
||||||
return;
|
} 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'])
|
@HostListener('window:keydown.Enter', ['$event'])
|
||||||
onEnter(event: KeyboardEvent): void {
|
onEnter(event: KeyboardEvent): void {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user