Skip to content

Commit

Permalink
prevent hidden filter values from being displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
litvinovg committed Oct 23, 2024
1 parent 7c7bf91 commit c6cbc04
Showing 1 changed file with 47 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,52 @@
<#assign selectedValue = "" >
<#assign valueNumber = 1>
<#list f.values?values as value>
<#if user.loggedIn || value.publiclyAvailable>
<#if value.selected>
<#assign selectedValue = value.id >
</#if>
<#assign valueLabel = value.name >
<#if !(valueLabel?has_content)>
<#assign valueLabel = value.id >
</#if>
<#if value.selected>
<li id="${value.id?html}" class="li-selected">
<a href="#" class="selected">
<@sl.getInput f value sl.getValueID(f.id, valueNumber) valueNumber 'filter-form' />
<@sl.getSelectedLabel sl.getValueID(filter.id, valueNumber)?html value f getCurrentCount(f value) />
</a>
</li>
<#else>
<li id="${value.id?html}">
<a href="#">
<@sl.getInput f value sl.getValueID(f.id, valueNumber) valueNumber 'filter-form' />
<@sl.getLabel sl.getValueID(f.id, valueNumber) value f getCurrentCount(f value) />
</a>
</li>
</#if>
<#assign valueNumber = valueNumber + 1>
</#if>
</#list>
</#macro>

<#function getCurrentCount f v>
<#if filters[f.id]??>
<#assign filter = filters[f.id]>
<#if filter.values[v.id]??>
<#return filter.values[v.id].count >
<#else>
<#return 0 />
</#if>
<#else>
<#return 0 />
</#if>
</#function>

<#macro filterFacets f>
<#assign selectedValue = "" >
<#assign valueNumber = 1>
<#list f.values?values as value>
<#if user.loggedIn || value.publiclyAvailable>
<#if value.selected>
<#assign selectedValue = value.id >
</#if>
Expand All @@ -79,7 +125,7 @@
<li id="${value.id?html}" class="li-selected">
<a href="#" class="selected">
<@sl.getInput f value sl.getValueID(f.id, valueNumber) valueNumber 'filter-form' />
<@sl.getSelectedLabel sl.getValueID(filter.id, valueNumber)?html value f getCurrentCount(f value) />
<@sl.getSelectedLabel sl.getValueID(f.id, valueNumber)?html value f getCurrentCount(f value) />
</a>
</li>
<#else>
Expand All @@ -91,49 +137,7 @@
</li>
</#if>
<#assign valueNumber = valueNumber + 1>
</#list>
</#macro>

<#function getCurrentCount f v>
<#if filters[f.id]??>
<#assign filter = filters[f.id]>
<#if filter.values[v.id]??>
<#return filter.values[v.id].count >
<#else>
<#return 0 />
</#if>
<#else>
<#return 0 />
</#if>
</#function>

<#macro filterFacets f>
<#assign selectedValue = "" >
<#assign valueNumber = 1>
<#list f.values?values as value>
<#if value.selected>
<#assign selectedValue = value.id >
</#if>
<#assign valueLabel = value.name >
<#if !(valueLabel?has_content)>
<#assign valueLabel = value.id >
</#if>
<#if value.selected>
<li id="${value.id?html}" class="li-selected">
<a href="#" class="selected">
<@sl.getInput f value sl.getValueID(f.id, valueNumber) valueNumber 'filter-form' />
<@sl.getSelectedLabel sl.getValueID(f.id, valueNumber)?html value f getCurrentCount(f value) />
</a>
</li>
<#else>
<li id="${value.id?html}">
<a href="#">
<@sl.getInput f value sl.getValueID(f.id, valueNumber) valueNumber 'filter-form' />
<@sl.getLabel sl.getValueID(f.id, valueNumber) value f getCurrentCount(f value) />
</a>
</li>
</#if>
<#assign valueNumber = valueNumber + 1>
</#list>
</#macro>

Expand Down

0 comments on commit c6cbc04

Please sign in to comment.