@eeacms/volto-clms-theme 1.1.289 → 1.1.290

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -4,6 +4,16 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ ### [1.1.290](https://github.com/eea/volto-clms-theme/compare/1.1.289...1.1.290) - 21 May 2026
8
+
9
+ #### :rocket: New Features
10
+
11
+ - feat: unify the design of technical library search with global search and dataset catalogue -refs #291483 [ana-oprea - [`8e1c755`](https://github.com/eea/volto-clms-theme/commit/8e1c7555b35fbeb49c3d78a8b47ad65b51b98e33)]
12
+
13
+ #### :hammer_and_wrench: Others
14
+
15
+ - fix icon and jest [ana-oprea - [`2566588`](https://github.com/eea/volto-clms-theme/commit/256658849faedcbfb406edd2d4bad2d1c4a287b7)]
16
+ - fix jest [ana-oprea - [`1c1d529`](https://github.com/eea/volto-clms-theme/commit/1c1d529940cb43bc02afe77686578cc181473a55)]
7
17
  ### [1.1.289](https://github.com/eea/volto-clms-theme/compare/1.1.288...1.1.289) - 21 May 2026
8
18
 
9
19
  #### :hammer_and_wrench: Others
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eeacms/volto-clms-theme",
3
- "version": "1.1.289",
3
+ "version": "1.1.290",
4
4
  "description": "volto-clms-theme: Volto theme for CLMS site",
5
5
  "main": "src/index.js",
6
6
  "author": "CodeSyntax for the European Environment Agency",
@@ -12,6 +12,10 @@ const messages = defineMessages({
12
12
  id: 'Clear filters',
13
13
  defaultMessage: 'Clear filters',
14
14
  },
15
+ applied: {
16
+ id: 'Applied',
17
+ defaultMessage: 'Applied',
18
+ },
15
19
  });
16
20
 
17
21
  const FilterList = (props) => {
@@ -93,7 +97,34 @@ const FilterList = (props) => {
93
97
  .length;
94
98
 
95
99
  const intl = useIntl();
96
- return showFilterList && Object.keys(currentFilters).length ? (
100
+ if (!showFilterList || !Object.keys(currentFilters).length) return null;
101
+
102
+ if (props.variant === 'globalSearch') {
103
+ if (!totalFilters) return null;
104
+
105
+ return (
106
+ <div className="global-search-applied-filters">
107
+ <span>
108
+ {intl.formatMessage(messages.applied)}: {totalFilters}
109
+ </span>
110
+ <Button
111
+ icon
112
+ basic
113
+ compact
114
+ size="small"
115
+ aria-label={intl.formatMessage(messages.clearFilters)}
116
+ onClick={(e) => {
117
+ e.stopPropagation();
118
+ !isEditMode && setFacets({});
119
+ }}
120
+ >
121
+ <Icon name="trash" />
122
+ </Button>
123
+ </div>
124
+ );
125
+ }
126
+
127
+ return (
97
128
  <div className="accordion ui filter-listing">
98
129
  <div
99
130
  className="filter-list-header"
@@ -118,7 +149,7 @@ const FilterList = (props) => {
118
149
  </Button>
119
150
  </div>
120
151
  </div>
121
- ) : null;
152
+ );
122
153
  };
123
154
 
124
155
  export default FilterList;
@@ -12,6 +12,7 @@ import { Icon } from '@plone/volto/components';
12
12
  import React from 'react';
13
13
  import filterSVG from '@plone/volto/icons/filter.svg';
14
14
  import { flushSync } from 'react-dom';
15
+ import { usesGlobalSearchDesign } from './searchDesign';
15
16
 
16
17
  const messages = defineMessages({
17
18
  searchButtonText: {
@@ -26,6 +27,76 @@ const FacetWrapper = ({ children }) => (
26
27
  </Segment>
27
28
  );
28
29
 
30
+ const getSortLabel = (value, querystring) => {
31
+ const title = querystring?.sortable_indexes?.[value]?.title || value;
32
+ if (
33
+ ['effective', 'publication_date', 'modified'].includes(value) ||
34
+ /publication date/i.test(title)
35
+ ) {
36
+ return 'Time';
37
+ }
38
+ if (value === 'sortable_title') {
39
+ return 'Title';
40
+ }
41
+ if (value === 'relevance') {
42
+ return 'Relevance';
43
+ }
44
+ return title?.replace(/^Sort by /, '') || value;
45
+ };
46
+
47
+ const GlobalSortOn = ({
48
+ data,
49
+ querystring,
50
+ isEditMode,
51
+ sortOn,
52
+ sortOrder,
53
+ onChange,
54
+ }) => {
55
+ const configuredOptions = data.sortOnOptions || [];
56
+ const concreteOptions = configuredOptions.filter(
57
+ (option) => !['SearchableText', 'relevance'].includes(option),
58
+ );
59
+ const options = ['relevance', ...concreteOptions];
60
+ const activeSortOn = sortOn && options.includes(sortOn) ? sortOn : options[0];
61
+
62
+ if (!options.length) return null;
63
+
64
+ return (
65
+ <div className="sorting global-search-sorting">
66
+ <span className="global-search-sort-label">Sort by:</span>
67
+ {options.map((option) => {
68
+ const isActive = activeSortOn === option;
69
+ return (
70
+ <button
71
+ key={option}
72
+ type="button"
73
+ className={isActive ? 'active' : ''}
74
+ onClick={() => {
75
+ if (isEditMode) return;
76
+ if (option === 'relevance') {
77
+ onChange(null, null);
78
+ return;
79
+ }
80
+ const nextOrder =
81
+ isActive && sortOrder === 'ascending'
82
+ ? 'descending'
83
+ : 'ascending';
84
+ onChange(option, nextOrder);
85
+ }}
86
+ >
87
+ {getSortLabel(option, querystring)}
88
+ {isActive && option !== 'relevance' && (
89
+ <span className="global-search-sort-direction">
90
+ {sortOrder === 'descending' ? '▼' : '▲'}
91
+ </span>
92
+ )}
93
+ </button>
94
+ );
95
+ })}
96
+ </div>
97
+ );
98
+ };
99
+
29
100
  function setFacetsHandler(setFacets, onTriggerSearch, searchedText) {
30
101
  return (f) => {
31
102
  flushSync(() => {
@@ -57,6 +128,7 @@ const RightModalFacets = (props) => {
57
128
  } = props;
58
129
  const { showSearchButton } = data;
59
130
  const isLive = !showSearchButton;
131
+ const hasGlobalSearchDesign = usesGlobalSearchDesign(props);
60
132
  const intl = useIntl();
61
133
  // Should we generalize this to an external function?
62
134
  if (querystring?.sortable_indexes?.effective?.title) {
@@ -75,8 +147,64 @@ const RightModalFacets = (props) => {
75
147
  querystring.sortable_indexes.version.title = 'Version';
76
148
  }
77
149
 
150
+ const updateFacets = setFacetsHandler(
151
+ setFacets,
152
+ onTriggerSearch,
153
+ searchedText,
154
+ );
155
+
156
+ const facetsModal = data.facets?.length ? (
157
+ <CclFiltersModal
158
+ trigger={
159
+ <div className="filters-element">
160
+ <div className="filters-title">
161
+ {hasGlobalSearchDesign ? (
162
+ <span
163
+ className="global-search-categories-icon"
164
+ aria-hidden="true"
165
+ >
166
+ <Icon
167
+ className="global-search-categories-filter-icon"
168
+ name={filterSVG}
169
+ size="10px"
170
+ color="#fff"
171
+ />
172
+ </span>
173
+ ) : (
174
+ <Icon className="ui" name={filterSVG} size={'20'} />
175
+ )}
176
+ <span className="filters-title-bold">
177
+ {hasGlobalSearchDesign ? 'Show Categories' : data.facetsTitle}
178
+ </span>
179
+ </div>
180
+ </div>
181
+ }
182
+ data={data}
183
+ setFacets={updateFacets}
184
+ >
185
+ <div id="right-modal-facets" className="facets">
186
+ <Facets
187
+ querystring={querystring}
188
+ data={data}
189
+ facets={facets}
190
+ isEditMode={isEditMode}
191
+ setFacets={updateFacets}
192
+ facetWrapper={FacetWrapper}
193
+ />
194
+ </div>
195
+ </CclFiltersModal>
196
+ ) : null;
197
+
78
198
  return (
79
- <Grid className="searchBlock-facets right-column-facets" stackable>
199
+ <Grid
200
+ className={[
201
+ 'searchBlock-facets right-column-facets',
202
+ hasGlobalSearchDesign ? 'global-search-facets' : '',
203
+ ]
204
+ .filter(Boolean)
205
+ .join(' ')}
206
+ stackable
207
+ >
80
208
  {data?.headline && (
81
209
  <Grid.Row>
82
210
  <Grid.Column>
@@ -91,21 +219,29 @@ const RightModalFacets = (props) => {
91
219
  ? data.showSearchInput
92
220
  : true) && (
93
221
  <>
94
- <div className="search-wrapper">
95
- <SearchInput {...props} isLive={isLive} />
96
- {data.showSearchButton && (
97
- <Button
98
- primary
99
- onClick={() => onTriggerSearch(searchText)}
100
- aria-label={
101
- data.searchButtonLabel ||
102
- intl.formatMessage(messages.searchButtonText)
103
- }
104
- >
105
- <span className="ccl-icon-zoom"></span>
106
- </Button>
107
- )}
108
- </div>
222
+ {hasGlobalSearchDesign ? (
223
+ <SearchInput
224
+ {...props}
225
+ isLive={isLive}
226
+ useSearchlibSearchDesign={hasGlobalSearchDesign}
227
+ />
228
+ ) : (
229
+ <div className="search-wrapper">
230
+ <SearchInput {...props} isLive={isLive} />
231
+ {data.showSearchButton && (
232
+ <Button
233
+ primary
234
+ onClick={() => onTriggerSearch(searchText)}
235
+ aria-label={
236
+ data.searchButtonLabel ||
237
+ intl.formatMessage(messages.searchButtonText)
238
+ }
239
+ >
240
+ <span className="ccl-icon-zoom"></span>
241
+ </Button>
242
+ )}
243
+ </div>
244
+ )}
109
245
  <div className="search-box-hint">
110
246
  <p>
111
247
  Hint: you can use double quotes to search for exact phrases.
@@ -115,84 +251,92 @@ const RightModalFacets = (props) => {
115
251
  </>
116
252
  )}
117
253
 
118
- <div>
119
- <FilterList
120
- {...props}
121
- isEditMode={isEditMode}
122
- setFacets={setFacetsHandler(
123
- setFacets,
124
- onTriggerSearch,
125
- searchedText,
126
- )}
127
- />
128
- </div>
129
-
130
- <div className="search-results-count-sort search-filters">
131
- <SearchDetails total={totalItems} data={data} />
132
- <div className="filters-container">
133
- {data.showSortOn && (
134
- <SortOn
135
- data={data}
136
- querystring={querystring}
254
+ {hasGlobalSearchDesign ? (
255
+ <>
256
+ <div className="global-search-count">
257
+ <SearchDetails total={totalItems} data={data} as="div" />
258
+ </div>
259
+ <div className="above-results global-search-above-results">
260
+ <div className="global-search-filters-left">
261
+ {facetsModal}
262
+ <FilterList
263
+ {...props}
264
+ variant="globalSearch"
265
+ isEditMode={isEditMode}
266
+ setFacets={updateFacets}
267
+ />
268
+ </div>
269
+ {data.showSortOn && (
270
+ <GlobalSortOn
271
+ data={data}
272
+ querystring={querystring}
273
+ isEditMode={isEditMode}
274
+ sortOrder={sortOrder}
275
+ sortOn={sortOn}
276
+ onChange={(sortOnParam, sortOrderParam) => {
277
+ flushSync(() => {
278
+ setSortOn(sortOnParam || undefined);
279
+ setSortOrder(sortOrderParam || undefined);
280
+ onTriggerSearch(
281
+ searchedText || '',
282
+ facets,
283
+ sortOnParam,
284
+ sortOrderParam,
285
+ );
286
+ });
287
+ }}
288
+ />
289
+ )}
290
+ </div>
291
+ </>
292
+ ) : (
293
+ <>
294
+ <div>
295
+ <FilterList
296
+ {...props}
137
297
  isEditMode={isEditMode}
138
- sortOrder={sortOrder}
139
- sortOn={sortOn}
140
- setSortOn={(sortOnParam) => {
141
- flushSync(() => {
142
- setSortOn(sortOnParam);
143
- onTriggerSearch(searchedText || '', facets, sortOnParam);
144
- });
145
- }}
146
- setSortOrder={(sortOrderParam) => {
147
- flushSync(() => {
148
- setSortOrder(sortOrderParam);
149
- onTriggerSearch(
150
- searchedText || '',
151
- facets,
152
- sortOn,
153
- sortOrderParam,
154
- );
155
- });
156
- }}
298
+ setFacets={updateFacets}
157
299
  />
158
- )}
159
- {data.facets?.length && (
160
- <CclFiltersModal
161
- trigger={
162
- <div className="filters-element">
163
- <div className="filters-title">
164
- <Icon className="ui" name={filterSVG} size={'20'} />
165
- <span className="filters-title-bold">
166
- {data.facetsTitle}
167
- </span>
168
- </div>
169
- </div>
170
- }
171
- data={data}
172
- setFacets={setFacetsHandler(
173
- setFacets,
174
- onTriggerSearch,
175
- searchedText,
176
- )}
177
- >
178
- <div id="right-modal-facets" className="facets">
179
- <Facets
180
- querystring={querystring}
300
+ </div>
301
+
302
+ <div className="search-results-count-sort search-filters">
303
+ <SearchDetails total={totalItems} data={data} />
304
+ <div className="filters-container">
305
+ {data.showSortOn && (
306
+ <SortOn
181
307
  data={data}
182
- facets={facets}
308
+ querystring={querystring}
183
309
  isEditMode={isEditMode}
184
- setFacets={setFacetsHandler(
185
- setFacets,
186
- onTriggerSearch,
187
- searchedText,
188
- )}
189
- facetWrapper={FacetWrapper}
310
+ sortOrder={sortOrder}
311
+ sortOn={sortOn}
312
+ setSortOn={(sortOnParam) => {
313
+ flushSync(() => {
314
+ setSortOn(sortOnParam);
315
+ onTriggerSearch(
316
+ searchedText || '',
317
+ facets,
318
+ sortOnParam,
319
+ );
320
+ });
321
+ }}
322
+ setSortOrder={(sortOrderParam) => {
323
+ flushSync(() => {
324
+ setSortOrder(sortOrderParam);
325
+ onTriggerSearch(
326
+ searchedText || '',
327
+ facets,
328
+ sortOn,
329
+ sortOrderParam,
330
+ );
331
+ });
332
+ }}
190
333
  />
191
- </div>
192
- </CclFiltersModal>
193
- )}
194
- </div>
195
- </div>
334
+ )}
335
+ {facetsModal}
336
+ </div>
337
+ </div>
338
+ </>
339
+ )}
196
340
  {children}
197
341
  </Grid.Column>
198
342
  </Grid.Row>
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
- import { Button, Input } from 'semantic-ui-react';
2
+ import { Button, Icon as SemanticIcon, Input } from 'semantic-ui-react';
3
3
  import { defineMessages, useIntl } from 'react-intl';
4
- import { Icon } from '@plone/volto/components';
4
+ import { Icon as VoltoIcon } from '@plone/volto/components';
5
5
  import clearSVG from '@plone/volto/icons/clear.svg';
6
+ import searchSVG from './icons/search.svg';
6
7
 
7
8
  const messages = defineMessages({
8
9
  search: {
@@ -12,8 +13,86 @@ const messages = defineMessages({
12
13
  });
13
14
 
14
15
  const SearchInput = (props) => {
15
- const { data, searchText, setSearchText, isLive, onTriggerSearch } = props;
16
+ const {
17
+ data,
18
+ searchText,
19
+ setSearchText,
20
+ isLive,
21
+ isGlobalSearch,
22
+ useSearchlibSearchDesign = isGlobalSearch,
23
+ onTriggerSearch,
24
+ } = props;
16
25
  const intl = useIntl();
26
+ const placeholder =
27
+ data.searchInputPrompt || intl.formatMessage(messages.search);
28
+
29
+ if (useSearchlibSearchDesign) {
30
+ return (
31
+ <div className="sui-search-box">
32
+ <div className="search-input">
33
+ <div className="terms-box">
34
+ <input
35
+ maxLength="200"
36
+ id={`${props.id}-searchtext`}
37
+ value={searchText}
38
+ className=""
39
+ placeholder={placeholder}
40
+ enterKeyHint="search"
41
+ onKeyDown={(event) => {
42
+ if (event.key === 'Enter') {
43
+ onTriggerSearch(searchText);
44
+ }
45
+ }}
46
+ onChange={(event) => {
47
+ setSearchText(event.target.value);
48
+ if (isLive) {
49
+ onTriggerSearch(event.target.value);
50
+ }
51
+ }}
52
+ />
53
+
54
+ <div className="terms-box-left">
55
+ <div className="input-controls">
56
+ {searchText && (
57
+ <div className="ui button basic clear-button">
58
+ <SemanticIcon
59
+ tabIndex={0}
60
+ name="close"
61
+ role="button"
62
+ onClick={() => {
63
+ setSearchText('');
64
+ onTriggerSearch('');
65
+ }}
66
+ onKeyDown={(event) => {
67
+ if (event.key === 'Enter') {
68
+ setSearchText('');
69
+ onTriggerSearch('');
70
+ }
71
+ }}
72
+ />
73
+ </div>
74
+ )}
75
+ </div>
76
+
77
+ <div
78
+ tabIndex={0}
79
+ role="button"
80
+ className="search-icon"
81
+ onClick={() => onTriggerSearch(searchText)}
82
+ onKeyDown={(event) => {
83
+ if (event.key === 'Enter') {
84
+ onTriggerSearch(searchText);
85
+ }
86
+ }}
87
+ >
88
+ <VoltoIcon name={searchSVG} size="29px" />
89
+ </div>
90
+ </div>
91
+ </div>
92
+ </div>
93
+ </div>
94
+ );
95
+ }
17
96
 
18
97
  return (
19
98
  <div className="search-input">
@@ -21,9 +100,7 @@ const SearchInput = (props) => {
21
100
  maxLength="200"
22
101
  id={`${props.id}-searchtext`}
23
102
  value={searchText}
24
- placeholder={
25
- data.searchInputPrompt || intl.formatMessage(messages.search)
26
- }
103
+ placeholder={placeholder}
27
104
  fluid
28
105
  onKeyPress={(event) => {
29
106
  if (isLive || event.key === 'Enter') onTriggerSearch(searchText);
@@ -46,7 +123,7 @@ const SearchInput = (props) => {
46
123
  onTriggerSearch('');
47
124
  }}
48
125
  >
49
- <Icon name={clearSVG}></Icon>
126
+ <VoltoIcon name={clearSVG}></VoltoIcon>
50
127
  </Button>
51
128
  )}
52
129
  </div>
@@ -0,0 +1,3 @@
1
+ <svg width="38" height="38" viewBox="0 0 38 38" xmlns="http://www.w3.org/2000/svg">
2
+ <path d="M37.3757 34.3789L30.2003 27.2246C32.5154 24.2751 33.7716 20.633 33.7669 16.8835C33.7669 13.5442 32.7767 10.28 30.9215 7.50351C29.0663 4.72705 26.4295 2.56305 23.3445 1.28518C20.2594 0.00731515 16.8647 -0.327033 13.5897 0.324418C10.3146 0.97587 7.30625 2.58386 4.94506 4.94506C2.58386 7.30625 0.97587 10.3146 0.324418 13.5897C-0.327033 16.8647 0.00731528 20.2594 1.28518 23.3445C2.56305 26.4295 4.72705 29.0664 7.50351 30.9215C10.28 32.7767 13.5442 33.7669 16.8835 33.7669C20.633 33.7716 24.2751 32.5154 27.2246 30.2003L34.3789 37.3757C34.5751 37.5735 34.8085 37.7306 35.0657 37.8377C35.3229 37.9448 35.5987 38 35.8773 38C36.1559 38 36.4318 37.9448 36.689 37.8377C36.9461 37.7306 37.1795 37.5735 37.3757 37.3757C37.5735 37.1795 37.7305 36.9461 37.8377 36.689C37.9448 36.4318 38 36.1559 38 35.8773C38 35.5987 37.9448 35.3229 37.8377 35.0657C37.7305 34.8085 37.5735 34.5751 37.3757 34.3789ZM4.22087 16.8835C4.22087 14.379 4.96352 11.9309 6.3549 9.8485C7.74628 7.76615 9.72391 6.14315 12.0377 5.18475C14.3515 4.22635 16.8975 3.97559 19.3538 4.46418C21.8101 4.95277 24.0664 6.15876 25.8373 7.92966C27.6081 9.70055 28.8141 11.9568 29.3027 14.4131C29.7913 16.8694 29.5406 19.4154 28.5822 21.7292C27.6238 24.043 26.0008 26.0206 23.9184 27.412C21.8361 28.8034 19.3879 29.546 16.8835 29.546C13.5251 29.546 10.3043 28.2119 7.92966 25.8373C5.55496 23.4626 4.22087 20.2418 4.22087 16.8835Z" />
3
+ </svg>
@@ -0,0 +1,8 @@
1
+ export const usesGlobalSearchDesign = ({ data, location, path }) => {
2
+ const currentPath = location?.pathname || path || '';
3
+ const normalizedPath = currentPath.replace(/\/$/, '');
4
+ return (
5
+ data?.listingBodyTemplate === 'CclGlobalSearch' ||
6
+ normalizedPath.endsWith('/dataset-catalog')
7
+ );
8
+ };
@@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
2
2
  import { FormattedMessage } from 'react-intl';
3
3
  import { useSelector } from 'react-redux';
4
4
  import { Link } from 'react-router-dom';
5
- import { Icon, Label } from 'semantic-ui-react';
5
+ import { Icon } from 'semantic-ui-react';
6
6
 
7
7
  import { flattenToAppURL } from '@plone/volto/helpers/Url/Url';
8
8
  import { UniversalLink, Icon as VoltoIcon } from '@plone/volto/components';
@@ -59,7 +59,7 @@ const CardLink = ({ url, children, className, condition = true }) => {
59
59
  );
60
60
  };
61
61
 
62
- const DocCard = ({ card, url, showEditor, children }) => {
62
+ const DocCard = ({ card, url, showEditor, hideSize = false, children }) => {
63
63
  return (
64
64
  <>
65
65
  <div className="card-doc-header">
@@ -104,7 +104,7 @@ const DocCard = ({ card, url, showEditor, children }) => {
104
104
  </Link>
105
105
  )}
106
106
  </div>
107
- {card?.['@type'] === 'TechnicalLibrary' && (
107
+ {card?.['@type'] === 'TechnicalLibrary' && !hideSize && (
108
108
  <div className="card-doc-size">{card.getObjSize || ''}</div>
109
109
  )}
110
110
  </div>
@@ -317,16 +317,30 @@ function CclCard(props) {
317
317
  </>
318
318
  )}
319
319
  {type === 'globalSearch' && (
320
- <>
321
- <Label ribbon="right" color="olive">
322
- {content_type}
323
- </Label>
324
- <DocCard card={card} url={url} showEditor={showEditor}>
325
- {children}
320
+ <div className="global-search-result-row">
321
+ <div className="global-search-result-main">
322
+ <DocCard
323
+ card={card}
324
+ url={url}
325
+ showEditor={showEditor}
326
+ hideSize
327
+ >
328
+ {children}
326
329
 
327
- <SearchResultExtras content={card} />
328
- </DocCard>
329
- </>
330
+ <SearchResultExtras content={card} />
331
+ </DocCard>
332
+ </div>
333
+ <div className="global-search-result-side">
334
+ <span className="global-search-result-type">
335
+ {content_type}
336
+ </span>
337
+ {card?.['@type'] === 'TechnicalLibrary' && (
338
+ <span className="global-search-result-size">
339
+ {card.getObjSize || ''}
340
+ </span>
341
+ )}
342
+ </div>
343
+ </div>
330
344
  )}
331
345
  {(type === 'block' || type === 'threeColumns') && (
332
346
  <>
@@ -1,9 +1,10 @@
1
1
  import React from 'react';
2
2
 
3
3
  import ListingBody from '@plone/volto/components/manage/Blocks/Listing/ListingBody';
4
- import { withBlockExtensions } from '@plone/volto/helpers';
4
+ import { BodyClass, withBlockExtensions } from '@plone/volto/helpers';
5
5
 
6
6
  import config from '@plone/volto/registry';
7
+ import { usesGlobalSearchDesign } from '@eeacms/volto-clms-theme/components/Blocks/CustomTemplates/VoltoSearchBlock/searchDesign';
7
8
 
8
9
  import {
9
10
  withSearch,
@@ -63,7 +64,12 @@ const applyDefaults = (data, root) => {
63
64
  };
64
65
 
65
66
  const SearchBlockView = (props) => {
66
- const { data, searchData, mode = 'view', variation } = props;
67
+ const { data, searchData, mode = 'view', variation, location, path } = props;
68
+ const hasGlobalSearchDesign = usesGlobalSearchDesign({
69
+ data,
70
+ location,
71
+ path,
72
+ });
67
73
 
68
74
  const Layout = variation.view;
69
75
 
@@ -86,8 +92,17 @@ const SearchBlockView = (props) => {
86
92
  const { variations } = config.blocks.blocksConfig.listing;
87
93
  const listingBodyVariation = variations.find(({ id }) => id === selectedView);
88
94
 
89
- return (
90
- <div className="block search">
95
+ const searchBlock = (
96
+ <div
97
+ className={[
98
+ 'block search',
99
+ hasGlobalSearchDesign
100
+ ? 'global-search-block searchlib-block searchapp searchapp-clmsSearchTechnicalLibrary'
101
+ : '',
102
+ ]
103
+ .filter(Boolean)
104
+ .join(' ')}
105
+ >
91
106
  <Layout
92
107
  {...props}
93
108
  isEditMode={mode === 'edit'}
@@ -103,6 +118,14 @@ const SearchBlockView = (props) => {
103
118
  </Layout>
104
119
  </div>
105
120
  );
121
+
122
+ return hasGlobalSearchDesign ? (
123
+ <BodyClass className="global-search-page searchlib-page">
124
+ {searchBlock}
125
+ </BodyClass>
126
+ ) : (
127
+ searchBlock
128
+ );
106
129
  };
107
130
 
108
131
  export const SearchBlockViewComponent = compose(
@@ -35,6 +35,7 @@ function getInitialState(
35
35
  id,
36
36
  sortOnParam,
37
37
  sortOrderParam,
38
+ useDefaultSort = true,
38
39
  ) {
39
40
  const {
40
41
  types: facetWidgetTypes,
@@ -69,8 +70,18 @@ function getInitialState(
69
70
  ]
70
71
  : []),
71
72
  ],
72
- sort_on: sortOnParam || data.query?.sort_on,
73
- sort_order: sortOrderParam || data.query?.sort_order,
73
+ sort_on:
74
+ sortOnParam !== undefined
75
+ ? sortOnParam
76
+ : useDefaultSort
77
+ ? data.query?.sort_on
78
+ : undefined,
79
+ sort_order:
80
+ sortOrderParam !== undefined
81
+ ? sortOrderParam
82
+ : useDefaultSort
83
+ ? data.query?.sort_order
84
+ : undefined,
74
85
  b_size: data.query?.b_size,
75
86
  limit: data.query?.limit,
76
87
  block: id,
@@ -92,6 +103,7 @@ function normalizeState({
92
103
  sortOn,
93
104
  sortOrder,
94
105
  facetSettings, // data.facets extracted from block data
106
+ useDefaultSort = true,
95
107
  }) {
96
108
  const {
97
109
  types: facetWidgetTypes,
@@ -115,8 +127,18 @@ function normalizeState({
115
127
  return valueToQuery({ value, facet });
116
128
  }),
117
129
  ].filter((o) => !!o),
118
- sort_on: sortOn || query.sort_on,
119
- sort_order: sortOrder || query.sort_order,
130
+ sort_on:
131
+ sortOn !== undefined
132
+ ? sortOn
133
+ : useDefaultSort
134
+ ? query.sort_on
135
+ : undefined,
136
+ sort_order:
137
+ sortOrder !== undefined
138
+ ? sortOrder
139
+ : useDefaultSort
140
+ ? query.sort_order
141
+ : undefined,
120
142
  b_size: query.b_size,
121
143
  limit: query.limit,
122
144
  block: id,
@@ -196,6 +218,13 @@ const useHashState = () => {
196
218
  }
197
219
  });
198
220
 
221
+ SEARCH_ENDPOINT_FIELDS.forEach((k) => {
222
+ if (!searchData[k] && oldState[k]) {
223
+ delete newParams[k];
224
+ changed = true;
225
+ }
226
+ });
227
+
199
228
  if (changed) {
200
229
  history.push({
201
230
  search: qs.stringify(newParams),
@@ -240,6 +269,7 @@ const withSearch = (options) => (WrappedComponent) => {
240
269
 
241
270
  function WithSearch(props) {
242
271
  const { data, id, editable = false } = props;
272
+ const isGlobalSearch = data?.listingBodyTemplate === 'CclGlobalSearch';
243
273
 
244
274
  const [locationSearchData, setLocationSearchData] = useSearchBlockState(
245
275
  id,
@@ -323,11 +353,25 @@ const withSearch = (options) => (WrappedComponent) => {
323
353
  previousUrlQuery,
324
354
  ]);
325
355
 
326
- const [sortOn, setSortOn] = React.useState(data?.query?.sort_on);
327
- const [sortOrder, setSortOrder] = React.useState(data?.query?.sort_order);
356
+ const [sortOn, setSortOn] = React.useState(
357
+ locationSearchData.sort_on ||
358
+ (isGlobalSearch ? undefined : data?.query?.sort_on),
359
+ );
360
+ const [sortOrder, setSortOrder] = React.useState(
361
+ locationSearchData.sort_order ||
362
+ (isGlobalSearch ? undefined : data?.query?.sort_order),
363
+ );
328
364
 
329
365
  const [searchData, setSearchData] = React.useState(
330
- getInitialState(data, facets, urlSearchText, id),
366
+ getInitialState(
367
+ data,
368
+ facets,
369
+ urlSearchText,
370
+ id,
371
+ sortOn,
372
+ sortOrder,
373
+ !isGlobalSearch,
374
+ ),
331
375
  );
332
376
 
333
377
  const deepFacets = JSON.stringify(facets);
@@ -341,9 +385,18 @@ const withSearch = (options) => (WrappedComponent) => {
341
385
  id,
342
386
  sortOn,
343
387
  sortOrder,
388
+ !isGlobalSearch,
344
389
  ),
345
390
  );
346
- }, [deepData, deepFacets, urlSearchText, id, sortOn, sortOrder]);
391
+ }, [
392
+ deepData,
393
+ deepFacets,
394
+ urlSearchText,
395
+ id,
396
+ sortOn,
397
+ sortOrder,
398
+ isGlobalSearch,
399
+ ]);
347
400
 
348
401
  const timeoutRef = React.useRef();
349
402
  const facetSettings = data?.facets;
@@ -359,18 +412,32 @@ const withSearch = (options) => (WrappedComponent) => {
359
412
  if (timeoutRef.current) clearTimeout(timeoutRef.current);
360
413
  timeoutRef.current = setTimeout(
361
414
  () => {
415
+ const shouldClearSort = toSortOn === null;
416
+ const hasSortOnParam = toSortOn !== undefined;
417
+ const nextSortOn = shouldClearSort
418
+ ? undefined
419
+ : hasSortOnParam
420
+ ? toSortOn
421
+ : sortOn;
422
+ const nextSortOrder = shouldClearSort
423
+ ? undefined
424
+ : toSortOrder !== undefined
425
+ ? toSortOrder
426
+ : sortOrder;
362
427
  const newSearchData = normalizeState({
363
428
  id,
364
429
  query: data.query || {},
365
430
  facets: toSearchFacets || facets,
366
431
  searchText: toSearchText ? toSearchText.trim() : '',
367
- sortOn: toSortOn || sortOn,
368
- sortOrder: toSortOrder || sortOrder,
432
+ sortOn: nextSortOn,
433
+ sortOrder: nextSortOrder,
369
434
  facetSettings,
435
+ useDefaultSort: !isGlobalSearch,
370
436
  });
371
437
  if (toSearchFacets) setFacets(toSearchFacets);
372
- if (toSortOn) setSortOn(toSortOn);
373
- if (toSortOrder) setSortOrder(toSortOrder);
438
+ if (hasSortOnParam) setSortOn(toSortOn || undefined);
439
+ if (toSortOrder !== undefined)
440
+ setSortOrder(toSortOrder || undefined);
374
441
  setSearchData(newSearchData);
375
442
  setLocationSearchData(getSearchFields(newSearchData));
376
443
  },
@@ -388,6 +455,7 @@ const withSearch = (options) => (WrappedComponent) => {
388
455
  sortOn,
389
456
  sortOrder,
390
457
  facetSettings,
458
+ isGlobalSearch,
391
459
  ],
392
460
  );
393
461
 
@@ -289,6 +289,463 @@
289
289
  font-size: 0.8rem;
290
290
  }
291
291
 
292
+ body.global-search-page h1.documentFirstHeading {
293
+ padding-bottom: 1rem;
294
+ border-bottom: 1px solid @clmsGreen;
295
+ margin-bottom: 0.7rem;
296
+ color: #273b4b;
297
+ font-size: 32px;
298
+ line-height: 1.15;
299
+ }
300
+
301
+ body.global-search-page .block.search.global-search-block {
302
+ margin-top: 0;
303
+ }
304
+
305
+ body.global-search-page.section-global-search #page-document > p {
306
+ margin-bottom: 0;
307
+ line-height: 1.35;
308
+ }
309
+
310
+ body.global-search-page.section-global-search #page-document > p strong:empty {
311
+ display: none;
312
+ }
313
+
314
+ body.global-search-page.section-global-search
315
+ #page-document
316
+ > p:has(strong:empty) {
317
+ display: none;
318
+ }
319
+
320
+ body.global-search-page.section-global-search
321
+ .block.search.global-search-block {
322
+ margin-top: 3rem;
323
+ }
324
+
325
+ body.global-search-page.section-dataset-catalog
326
+ .block.search.global-search-block {
327
+ margin-top: 1.5rem;
328
+ }
329
+
330
+ body.global-search-page .block.search.global-search-block .ui.grid {
331
+ margin: 0;
332
+ }
333
+
334
+ body.global-search-page .block.search.global-search-block .ui.grid > .row {
335
+ padding-top: 0;
336
+ }
337
+
338
+ body.global-search-page
339
+ .block.search.global-search-block
340
+ .ui.grid
341
+ > .row
342
+ > .column {
343
+ padding-right: 0;
344
+ padding-left: 0;
345
+ }
346
+
347
+ body.global-search-page .block.search.global-search-block .sui-search-box {
348
+ margin: 0 0 0.6rem;
349
+ }
350
+
351
+ body.global-search-page .block.search.global-search-block .search-box-hint p {
352
+ margin: 0;
353
+ color: #273b4b;
354
+ font-size: 0.75rem;
355
+ }
356
+
357
+ body.global-search-page .block.search.global-search-block .global-search-count {
358
+ padding-bottom: 0.5rem;
359
+ border-bottom: 2px solid fade(#273b4b, 20%);
360
+ margin-top: 1.75rem;
361
+ }
362
+
363
+ body.global-search-page
364
+ .block.search.global-search-block
365
+ .global-search-count
366
+ .search-details {
367
+ margin: 0;
368
+ color: #273b4b;
369
+ font-size: 0.95rem;
370
+ font-weight: 700;
371
+ }
372
+
373
+ body.global-search-page
374
+ .block.search.global-search-block
375
+ .global-search-above-results {
376
+ display: flex;
377
+ align-items: center;
378
+ justify-content: space-between;
379
+ padding: 0.55rem 0 1.4rem;
380
+ margin: 0;
381
+ }
382
+
383
+ body.global-search-page
384
+ .block.search.global-search-block
385
+ .global-search-filters-left,
386
+ body.global-search-page
387
+ .block.search.global-search-block
388
+ .global-search-applied-filters,
389
+ body.global-search-page
390
+ .block.search.global-search-block
391
+ .global-search-sorting {
392
+ display: flex;
393
+ align-items: center;
394
+ }
395
+
396
+ body.global-search-page
397
+ .block.search.global-search-block
398
+ .global-search-filters-left {
399
+ gap: 1rem;
400
+ }
401
+
402
+ body.global-search-page
403
+ .block.search.global-search-block
404
+ .global-search-filters-left
405
+ .filters-element {
406
+ margin-left: 0;
407
+ }
408
+
409
+ body.global-search-page
410
+ .block.search.global-search-block
411
+ .global-search-filters-left
412
+ .filters-title {
413
+ align-items: center;
414
+ }
415
+
416
+ body.global-search-page
417
+ .block.search.global-search-block
418
+ .global-search-filters-left
419
+ .filters-title
420
+ .global-search-categories-icon {
421
+ display: inline-flex;
422
+ width: 16px !important;
423
+ height: 16px !important;
424
+ align-items: center;
425
+ justify-content: center;
426
+ margin-right: 0.35rem;
427
+ background: @clmsGreen;
428
+ border-radius: 50%;
429
+ color: #fff;
430
+ }
431
+
432
+ body.global-search-page
433
+ .block.search.global-search-block
434
+ .global-search-filters-left
435
+ .global-search-categories-icon
436
+ .global-search-categories-filter-icon {
437
+ display: block;
438
+ color: #fff;
439
+ }
440
+
441
+ body.global-search-page
442
+ .block.search.global-search-block
443
+ .global-search-applied-filters {
444
+ color: #808080;
445
+ gap: 0.25rem;
446
+ }
447
+
448
+ body.global-search-page
449
+ .block.search.global-search-block
450
+ .global-search-applied-filters
451
+ .ui.basic.button {
452
+ padding: 0 !important;
453
+ border: none;
454
+ box-shadow: none !important;
455
+ color: #808080 !important;
456
+ }
457
+
458
+ body.global-search-page
459
+ .block.search.global-search-block
460
+ .global-search-sorting {
461
+ gap: 0.7rem;
462
+ }
463
+
464
+ body.global-search-page
465
+ .block.search.global-search-block
466
+ .global-search-sort-label {
467
+ color: #273b4b;
468
+ }
469
+
470
+ body.global-search-page
471
+ .block.search.global-search-block
472
+ .global-search-sorting
473
+ button {
474
+ padding: 0;
475
+ border: 0;
476
+ background: transparent;
477
+ color: #808080;
478
+ cursor: pointer;
479
+ font: inherit;
480
+ font-weight: 700;
481
+ }
482
+
483
+ body.global-search-page
484
+ .block.search.global-search-block
485
+ .global-search-sorting
486
+ button.active,
487
+ body.global-search-page
488
+ .block.search.global-search-block
489
+ .global-search-sorting
490
+ button:hover {
491
+ color: @clmsGreen;
492
+ }
493
+
494
+ body.global-search-page
495
+ .block.search.global-search-block
496
+ .global-search-sorting
497
+ button:first-of-type {
498
+ color: #808080;
499
+ }
500
+
501
+ body.global-search-page
502
+ .block.search.global-search-block
503
+ .global-search-sort-direction {
504
+ margin-left: 0.25rem;
505
+ color: #808080;
506
+ font-size: 0.75rem;
507
+ }
508
+
509
+ body.global-search-page .block.search.global-search-block .card-doc {
510
+ padding: 0;
511
+ border-bottom: 1px solid #cfd5d8;
512
+ }
513
+
514
+ body.global-search-page
515
+ .block.search.global-search-block
516
+ .global-search-result-row {
517
+ display: grid;
518
+ padding: 1.15rem 0 1.05rem;
519
+ column-gap: 1.5rem;
520
+ grid-template-columns: minmax(0, 1fr) auto;
521
+ }
522
+
523
+ body.global-search-page
524
+ .block.search.global-search-block
525
+ .global-search-result-main {
526
+ min-width: 0;
527
+ }
528
+
529
+ body.global-search-page
530
+ .block.search.global-search-block
531
+ .global-search-result-main
532
+ .card-doc-header {
533
+ display: block;
534
+ }
535
+
536
+ body.global-search-page
537
+ .block.search.global-search-block
538
+ .global-search-result-main
539
+ .card-doc-title {
540
+ margin-bottom: 0.85rem;
541
+ font-size: 20px;
542
+ line-height: 1.25;
543
+ }
544
+
545
+ body.global-search-page
546
+ .block.search.global-search-block
547
+ .global-search-result-main
548
+ .card-doc-title
549
+ a {
550
+ color: @clmsGreen;
551
+ }
552
+
553
+ body.global-search-page
554
+ .block.search.global-search-block
555
+ .global-search-result-main
556
+ .card-doc-description {
557
+ margin-bottom: 0.35rem;
558
+ }
559
+
560
+ body.global-search-page
561
+ .block.search.global-search-block
562
+ .global-search-result-main
563
+ .card-doc-extrametadata {
564
+ color: #34495e;
565
+ font-size: 16px;
566
+ }
567
+
568
+ body.global-search-page
569
+ .block.search.global-search-block
570
+ .global-search-result-side {
571
+ display: flex;
572
+ flex-direction: column;
573
+ align-items: flex-end;
574
+ padding-top: 0.05rem;
575
+ color: #34495e;
576
+ gap: 1.15rem;
577
+ white-space: nowrap;
578
+ }
579
+
580
+ body.global-search-page
581
+ .block.search.global-search-block
582
+ .global-search-result-type {
583
+ padding: 0.25rem 0.55rem;
584
+ background: #e6e6e6;
585
+ border-radius: 4px;
586
+ color: #555;
587
+ font-size: 12px;
588
+ line-height: 1;
589
+ }
590
+
591
+ body.global-search-page
592
+ .block.search.global-search-block
593
+ .global-search-result-size {
594
+ font-size: 14px;
595
+ }
596
+
597
+ @media (max-width: 1127px) {
598
+ body.global-search-page.searchlib-page div#page-document.ui.container,
599
+ body.global-search-page.searchlib-page div#page-document {
600
+ width: calc(100% - 2rem) !important;
601
+ max-width: calc(100% - 2rem) !important;
602
+ padding-right: 1rem;
603
+ padding-left: 1rem;
604
+ }
605
+
606
+ body.global-search-page .block.search.global-search-block {
607
+ padding-right: 0;
608
+ padding-left: 0;
609
+ }
610
+ }
611
+
612
+ @media (max-width: 767px) {
613
+ body.global-search-page.searchlib-page div#page-document.ui.container,
614
+ body.global-search-page.searchlib-page div#page-document {
615
+ padding-right: 0.75rem;
616
+ padding-left: 0.75rem;
617
+ }
618
+
619
+ body.global-search-page h1.documentFirstHeading {
620
+ padding-bottom: 0.75rem;
621
+ margin-bottom: 0.75rem;
622
+ font-size: 28px;
623
+ }
624
+
625
+ body.global-search-page
626
+ .block.search.global-search-block
627
+ .sui-search-box
628
+ .search-input
629
+ .terms-box
630
+ input {
631
+ min-width: 0;
632
+ }
633
+
634
+ body.global-search-page
635
+ .block.search.global-search-block
636
+ .sui-search-box
637
+ .search-input
638
+ .terms-box
639
+ .input-controls
640
+ .clear-button {
641
+ width: 24px;
642
+ height: 24px;
643
+ margin: 0 0.35rem 0.35rem 0;
644
+ }
645
+
646
+ body.global-search-page .block.search.global-search-block .search-box-hint p {
647
+ font-size: 0.72rem;
648
+ line-height: 1.35;
649
+ }
650
+
651
+ body.global-search-page
652
+ .block.search.global-search-block
653
+ .global-search-count {
654
+ margin-top: 1.1rem;
655
+ }
656
+
657
+ body.global-search-page
658
+ .block.search.global-search-block
659
+ .global-search-above-results,
660
+ body.global-search-page
661
+ .block.search.global-search-block
662
+ .global-search-result-row {
663
+ display: flex;
664
+ flex-direction: column;
665
+ gap: 0.75rem;
666
+ }
667
+
668
+ body.global-search-page
669
+ .block.search.global-search-block
670
+ .global-search-above-results {
671
+ align-items: stretch;
672
+ padding-bottom: 1rem;
673
+ }
674
+
675
+ body.global-search-page
676
+ .block.search.global-search-block
677
+ .global-search-filters-left {
678
+ flex-wrap: wrap;
679
+ align-items: flex-start;
680
+ gap: 0.5rem 0.85rem;
681
+ }
682
+
683
+ body.global-search-page
684
+ .block.search.global-search-block
685
+ .global-search-sorting {
686
+ width: 100%;
687
+ flex-wrap: nowrap;
688
+ align-items: center;
689
+ justify-content: flex-start;
690
+ gap: 0.45rem 0.7rem;
691
+ }
692
+
693
+ body.global-search-page
694
+ .block.search.global-search-block
695
+ .global-search-result-row {
696
+ padding: 0.95rem 0;
697
+ }
698
+
699
+ body.global-search-page
700
+ .block.search.global-search-block
701
+ .global-search-result-main
702
+ .card-doc-title {
703
+ margin-bottom: 0.55rem;
704
+ font-size: 18px;
705
+ line-height: 1.3;
706
+ }
707
+
708
+ body.global-search-page
709
+ .block.search.global-search-block
710
+ .global-search-result-main
711
+ .card-doc-extrametadata {
712
+ font-size: 14px;
713
+ line-height: 1.4;
714
+ }
715
+
716
+ body.global-search-page
717
+ .block.search.global-search-block
718
+ .global-search-result-side {
719
+ flex-direction: row;
720
+ flex-wrap: wrap;
721
+ align-items: flex-start;
722
+ gap: 0.5rem;
723
+ white-space: normal;
724
+ }
725
+
726
+ body.global-search-page
727
+ .block.search.global-search-block
728
+ .ui.pagination.menu {
729
+ width: 100%;
730
+ max-width: 100%;
731
+ justify-content: flex-start;
732
+ overflow-x: auto;
733
+ }
734
+
735
+ body.global-search-page
736
+ .block.search.global-search-block
737
+ .ui.pagination.menu
738
+ .item {
739
+ flex: 0 0 auto;
740
+ }
741
+ }
742
+
743
+ @media (max-width: 420px) {
744
+ body.global-search-page h1.documentFirstHeading {
745
+ font-size: 26px;
746
+ }
747
+ }
748
+
292
749
  /* Filters */
293
750
  .filters-container {
294
751
  display: flex;