@plone/volto 17.1.1 → 17.2.0
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
|
@@ -8,6 +8,17 @@
|
|
|
8
8
|
|
|
9
9
|
<!-- towncrier release notes start -->
|
|
10
10
|
|
|
11
|
+
## 17.2.0 (2023-10-16)
|
|
12
|
+
|
|
13
|
+
### Feature
|
|
14
|
+
|
|
15
|
+
- add cypress test for search block via url - @ionlizarazu [#5298](https://github.com/plone/volto/issues/5298)
|
|
16
|
+
|
|
17
|
+
### Bugfix
|
|
18
|
+
|
|
19
|
+
- Fix adding multiple path criteria in search and listing blocks. @davisagli [#5317](https://github.com/plone/volto/issues/5317)
|
|
20
|
+
|
|
21
|
+
|
|
11
22
|
## 17.1.1 (2023-10-13)
|
|
12
23
|
|
|
13
24
|
### Bugfix
|
package/news/5298 bugfix
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fix the search block for search via url - @ionlizarazu
|
package/package.json
CHANGED
|
@@ -28,7 +28,14 @@ const PAQO = 'plone.app.querystring.operation';
|
|
|
28
28
|
* @function getInitialState
|
|
29
29
|
*
|
|
30
30
|
*/
|
|
31
|
-
function getInitialState(
|
|
31
|
+
function getInitialState(
|
|
32
|
+
data,
|
|
33
|
+
facets,
|
|
34
|
+
urlSearchText,
|
|
35
|
+
id,
|
|
36
|
+
sortOnParam,
|
|
37
|
+
sortOrderParam,
|
|
38
|
+
) {
|
|
32
39
|
const { types: facetWidgetTypes } =
|
|
33
40
|
config.blocks.blocksConfig.search.extensions.facetWidgets;
|
|
34
41
|
const facetSettings = data?.facets || [];
|
|
@@ -62,8 +69,8 @@ function getInitialState(data, facets, urlSearchText, id) {
|
|
|
62
69
|
]
|
|
63
70
|
: []),
|
|
64
71
|
],
|
|
65
|
-
sort_on: data.query?.sort_on,
|
|
66
|
-
sort_order: data.query?.sort_order,
|
|
72
|
+
sort_on: sortOnParam || data.query?.sort_on,
|
|
73
|
+
sort_order: sortOrderParam || data.query?.sort_order,
|
|
67
74
|
b_size: data.query?.b_size,
|
|
68
75
|
limit: data.query?.limit,
|
|
69
76
|
block: id,
|
|
@@ -257,7 +264,28 @@ const withSearch = (options) => (WrappedComponent) => {
|
|
|
257
264
|
const multiFacets = data.facets
|
|
258
265
|
?.filter((facet) => facet?.multiple)
|
|
259
266
|
.map((facet) => facet?.field?.value);
|
|
260
|
-
const [facets, setFacets] = React.useState(
|
|
267
|
+
const [facets, setFacets] = React.useState(
|
|
268
|
+
Object.assign(
|
|
269
|
+
{},
|
|
270
|
+
...urlQuery.map(({ i, v }) => ({ [i]: v })), // TODO: the 'o' should be kept. This would be a major refactoring of the facets
|
|
271
|
+
|
|
272
|
+
// support for simple filters like ?Subject=something
|
|
273
|
+
// TODO: since the move to hash params this is no longer working.
|
|
274
|
+
// We'd have to treat the location.search and manage it just like the
|
|
275
|
+
// hash, to support it. We can read it, but we'd have to reset it as
|
|
276
|
+
// well, so at that point what's the difference to the hash?
|
|
277
|
+
...configuredFacets.map((f) =>
|
|
278
|
+
locationSearchData[f]
|
|
279
|
+
? {
|
|
280
|
+
[f]:
|
|
281
|
+
multiFacets.indexOf(f) > -1
|
|
282
|
+
? [locationSearchData[f]]
|
|
283
|
+
: locationSearchData[f],
|
|
284
|
+
}
|
|
285
|
+
: {},
|
|
286
|
+
),
|
|
287
|
+
),
|
|
288
|
+
);
|
|
261
289
|
const previousUrlQuery = usePrevious(urlQuery);
|
|
262
290
|
|
|
263
291
|
React.useEffect(() => {
|
|
@@ -296,11 +324,16 @@ const withSearch = (options) => (WrappedComponent) => {
|
|
|
296
324
|
const [sortOn, setSortOn] = React.useState(data?.query?.sort_on);
|
|
297
325
|
const [sortOrder, setSortOrder] = React.useState(data?.query?.sort_order);
|
|
298
326
|
|
|
299
|
-
const [searchData, setSearchData] = React.useState(
|
|
327
|
+
const [searchData, setSearchData] = React.useState(
|
|
328
|
+
getInitialState(data, facets, urlSearchText, id),
|
|
329
|
+
);
|
|
300
330
|
|
|
331
|
+
const deepFacets = JSON.stringify(facets);
|
|
301
332
|
React.useEffect(() => {
|
|
302
|
-
setSearchData(
|
|
303
|
-
|
|
333
|
+
setSearchData(
|
|
334
|
+
getInitialState(data, facets, urlSearchText, id, sortOn, sortOrder),
|
|
335
|
+
);
|
|
336
|
+
}, [deepFacets, facets, data, urlSearchText, id, sortOn, sortOrder]);
|
|
304
337
|
|
|
305
338
|
const timeoutRef = React.useRef();
|
|
306
339
|
const facetSettings = data?.facets;
|
|
@@ -316,7 +349,7 @@ const withSearch = (options) => (WrappedComponent) => {
|
|
|
316
349
|
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
|
317
350
|
timeoutRef.current = setTimeout(
|
|
318
351
|
() => {
|
|
319
|
-
const
|
|
352
|
+
const newSearchData = normalizeState({
|
|
320
353
|
id,
|
|
321
354
|
query: data.query || {},
|
|
322
355
|
facets: toSearchFacets || facets,
|
|
@@ -328,8 +361,8 @@ const withSearch = (options) => (WrappedComponent) => {
|
|
|
328
361
|
if (toSearchFacets) setFacets(toSearchFacets);
|
|
329
362
|
if (toSortOn) setSortOn(toSortOn);
|
|
330
363
|
if (toSortOrder) setSortOrder(toSortOrder);
|
|
331
|
-
setSearchData(
|
|
332
|
-
setLocationSearchData(getSearchFields(
|
|
364
|
+
setSearchData(newSearchData);
|
|
365
|
+
setLocationSearchData(getSearchFields(newSearchData));
|
|
333
366
|
},
|
|
334
367
|
toSearchFacets ? inputDelay / 3 : inputDelay,
|
|
335
368
|
);
|
|
@@ -349,13 +382,14 @@ const withSearch = (options) => (WrappedComponent) => {
|
|
|
349
382
|
);
|
|
350
383
|
|
|
351
384
|
const removeSearchQuery = () => {
|
|
352
|
-
|
|
385
|
+
let newSearchData = { ...searchData };
|
|
386
|
+
newSearchData.query = searchData.query.reduce(
|
|
353
387
|
// Remove SearchableText from query
|
|
354
388
|
(acc, kvp) => (kvp.i === 'SearchableText' ? acc : [...acc, kvp]),
|
|
355
389
|
[],
|
|
356
390
|
);
|
|
357
|
-
setSearchData(
|
|
358
|
-
setLocationSearchData(getSearchFields(
|
|
391
|
+
setSearchData(newSearchData);
|
|
392
|
+
setLocationSearchData(getSearchFields(newSearchData));
|
|
359
393
|
};
|
|
360
394
|
|
|
361
395
|
const querystringResults = useSelector(
|
|
@@ -314,7 +314,8 @@ export class QuerystringWidgetComponent extends Component {
|
|
|
314
314
|
label: field[1].title,
|
|
315
315
|
value: field[0],
|
|
316
316
|
isDisabled: (value || []).some(
|
|
317
|
-
(v) =>
|
|
317
|
+
(v) =>
|
|
318
|
+
v['i'] !== 'path' && v['i'] === field[0],
|
|
318
319
|
),
|
|
319
320
|
}),
|
|
320
321
|
),
|
|
@@ -444,8 +445,11 @@ export class QuerystringWidgetComponent extends Component {
|
|
|
444
445
|
(field) => ({
|
|
445
446
|
label: field[1].title,
|
|
446
447
|
value: field[0],
|
|
448
|
+
// disable selecting indexes that are already used,
|
|
449
|
+
// except for path, which has explicit support
|
|
450
|
+
// in the backend for multipath queries
|
|
447
451
|
isDisabled: (value || []).some(
|
|
448
|
-
(v) => v['i'] === field[0],
|
|
452
|
+
(v) => v['i'] !== 'path' && v['i'] === field[0],
|
|
449
453
|
),
|
|
450
454
|
}),
|
|
451
455
|
),
|