From 162e355fdae390387db6a3a4ff077a8d51ab4d7b Mon Sep 17 00:00:00 2001 From: Josemi Date: Tue, 14 Jan 2025 11:32:38 +0100 Subject: [PATCH] wc: Improve displaying advanced filters in drawer #TASK-7216 #TASK-7100 --- .../variant-browser-horizontal-filter.js | 59 ++++++++++++++++--- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/src/webcomponents/variant/variant-browser-horizontal-filter.js b/src/webcomponents/variant/variant-browser-horizontal-filter.js index 692426297..64e24bff1 100644 --- a/src/webcomponents/variant/variant-browser-horizontal-filter.js +++ b/src/webcomponents/variant/variant-browser-horizontal-filter.js @@ -122,6 +122,20 @@ export default class VariantBrowserHorizontalFilter extends LitElement { // this.preparedQuery = {...this.query}; // propagates here the iva-app query object // } + firstUpdated() { + // register listeners to bootstrap collapse events + Array.from(this.querySelectorAll(`[data-bs-role="collapse"]`)).forEach(el => { + el.addEventListener("show.bs.collapse", e => { + e.target.previousElementSibling.querySelector("i").classList.remove("fa-chevron-down"); + e.target.previousElementSibling.querySelector("i").classList.add("fa-chevron-up"); + }); + el.addEventListener("hide.bs.collapse", e => { + e.target.previousElementSibling.querySelector("i").classList.remove("fa-chevron-up"); + e.target.previousElementSibling.querySelector("i").classList.add("fa-chevron-down"); + }); + }); + } + update(changedProperties) { // if (changedProperties.has("opencgaSession")) { // this.opencgaSessionObserver(); @@ -778,16 +792,47 @@ export default class VariantBrowserHorizontalFilter extends LitElement { } renderAdvancedFilters() { - return this.advancedFilters.map(section => { + return this.advancedFilters.map((section, index) => { return html` -
${section.title}
- ${section.filters.map(subsection => this.renderFilter(subsection))} +
+ + ${section.title} +
+
+
+ ${section.filters.map(subsection => this.renderAdvancedFilterSubsection(subsection))} +
+
`; }); } + renderAdvancedFilterSubsection(subsection) { + return html` +
+ ${subsection.title ? html` +
+ ${this._getFilterField(subsection.title)} + ${subsection.tooltip ? html` + + + + ` : nothing} +
+ `: nothing} +
+ ${this._createMessage(subsection)} + ${subsection.description ? html` +
${this._getFilterField(subsection.description)}
+ ` : nothing} + ${this.renderFilter(subsection)} +
+
+ `; + } + render() { const advancedFieldsCount = this.advancedFilters.reduce((count, section) => { const filtersCounts = section.filters.map(filter => { @@ -811,12 +856,12 @@ export default class VariantBrowserHorizontalFilter extends LitElement { ` : nothing} -
-
-
Advanced Filters
+
+
+

Advanced Filters

-
+
${this.renderAdvancedFilters()}