From 60e78c68b5ef73b7cb602c10b12ebae527fbfed3 Mon Sep 17 00:00:00 2001 From: SteinerPascal Date: Tue, 13 Sep 2022 14:43:56 +0200 Subject: [PATCH] fixes #67 --- src/index.html | 9 +++++---- src/sparnatural.ts | 8 ++++++++ src/sparnatural/components/Sparnatural.ts | 14 +++++++++----- src/sparnatural/components/buttons/PlayBtn.ts | 4 ++-- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/index.html b/src/index.html index 5239ae30..51c9a9df 100644 --- a/src/index.html +++ b/src/index.html @@ -119,11 +119,12 @@ yasqe.setValue(queryString); }, // triggered when "play" button is clicked - onSubmit: function(sparnat) { + onSubmit: ()=> { + sparnatural.disablePlayBtn(); // trigger the query from YasQE yasqe.query(); - sparnat.onQuerySubmitted(); - } + + }, } sparnatural.settings = settings }) @@ -156,7 +157,7 @@ // link yasqe and yasr yasqe.on("queryResponse", function(_yasqe, response, duration) { yasr.setResponse(response, duration); - sparnatural.onQueryFinished() ; + sparnatural.enablePlayBtn() ; }); diff --git a/src/sparnatural.ts b/src/sparnatural.ts index bc356e71..32368572 100644 --- a/src/sparnatural.ts +++ b/src/sparnatural.ts @@ -58,6 +58,14 @@ class SparNatural extends HTMLElement { $(this).append(this.Sparnatural.html); this.Sparnatural.render(); } + + enablePlayBtn(){ + this.Sparnatural.enablePlayBtn() + } + + disablePlayBtn(){ + this.Sparnatural.disablePlayBtn() + } } customElements.get("spar-natural") || diff --git a/src/sparnatural/components/Sparnatural.ts b/src/sparnatural/components/Sparnatural.ts index 35fe24d5..f453d7cf 100644 --- a/src/sparnatural/components/Sparnatural.ts +++ b/src/sparnatural/components/Sparnatural.ts @@ -24,6 +24,7 @@ class Sparnatural extends HTMLComponent { filter = $( '' ); + constructor() { //Sparnatural: Does not have a ParentComponent! super("Sparnatural", null, null); @@ -70,12 +71,15 @@ class Sparnatural extends HTMLComponent { // initStatistics(specProvider); } - onQuerySubmitted() { - this.SubmitSection.playBtn.enableLoading(); + // method is exposed from the HTMLElement + enablePlayBtn = () =>{ + this.SubmitSection.playBtn.enable(); } - - onQueryFinished() { - this.SubmitSection.playBtn.disableLoading(); + + // method is exposed from the HTMLElement + disablePlayBtn = () => { + this.SubmitSection.playBtn.disable(); } + } export default Sparnatural; diff --git a/src/sparnatural/components/buttons/PlayBtn.ts b/src/sparnatural/components/buttons/PlayBtn.ts index fdb92725..0d2a5341 100644 --- a/src/sparnatural/components/buttons/PlayBtn.ts +++ b/src/sparnatural/components/buttons/PlayBtn.ts @@ -16,11 +16,11 @@ class PlayBtn extends HTMLComponent { return this; } - enableLoading() { + disable() { this.widgetHtml.addClass('submitDisable loadingEnabled'); } - disableLoading() { + enable() { this.widgetHtml.removeClass('loadingEnabled'); } }