web/elements: fix ActionButton

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-04-03 23:23:29 +02:00
parent 1f781eb78a
commit 195951a61a
2 changed files with 6 additions and 7 deletions

View File

@ -16,7 +16,7 @@ export class ActionButton extends SpinnerButton {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
apiRequest: () => Promise<any> = () => { throw new Error(); }; apiRequest: () => Promise<any> = () => { throw new Error(); };
defaultCallAction(): void { callAction = (): void => {
if (this.isRunning === true) { if (this.isRunning === true) {
return; return;
} }
@ -39,5 +39,5 @@ export class ActionButton extends SpinnerButton {
} }
this.setDone(ERROR_CLASS); this.setDone(ERROR_CLASS);
}); });
} };
} }

View File

@ -12,7 +12,7 @@ export class SpinnerButton extends LitElement {
isRunning = false; isRunning = false;
@property() @property()
callAction: () => void = () => {}; callAction?: () => void;
static get styles(): CSSResult[] { static get styles(): CSSResult[] {
return [ return [
@ -51,9 +51,6 @@ export class SpinnerButton extends LitElement {
}, 1000); }, 1000);
} }
defaultCallAction(): void {
}
render(): TemplateResult { render(): TemplateResult {
return html`<button return html`<button
class="pf-c-button pf-m-progress ${this.classList.toString()}" class="pf-c-button pf-m-progress ${this.classList.toString()}"
@ -62,7 +59,9 @@ export class SpinnerButton extends LitElement {
return; return;
} }
this.setLoading(); this.setLoading();
if (this.callAction) {
this.callAction(); this.callAction();
}
}}> }}>
${this.isRunning ${this.isRunning
? html` <span class="pf-c-button__progress"> ? html` <span class="pf-c-button__progress">