From 34f35e26164592854ccf7eda6a3f320c636c7901 Mon Sep 17 00:00:00 2001 From: gpveronica Date: Tue, 15 Oct 2024 14:49:38 +0200 Subject: [PATCH 01/35] wc - Clean and improve code #TASK-7033 Signed-off-by: gpveronica --- .../commons/opencga-browser-filter.js | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/src/webcomponents/commons/opencga-browser-filter.js b/src/webcomponents/commons/opencga-browser-filter.js index 27d17839b..e956dc2dc 100644 --- a/src/webcomponents/commons/opencga-browser-filter.js +++ b/src/webcomponents/commons/opencga-browser-filter.js @@ -14,7 +14,7 @@ * limitations under the License. */ -import {LitElement, html, nothing} from "lit"; +import {LitElement, html} from "lit"; import UtilsNew from "../../core/utils-new.js"; import LitUtils from "./utils/lit-utils.js"; import "./filters/catalog-search-autocomplete.js"; @@ -34,7 +34,7 @@ export default class OpencgaBrowserFilter extends LitElement { constructor() { super(); - this._init(); + this.#init(); } createRenderRoot() { @@ -67,15 +67,9 @@ export default class OpencgaBrowserFilter extends LitElement { }; } - _init() { + #init() { this._prefix = UtilsNew.randomString(8); - this.annotationFilterConfig = { - class: "small", - buttonClass: "btn-sm", - inputClass: "input-sm" - }; - this.query = {}; this.preparedQuery = {}; this.searchButton = true; @@ -112,12 +106,6 @@ export default class OpencgaBrowserFilter extends LitElement { }; } - connectedCallback() { - super.connectedCallback(); - - this.preparedQuery = {...this.query}; // propagates here the iva-app query object - } - firstUpdated(changedProperties) { super.firstUpdated(changedProperties); @@ -141,17 +129,18 @@ export default class OpencgaBrowserFilter extends LitElement { queryObserver() { this.preparedQuery = this.query || {}; - this.requestUpdate(); } onFilterChange(key, value) { if (value && value !== "") { - this.preparedQuery = {...this.preparedQuery, ...{[key]: value}}; + this.preparedQuery[key] = value; } else { delete this.preparedQuery[key]; - this.preparedQuery = {...this.preparedQuery}; } + this.preparedQuery = {...this.preparedQuery}; this.notifyQuery(this.preparedQuery); + // Note 20241015 Vero: I believe this.requestUpdate() is not needed, but removing it requires further investigation + // (see variant-browser-filter.js, onFilterChange()) this.requestUpdate(); } @@ -163,7 +152,6 @@ export default class OpencgaBrowserFilter extends LitElement { } this.preparedQuery = {...this.preparedQuery}; this.notifyQuery(this.preparedQuery); - this.requestUpdate(); } notifyQuery(query) { @@ -289,7 +277,6 @@ export default class OpencgaBrowserFilter extends LitElement { .opencgaSession="${this.opencgaSession}" .opencgaClient="${this.opencgaSession.opencgaClient}" .resource="${this.resource}" - .config="${this.annotationFilterConfig}" .selectedVariablesText="${this.preparedQuery.annotation}" @annotationChange="${this.onAnnotationChange}"> From 993e947359eaacb44de274578b23729221567971 Mon Sep 17 00:00:00 2001 From: gpveronica Date: Tue, 15 Oct 2024 15:31:37 +0200 Subject: [PATCH 02/35] wc - Fix modal size, #TASK-7033 Signed-off-by: gpveronica --- src/webcomponents/commons/modal/modal-utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/webcomponents/commons/modal/modal-utils.js b/src/webcomponents/commons/modal/modal-utils.js index 191d5c43e..15bc022a3 100644 --- a/src/webcomponents/commons/modal/modal-utils.js +++ b/src/webcomponents/commons/modal/modal-utils.js @@ -38,7 +38,7 @@ export default class ModalUtils { aria-hidden="true" data-cy="${modalCyDataName}" > - - `; + + `; break; case "CATEGORICAL": content = html` - `; +
+ + + +
+ `; break; case "BOOLEAN": content = html` @@ -431,16 +449,31 @@ export default class OpencgaAnnotationFilterModal extends LitElement { ${variable.id}
- + True - + False
- `; + + `; break; default: throw new Error("Type not recognized " + variable.type + "(" + variable.id + ")"); @@ -448,68 +481,60 @@ export default class OpencgaAnnotationFilterModal extends LitElement { return html`${content}`; } - filterChange() { - - } - showModal() { - const annotationModal = new bootstrap.Modal(`#${this._prefix}annotation-modal`); + const annotationModal = new bootstrap.Modal(`#${this._prefix}AnnotationFilterModal`); annotationModal.show(); UtilsNew.initTooltip(this); } - getDefaultConfig() { - return { - - }; - } - - render() { + renderBody() { return html` - ${this.variableSets?.length ? html` - - -