Skip to content

Commit

Permalink
wc: Refactor render method of section filter component #TASK-7216 #TA…
Browse files Browse the repository at this point in the history
…SK-7100
  • Loading branch information
jmjuanes committed Nov 29, 2024
1 parent c24d7a8 commit a869c63
Showing 1 changed file with 18 additions and 14 deletions.
32 changes: 18 additions & 14 deletions src/webcomponents/commons/forms/section-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ export default class SectionFilter extends LitElement {
static get properties() {
return {
filters: {
type: Array
type: Array,
},
config: {
type: Object
}
type: Object,
},
};
}

Expand All @@ -49,19 +49,23 @@ export default class SectionFilter extends LitElement {
}

render() {
const id = this.config.title.replace(/ /g, "");
return this.config && this.filters?.length > 0 ? html`
<div class="card shadow-sm">
<div class="card-body border-bottom py-2 cursor-pointer" data-bs-toggle="collapse" data-bs-target="#${this._prefix}">
<span class="fw-bold fs-5">${this.config.title}</span>
</div>
<div class="collapse ${this.config.collapsed ? "" : "show"}" id="${this._prefix || ""}">
<div class="card-body">
${this.filters?.map(filter => html`${filter}`)}
if (this.config && this.filters?.length > 0) {
return html`
<div class="card shadow-sm">
<div class="card-body border-bottom py-2 cursor-pointer" data-bs-toggle="collapse" data-bs-target="#${this._prefix}">
<span class="fw-bold fs-5">${this.config.title}</span>
</div>
<div class="collapse ${this.config.collapsed ? "" : "show"}" id="${this._prefix || ""}">
<div class="card-body">
${this.filters?.map(filter => html`${filter}`)}
</div>
</div>
</div>
</div>
` : nothing;
`;
}

// no configuration or filters to display
return nothing;
}

}
Expand Down

0 comments on commit a869c63

Please sign in to comment.