Skip to content

Commit

Permalink
support qid fqs in activeFacetMap
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Collins committed Dec 4, 2023
1 parent bc9de07 commit 2aa3dca
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions grails-app/taglib/au/org/ala/biocache/hubs/OccurrenceTagLib.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ class OccurrenceTagLib {
out << name
}

def paramsHasFilterItem(fq) {
def fqList = params.list('fq')
def idx = fqList.findIndexOf { it == fq}
return idx >= 0
}

/**
* Generate HTML for current filters
*
Expand Down Expand Up @@ -189,13 +195,22 @@ class OccurrenceTagLib {
fqLabel = fqLabel.replaceAll(facetKey, i18nLabel)
}

String hrefValue = currentFilterItemLink(attrs, facetValue)
String hrefValue
String title
String fqHiddenInQidClass
if (paramsHasFilterItem(facetValue)) {
hrefValue = currentFilterItemLink(attrs, facetValue)
title = (attrs.title != null ? "${attrs.title}<br><br>" : "") + alatag.message(code:"title.filter.remove", default:"Click to remove this filter")
} else {
attrs.addCheckBox = false
attrs.addCloseBtn = false
fqHiddenInQidClass = "disabled"
}
String color = attrs.cssColor != null ? "color:${attrs.cssColor}" : ""
String title = (attrs.title != null ? "${attrs.title}<br><br>" : "") + alatag.message(code:"title.filter.remove", default:"Click to remove this filter")

def mb = new MarkupBuilder(out)
mb.a( href: hrefValue,
class: "${attrs.cssClass} tooltips activeFilter",
class: "${attrs.cssClass} tooltips activeFilter ${fqHiddenInQidClass}",
style: color,
title: title
) {
Expand Down Expand Up @@ -247,8 +262,11 @@ class OccurrenceTagLib {
newFqList = []
} else {
def idx = fqList.findIndexOf { it == facet }
newFqList = new ArrayList<>(fqList)
newFqList.remove(idx)
// Some facets are hidden in qids and cannot be removed.
if (idx >= 0) {
newFqList = new ArrayList<>(fqList)
newFqList.remove(idx)
}
}

GrailsParameterMap newParams = params.clone()
Expand Down

0 comments on commit 2aa3dca

Please sign in to comment.