From 7556730cd40dad3d680ad0e8209c97d725d22045 Mon Sep 17 00:00:00 2001 From: helenasabel Date: Tue, 12 Dec 2023 12:10:17 +0100 Subject: [PATCH 1/4] Facets: considers output when sorting --- modules/facets.xql | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/facets.xql b/modules/facets.xql index 79cd5815..d8f85182 100644 --- a/modules/facets.xql +++ b/modules/facets.xql @@ -23,12 +23,13 @@ import module namespace config="http://www.tei-c.org/tei-simple/config" at "conf declare namespace tei="http://www.tei-c.org/ns/1.0"; -declare function facets:sort($facets as map(*)?) { +declare function facets:sort($config as map(*), $facets as map(*)?) { array { if (exists($facets)) then for $key in map:keys($facets) let $value := map:get($facets, $key) - order by $key ascending + let $sortKey := if (exists($config?output)) then $config?output($key) else $key + order by $sortKey ascending return map { $key: $value } else @@ -48,7 +49,7 @@ declare function facets:print-table($config as map(*), $nodes as element()+, $va if (map:size($facets) > 0) then { - array:for-each(facets:sort($facets), function($entry) { + array:for-each(facets:sort($config, $facets), function($entry) { map:for-each($entry, function($label, $freq) { let $content := if (exists($config?output)) then From 3d0027e6059f52133ee243ed879b426e93b9f903 Mon Sep 17 00:00:00 2001 From: helenasabel Date: Sat, 16 Dec 2023 14:26:48 +0100 Subject: [PATCH 2/4] changes value of text if output has been configured --- modules/lib/api/search.xql | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/lib/api/search.xql b/modules/lib/api/search.xql index 93c94a62..c4559145 100644 --- a/modules/lib/api/search.xql +++ b/modules/lib/api/search.xql @@ -132,12 +132,15 @@ declare function sapi:list-facets($request as map(*)) { let $hits := session:get-attribute($config:session-prefix || ".hits") let $facets := ft:facets($hits, $type, ()) + let $config := for $config in $config:facets?* where $config?dimension eq $type return $config + let $matches := for $key in if (exists($request?parameters?value)) then $request?parameters?value else map:keys($facets) + let $text := if (exists($config?output)) then $config?output($key) else $key return map { - "text": $key, + "text": $text, "freq": $facets($key), "value": $key } From bcc883ec7d01695d915063ea70b71a1cb3c8dfaf Mon Sep 17 00:00:00 2001 From: helenasabel Date: Sat, 16 Dec 2023 14:27:26 +0100 Subject: [PATCH 3/4] adds output to feature facet for testing combobox content --- modules/config.xqm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/config.xqm b/modules/config.xqm index b28884c4..e0816de9 100644 --- a/modules/config.xqm +++ b/modules/config.xqm @@ -158,7 +158,10 @@ declare variable $config:facets := [ "heading": "facets.feature", "source": "api/search/facets/feature", "max": 15, - "hierarchical": false() + "hierarchical": false(), + "output": function($label) { + upper-case(substring($label,1,1)) || substring($label, 2) + } }, map { "dimension": "period", From 8cf025d9e6e7225dfac9c49cc3d753d7de20bf81 Mon Sep 17 00:00:00 2001 From: Wolfgang Meier Date: Sun, 31 Dec 2023 16:53:10 +0100 Subject: [PATCH 4/4] Avoid duplication --- modules/lib/api/search.xql | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/lib/api/search.xql b/modules/lib/api/search.xql index 7fa14431..26055fd5 100644 --- a/modules/lib/api/search.xql +++ b/modules/lib/api/search.xql @@ -132,9 +132,6 @@ declare function sapi:list-facets($request as map(*)) { }) let $hits := session:get-attribute($config:session-prefix || ".hits") let $facets := ft:facets($hits, $type, ()) - let $config := for $config in $config:facets?* where $config?dimension eq $type return $config - - let $matches := for $key in if (exists($request?parameters?value)) then $request?parameters?value else map:keys($facets) let $label := facets:translate($facetConfig, $lang, $key)