From 349e00fbf13cf3fc4aa8028178f1ab85a040d4ea Mon Sep 17 00:00:00 2001 From: Joeli Takala Date: Tue, 17 Dec 2024 17:29:38 +0200 Subject: [PATCH 01/11] Pass the var search results size to JS --- src/view/scripts.inc.twig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/view/scripts.inc.twig b/src/view/scripts.inc.twig index 27c43bcc9..1fda51a7e 100644 --- a/src/view/scripts.inc.twig +++ b/src/view/scripts.inc.twig @@ -47,7 +47,10 @@ window.SKOSMOS = { {%- if request.plugins.callbacks ~%} "pluginCallbacks": [{% for function in request.plugins.callbacks %}{% if not loop.first %}, {% endif %}"{{ function }}"{% endfor %}], {%- endif ~%} - {%- if custom_labels -%} + {%- if GlobalConfig.searchResultsSize ~%} + "searchResultSize": {{ GlobalConfig.searchResultsSize }} + {%- endif ~%} + {% if custom_labels -%} "customLabels": { {%- for k, v in custom_labels -%} {%- set label = v['label'][request.lang] -%} From 78d69d737476fd836245087e46ab5e05630c14a4 Mon Sep 17 00:00:00 2001 From: Joeli Takala Date: Tue, 17 Dec 2024 17:56:23 +0200 Subject: [PATCH 02/11] Added comma --- src/view/scripts.inc.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/view/scripts.inc.twig b/src/view/scripts.inc.twig index 1fda51a7e..e3d22a0b3 100644 --- a/src/view/scripts.inc.twig +++ b/src/view/scripts.inc.twig @@ -48,7 +48,7 @@ window.SKOSMOS = { "pluginCallbacks": [{% for function in request.plugins.callbacks %}{% if not loop.first %}, {% endif %}"{{ function }}"{% endfor %}], {%- endif ~%} {%- if GlobalConfig.searchResultsSize ~%} - "searchResultSize": {{ GlobalConfig.searchResultsSize }} + "searchResultSize": {{ GlobalConfig.searchResultsSize }}, {%- endif ~%} {% if custom_labels -%} "customLabels": { From cdaeb8749f06e04842d957c5590e49bf6fb1f09d Mon Sep 17 00:00:00 2001 From: Joeli Takala Date: Tue, 17 Dec 2024 18:14:29 +0200 Subject: [PATCH 03/11] Scroll bar implementation based on bootstrap --- resource/js/vocab-search.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/resource/js/vocab-search.js b/resource/js/vocab-search.js index e7e6b6528..8c26c0d9b 100644 --- a/resource/js/vocab-search.js +++ b/resource/js/vocab-search.js @@ -11,7 +11,8 @@ const vocabSearch = Vue.createApp({ languageStrings: null, msgs: null, showDropdown: false, - showNotation: null + showNotation: null, + searchResultStyle: null } }, mounted () { @@ -62,6 +63,14 @@ const vocabSearch = Vue.createApp({ if (this.searchTerm.includes('*')) { return this.searchTerm } return this.searchTerm + '*' }, + formatSearchResultStyle () { + const maxResults = window.SKOSMOS.searchResultSize + if (maxResults) { + return this.renderedResultsList.length > maxResults + ? `max-height: ${maxResults * 1.8}rem` // rough length based on searchResultSize variable + : 'max-height: none' + } + }, notationMatches (searchTerm, notation) { if (notation && notation.toLowerCase().includes(searchTerm.toLowerCase())) { return true @@ -168,6 +177,7 @@ const vocabSearch = Vue.createApp({ lang: window.SKOSMOS.lang }) } + this.searchResultStyle = this.formatSearchResultStyle() this.showAutoComplete() }, hideAutoComplete () { @@ -264,8 +274,11 @@ const vocabSearch = Vue.createApp({ @input="autoComplete()" @keyup.enter="gotoSearchPage()" @click="showAutoComplete()"> -