web/elements: rewrite SpinnerButton to promises, fix spinner button with forms after errors

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer
2021-04-04 20:42:50 +02:00
parent 52029f55e4
commit 002c048d0b
7 changed files with 44 additions and 52 deletions

View File

@ -20,8 +20,8 @@ export class ConfirmationForm extends ModalButton {
@property({attribute: false})
onConfirm!: () => Promise<unknown>;
confirm(): void {
this.onConfirm().then(() => {
confirm(): Promise<void> {
return this.onConfirm().then(() => {
this.onSuccess();
this.open = false;
this.dispatchEvent(
@ -32,6 +32,7 @@ export class ConfirmationForm extends ModalButton {
);
}).catch((e) => {
this.onError(e);
throw e;
});
}
@ -65,13 +66,13 @@ export class ConfirmationForm extends ModalButton {
<footer class="pf-c-modal-box__footer">
<ak-spinner-button
.callAction=${() => {
this.confirm();
return this.confirm();
}}
class="pf-m-danger">
${this.action}
</ak-spinner-button>&nbsp;
<ak-spinner-button
.callAction=${() => {
.callAction=${async () => {
this.open = false;
}}
class="pf-m-secondary">