Skip to content

Commit da9974c

Browse files
committed
saving added, it used to prevent double clicks
1 parent 46f3bd0 commit da9974c

File tree

1 file changed

+22
-8
lines changed

1 file changed

+22
-8
lines changed

angular/src/app/roles/create-or-edit-role-dialog.component.ts

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
CreateRoleDto
1515
} from '@shared/service-proxies/service-proxies';
1616
import { AppComponentBase } from '@shared/app-component-base';
17+
import { finalize } from 'rxjs/operators';
1718

1819
@Component({
1920
templateUrl: 'create-or-edit-role-dialog.component.html',
@@ -36,6 +37,7 @@ export class CreateOrEditRoleDialogComponent extends AppComponentBase
3637
checkedPermissionsMap: { [key: string]: boolean } = {};
3738
defaultPermissionCheckedStatus = true;
3839
permissionName = '';
40+
saving = false;
3941

4042
constructor(
4143
injector: Injector,
@@ -105,22 +107,34 @@ export class CreateOrEditRoleDialogComponent extends AppComponentBase
105107
}
106108

107109
save(): void {
110+
this.saving = true;
111+
108112
const role = new RoleDto();
109113
role.permissions = this.getCheckedPermissions();
110114
role.init(this.role);
111115

112116
if (this.isCreateDialog()) {
113117
const createRole = new CreateRoleDto();
114118
createRole.init(role);
115-
this._roleService.create(createRole).subscribe(() => {
116-
this.notify.info(this.l('SavedSuccessfully'));
117-
this.close(true);
118-
});
119+
this._roleService.create(createRole)
120+
.pipe(
121+
finalize(() => {
122+
this.saving = false;
123+
})
124+
).subscribe(() => {
125+
this.notify.info(this.l('SavedSuccessfully'));
126+
this.close(true);
127+
});
119128
} else {
120-
this._roleService.update(role).subscribe(() => {
121-
this.notify.info(this.l('SavedSuccessfully'));
122-
this.close(true);
123-
});
129+
this._roleService.update(role)
130+
.pipe(
131+
finalize(() => {
132+
this.saving = false;
133+
})
134+
).subscribe(() => {
135+
this.notify.info(this.l('SavedSuccessfully'));
136+
this.close(true);
137+
});
124138
}
125139
}
126140

0 commit comments

Comments
 (0)