[28325] Fix double submit on destroy modal

https://community.openproject.com/wp/28325
pull/6576/head
Oliver Günther 6 years ago
parent 61c222d39b
commit bbbcc95f1c
No known key found for this signature in database
GPG Key ID: 88872239EB414F99
  1. 1
      frontend/src/app/components/modals/wp-destroy-modal/wp-destroy.modal.html
  2. 12
      frontend/src/app/components/modals/wp-destroy-modal/wp-destroy.modal.ts

@ -66,6 +66,7 @@
<div class="form--space -left-spacing"> <div class="form--space -left-spacing">
<button class="button -danger" <button class="button -danger"
[textContent]="text.confirm" [textContent]="text.confirm"
[attr.disabled]="busy || undefined"
(click)="confirmDeletion($event)"> (click)="confirmDeletion($event)">
</button> </button>
<button class="button" <button class="button"

@ -51,6 +51,7 @@ export class WpDestroyModal extends OpModalComponent implements OnInit {
// Single work package // Single work package
public singleWorkPackage:WorkPackageResource; public singleWorkPackage:WorkPackageResource;
public singleWorkPackageChildren:WorkPackageResource[]; public singleWorkPackageChildren:WorkPackageResource[];
public busy = false;
public text:any = { public text:any = {
label_visibility_settings: this.I18n.t('js.label_visibility_settings'), label_visibility_settings: this.I18n.t('js.label_visibility_settings'),
@ -106,12 +107,23 @@ export class WpDestroyModal extends OpModalComponent implements OnInit {
public confirmDeletion($event:JQueryEventObject) { public confirmDeletion($event:JQueryEventObject) {
if (this.busy) {
return false;
}
this.busy = true;
this.WorkPackageService.performBulkDelete(this.workPackages.map(el => el.id), true) this.WorkPackageService.performBulkDelete(this.workPackages.map(el => el.id), true)
.then(() => { .then(() => {
this.busy = false;
this.closeMe($event); this.closeMe($event);
this.wpTableFocus.clear(); this.wpTableFocus.clear();
this.$state.go('work-packages.list'); this.$state.go('work-packages.list');
})
.catch(() => {
this.busy = false;
}); });
return false;
} }
public children(workPackage:WorkPackageResource) { public children(workPackage:WorkPackageResource) {

Loading…
Cancel
Save