From 3a460182bedab19e542cca75840ac7c386c30b0c Mon Sep 17 00:00:00 2001 From: JohannesDoberer Date: Tue, 14 Dec 2021 18:24:34 +0100 Subject: [PATCH] Searchfield configurable (#2385) --- core/src/navigation/GlobalSearch.html | 19 +- core/src/navigation/GlobalSearchCentered.html | 534 ++++++++++++++++++ core/src/navigation/LeftNav.html | 2 +- core/src/navigation/TopNav.html | 41 +- .../helpers/global-search-helpers.js | 12 + core/src/utilities/helpers/index.js | 1 + core/src/utilities/luigi-config-defaults.js | 3 +- docs/navigation-parameters-reference.md | 12 +- plugins/package.json | 2 +- .../tests/0-fiddle/fiddle-navigation.spec.js | 62 +- .../src/luigi-config/extended/globalSearch.js | 5 +- 11 files changed, 669 insertions(+), 24 deletions(-) create mode 100644 core/src/navigation/GlobalSearchCentered.html create mode 100644 core/src/utilities/helpers/global-search-helpers.js diff --git a/core/src/navigation/GlobalSearch.html b/core/src/navigation/GlobalSearch.html index 9433f26cfc..0f036c98e2 100644 --- a/core/src/navigation/GlobalSearch.html +++ b/core/src/navigation/GlobalSearch.html @@ -99,6 +99,7 @@ export let inputElem; export let luigiCustomSearchRenderer__slot; export let luigiCustomSearchItemRenderer__slotContainer; + export let globalSearchConfig; const dispatch = createEventDispatcher(); const searchApiObj = { fireItemSelected: item => { @@ -107,23 +108,34 @@ }; let searchResults = {}; let showPopOverCustomSearch = false; - let search; + let search = {}; let isCustomSearchRenderer; let isCustomSearchResultItemRenderer; + let searchFieldAlwaysVisible; + onMount(async () => { - search = await LuigiConfig.getConfigValueAsync('globalSearch'); + search = globalSearchConfig; let inputElement = inputElem; const placeHolder = getSearchPlaceholder(search.searchProvider); if (placeHolder) { inputElement.placeholder = placeHolder; } + getCustomRenderer(); + }); + + beforeUpdate(() => { + search = globalSearchConfig; + getCustomRenderer(); + }); + + function getCustomRenderer() { isCustomSearchRenderer = GenericHelpers.isFunction( search.searchProvider.customSearchResultRenderer ); isCustomSearchResultItemRenderer = GenericHelpers.isFunction( search.searchProvider.customSearchResultItemRenderer ); - }); + } function getSearchPlaceholder(searchProvider) { if (!searchProvider || !searchProvider.inputPlaceholder) { @@ -338,7 +350,6 @@ } //remove arrow from the search popover - @media screen and (max-width: 1024px) { .luigi-search-shell__mobile { position: relative; diff --git a/core/src/navigation/GlobalSearchCentered.html b/core/src/navigation/GlobalSearchCentered.html new file mode 100644 index 0000000000..5ce086a026 --- /dev/null +++ b/core/src/navigation/GlobalSearchCentered.html @@ -0,0 +1,534 @@ + +
+
+ +
+
+{#if !isSearchFieldVisible} +
+
+ +
+
+{/if} {#if isSearchFieldVisible} +
+ +
+{/if} + + diff --git a/core/src/navigation/LeftNav.html b/core/src/navigation/LeftNav.html index 2b649cf637..df7181b1e7 100644 --- a/core/src/navigation/LeftNav.html +++ b/core/src/navigation/LeftNav.html @@ -1016,7 +1016,7 @@ animation-duration: 0.3s; animation-fill-mode: forwards; .lui-flyout-sublist__title { - background: var(--sapList_Background,#fff); + background: var(--sapList_Background, #fff); } @-webkit-keyframes flyoutAnimation { diff --git a/core/src/navigation/TopNav.html b/core/src/navigation/TopNav.html index 2905b7fb17..eeb9454906 100644 --- a/core/src/navigation/TopNav.html +++ b/core/src/navigation/TopNav.html @@ -22,8 +22,25 @@ on:handleClick="{handleClickExternal}" /> + {#if globalSearchConfig && isGlobalSearchCentered} + + {/if}
- {#if !authorizationEnabled || isLoggedIn} {#if isGlobalSearchAvailable} + {#if !authorizationEnabled || isLoggedIn} {#if globalSearchConfig && + !isGlobalSearchCentered} {/if} - {/if} {#if isGlobalSearchAvailable || (children && pathData.length > 0)} {#if - (children && pathData.length > 0)} {#each children as node, i} {#if !(node.hideFromNav - || (showGlobalNav && node.globalNav))} {#if node.isCat} + {/if} {#if globalSearchConfig || (children && pathData.length > 0)} {#if (children && + pathData.length > 0)} {#each children as node, i} {#if !(node.hideFromNav || + (showGlobalNav && node.globalNav))} {#if node.isCat}
@@ -119,7 +137,7 @@ {#if (visibleNodeCount - globalNavNodeCount > 0) || isProductSwitcherAvailable || - contextSwitcherConfig || isGlobalSearchAvailable } + contextSwitcherConfig || globalSearchConfig }
@@ -150,7 +168,7 @@ >