Skip to content

Commit

Permalink
update facets
Browse files Browse the repository at this point in the history
  • Loading branch information
wsalesky committed Dec 4, 2019
1 parent 0cc269e commit 89915bf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion modules/app.xql
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ declare function app:display-facets($node as node(), $model as map(*), $collecti
let $facet-config := global:facet-definition-file($collection)
return
if(not(empty($facet-config))) then
(facet:selected-facets-display($facet-config/descendant::facet:facets/facet:facet-definition), facet:output-html-facets($hits, $facet-config/descendant::facet:facets/facet:facet-definition))
(facet:output-html-facets($hits, $facet-config/descendant::facet:facets/facet:facet-definition))
else ()
};

Expand Down
18 changes: 6 additions & 12 deletions modules/lib/browse.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ declare function browse:show-hits($node as node(), $model as map(*), $collection
data-toggle="collapse" data-target="#filterMap"
href="#filterMap" data-text-swap="+ Show"> - Hide </a></span>
<div class="collapse in" id="filterMap">
{(facet:selected-facets-display($facet-config/descendant::facet:facets/facet:facet-definition),
facet:output-html-facets($hits[descendant::tei:geo], $facet-config/descendant::facet:facets/facet:facet-definition[@name="Type"]))}
{(facet:output-html-facets($hits[descendant::tei:geo], $facet-config/descendant::facet:facets/facet:facet-definition[@name="Type"]))}
</div>
</div>
</div>
Expand All @@ -76,8 +75,7 @@ declare function browse:show-hits($node as node(), $model as map(*), $collection
</div>
<br/>
<div class="row">
<div class="col-md-3">{(facet:selected-facets-display($facet-config/descendant::facet:facets/facet:facet-definition),
facet:output-html-facets($hits, $facet-config/descendant::facet:facets/facet:facet-definition))}</div>
<div class="col-md-3">{(facet:output-html-facets($hits, $facet-config/descendant::facet:facets/facet:facet-definition))}</div>
<div class="col-md-9">
{(
if(($browse:lang = 'syr') or ($browse:lang = 'ar')) then (attribute dir {"rtl"}) else(),
Expand Down Expand Up @@ -244,13 +242,10 @@ declare function browse:by-type($hits, $collection, $sort-options){
{if($browse:view='type') then
if($collection = ('geo','places')) then
browse:browse-type($collection)
else (facet:selected-facets-display($facet-config/descendant::facet:facets/facet:facet-definition),
facet:output-html-facets($hits, $facet-config/descendant::facet:facets/facet:facet-definition[@name="Type"]))
else facet:output-html-facets($hits, $facet-config/descendant::facet:facets/facet:facet-definition[@name="Type"])
else if($browse:view = 'date') then
(facet:selected-facets-display($facet-config/descendant::facet:facets/facet:facet-definition),
facet:output-html-facets($hits, $facet-config/descendant::facet:facets/facet:facet-definition[@name="Century"]))
else (facet:selected-facets-display($facet-config/descendant::facet:facets/facet:facet-definition),
facet:output-html-facets($hits, $facet-config/descendant::facet:facets/facet:facet-definition))
facet:output-html-facets($hits, $facet-config/descendant::facet:facets/facet:facet-definition[@name="Century"])
else facet:output-html-facets($hits, $facet-config/descendant::facet:facets/facet:facet-definition)
}</div>,
<div class="col-md-8" xmlns="http://www.w3.org/1999/xhtml">{
if($browse:view='type') then
Expand Down Expand Up @@ -316,8 +311,7 @@ return
data-toggle="collapse" data-target="#filterMap"
href="#filterMap" data-text-swap="+ Show"> - Hide </a></span>
<div class="collapse in" id="filterMap">
{(facet:selected-facets-display($facet-config/descendant::facet:facets/facet:facet-definition),
facet:output-html-facets($hits, $facet-config/descendant::facet:facets/facet:facet-definition[@name="Type"]))}
{facet:output-html-facets($hits, $facet-config/descendant::facet:facets/facet:facet-definition[@name="Type"])}
</div>
</div>
</div>
Expand Down
19 changes: 13 additions & 6 deletions modules/lib/facet.xqm
Original file line number Diff line number Diff line change
Expand Up @@ -236,14 +236,21 @@ else ()
};

declare function facet:key($label, $value, $count, $facet-definition){
let $facet-query := replace(replace(concat(';fq-',string($facet-definition/@name),':',string($value)),';fq-;fq-;',';fq-'),';fq- ','')
let $new-fq :=
if($facet:fq) then concat('fq=',encode-for-uri($facet:fq),encode-for-uri($facet-query))
else concat('fq=',normalize-space($facet-query))
let $active := if(contains($facet:fq,concat(';fq-',string($facet-definition/@name),':',string($value)))) then 'active' else ()
let $facet-query := concat(string($facet-definition/@name),':',$value)
(:replace(replace(concat(';fq-',string($facet-definition/@name),':',string($value)),';fq-;fq-;',';fq-'),';fq- ',''):)
let $active := if(contains($facet:fq,concat(';fq-',string($facet-definition/@name),':',string($value)))) then 'active' else ()
let $new-fq :=
if($active) then
concat('fq=',
string-join(for $facet-param in tokenize($facet:fq,';fq-')
return
if($facet-param = '' or $facet-param = $facet-query) then ()
else concat(';fq-',$facet-param),''))
else if($facet:fq) then concat('fq=',encode-for-uri($facet:fq),encode-for-uri(concat(';fq-',$facet-query)))
else concat('fq=',encode-for-uri(concat(';fq-',$facet-query)))
return
if($count gt 0) then
<a href="?{$new-fq}{facet:url-params()}" class="facet-label btn btn-default {$active}">{lower-case(global:get-label(string($label)))} <span class="count"> ({string($count)})</span></a>
<a href="?{$new-fq}{facet:url-params()}" class="facet-label btn btn-default {$active}">{if($active) then <span class="glyphicon glyphicon-remove facet-remove"></span> else ()}{global:get-label(string($label))} <span class="count"> ({string($count)})</span> </a>
else ()
};

Expand Down
1 change: 1 addition & 0 deletions resources/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ footer .poweredby img { width: 120px; }
white-space: normal;
}
.facet-label.remove {background-color:#eee; color:#666; font-weight:normal; margin:.25em; display:inline-block;}
.facet-remove {padding-right:6px; margin-right:6px; border-right:1px solid #666; font-weight:normal; color:#666;}

/* G */
.geo-home {margin-top:4em !important;}
Expand Down

0 comments on commit 89915bf

Please sign in to comment.