@plone/volto 17.0.0-alpha.0 → 17.0.0-alpha.10

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.
Files changed (190) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/CHANGELOG.md +451 -19
  3. package/CONTRIBUTING.md +1 -1
  4. package/README.md +12 -15
  5. package/addon-registry.js +34 -0
  6. package/create-theme-addons-loader.js +79 -0
  7. package/cypress/support/commands.js +25 -0
  8. package/locales/ca/LC_MESSAGES/volto.po +187 -6
  9. package/locales/ca.json +1 -1
  10. package/locales/de/LC_MESSAGES/volto.po +206 -25
  11. package/locales/de.json +1 -1
  12. package/locales/en/LC_MESSAGES/volto.po +186 -5
  13. package/locales/en.json +1 -1
  14. package/locales/es/LC_MESSAGES/volto.po +187 -6
  15. package/locales/es.json +1 -1
  16. package/locales/eu/LC_MESSAGES/volto.po +187 -6
  17. package/locales/eu.json +1 -1
  18. package/locales/fi/LC_MESSAGES/volto.po +4792 -0
  19. package/locales/fi.json +1 -1
  20. package/locales/fr/LC_MESSAGES/volto.po +187 -6
  21. package/locales/fr.json +1 -1
  22. package/locales/it/LC_MESSAGES/volto.po +187 -6
  23. package/locales/it.json +1 -1
  24. package/locales/ja/LC_MESSAGES/volto.po +187 -6
  25. package/locales/ja.json +1 -1
  26. package/locales/nl/LC_MESSAGES/volto.po +842 -649
  27. package/locales/nl.json +1 -1
  28. package/locales/pt/LC_MESSAGES/volto.po +187 -6
  29. package/locales/pt.json +1 -1
  30. package/locales/pt_BR/LC_MESSAGES/volto.po +195 -14
  31. package/locales/pt_BR.json +1 -1
  32. package/locales/ro/LC_MESSAGES/volto.po +187 -6
  33. package/locales/ro.json +1 -1
  34. package/locales/volto.pot +187 -6
  35. package/locales/zh_CN/LC_MESSAGES/volto.po +187 -6
  36. package/locales/zh_CN.json +1 -1
  37. package/package-why.json +0 -1
  38. package/package.json +9 -8
  39. package/packages/volto-slate/build/messages/src/blocks/Table/TableBlockEdit.json +1 -1
  40. package/packages/volto-slate/build/messages/src/blocks/Text/DefaultTextBlockEditor.json +1 -1
  41. package/packages/volto-slate/build/messages/src/blocks/Text/DetachedTextBlockEditor.json +1 -1
  42. package/packages/volto-slate/build/messages/src/blocks/Text/SlashMenu.json +1 -1
  43. package/packages/volto-slate/build/messages/src/editor/plugins/AdvancedLink/index.json +1 -1
  44. package/packages/volto-slate/build/messages/src/editor/plugins/Link/index.json +1 -1
  45. package/packages/volto-slate/build/messages/src/editor/plugins/Table/index.json +1 -1
  46. package/packages/volto-slate/build/messages/src/elementEditor/messages.json +1 -1
  47. package/packages/volto-slate/build/messages/src/widgets/HtmlSlateWidget.json +1 -1
  48. package/packages/volto-slate/build/messages/src/widgets/RichTextWidgetView.json +1 -1
  49. package/packages/volto-slate/package.json +1 -1
  50. package/packages/volto-slate/src/blocks/Table/TableBlockView.jsx +4 -4
  51. package/packages/volto-slate/src/blocks/Table/index.js +2 -0
  52. package/packages/volto-slate/src/blocks/Text/SlashMenu.jsx +4 -3
  53. package/packages/volto-slate/src/editor/deserialize.js +0 -1
  54. package/packages/volto-slate/src/editor/plugins/StyleMenu/StyleMenu.jsx +14 -4
  55. package/razzle.config.js +28 -0
  56. package/src/actions/index.js +6 -0
  57. package/src/actions/language/language.js +9 -8
  58. package/src/actions/querystringsearch/querystringsearch.js +20 -14
  59. package/src/actions/relations/rebuild.js +25 -0
  60. package/src/actions/relations/relations.js +86 -0
  61. package/src/actions/relations/relations.test.js +15 -0
  62. package/src/components/index.js +1 -0
  63. package/src/components/manage/Add/Add.jsx +2 -2
  64. package/src/components/manage/BlockChooser/BlockChooser.jsx +14 -5
  65. package/src/components/manage/BlockChooser/BlockChooser.test.jsx +5 -0
  66. package/src/components/manage/BlockChooser/BlockChooserButton.jsx +63 -29
  67. package/src/components/manage/BlockChooser/BlockChooserSearch.jsx +0 -1
  68. package/src/components/manage/Blocks/Listing/Edit.jsx +0 -19
  69. package/src/components/manage/Blocks/Listing/ListingBody.jsx +77 -61
  70. package/src/components/manage/Blocks/Listing/View.jsx +0 -4
  71. package/src/components/manage/Blocks/Listing/getAsyncData.js +10 -2
  72. package/src/components/manage/Blocks/Listing/withQuerystringResults.jsx +18 -13
  73. package/src/components/manage/Blocks/Search/SearchBlockEdit.jsx +5 -4
  74. package/src/components/manage/Blocks/Search/SearchBlockView.jsx +2 -1
  75. package/src/components/manage/Blocks/Search/components/DateRangeFacet.jsx +4 -1
  76. package/src/components/manage/Blocks/Search/components/Facets.jsx +58 -2
  77. package/src/components/manage/Blocks/Search/hocs/withSearch.jsx +24 -11
  78. package/src/components/manage/Blocks/Search/layout/LeftColumnFacets.jsx +17 -5
  79. package/src/components/manage/Blocks/Search/layout/RightColumnFacets.jsx +17 -5
  80. package/src/components/manage/Blocks/Search/layout/TopSideFacets.jsx +21 -5
  81. package/src/components/manage/Blocks/Search/schema.js +16 -1
  82. package/src/components/manage/Blocks/ToC/Edit.jsx +1 -0
  83. package/src/components/manage/Contents/Contents.jsx +69 -33
  84. package/src/components/manage/Contents/ContentsItem.jsx +6 -0
  85. package/src/components/manage/Controlpanels/AddonsControlpanel.jsx +3 -3
  86. package/src/components/manage/Controlpanels/Controlpanels.jsx +199 -224
  87. package/src/components/manage/Controlpanels/Controlpanels.test.jsx +46 -7
  88. package/src/components/manage/Controlpanels/Relations/BrokenRelations.jsx +66 -0
  89. package/src/components/manage/Controlpanels/Relations/Relations.jsx +114 -0
  90. package/src/components/manage/Controlpanels/Relations/RelationsListing.jsx +479 -0
  91. package/src/components/manage/Controlpanels/Relations/RelationsMatrix.jsx +531 -0
  92. package/src/components/manage/Controlpanels/Users/UserGroupMembershipControlPanel.jsx +3 -3
  93. package/src/components/manage/Controlpanels/Users/UserGroupMembershipListing.jsx +51 -82
  94. package/src/components/manage/Controlpanels/Users/UserGroupMembershipMatrix.jsx +79 -75
  95. package/src/components/manage/DragDropList/DragDropList.jsx +63 -42
  96. package/src/components/manage/Form/BlocksToolbar.jsx +5 -1
  97. package/src/components/manage/Form/Form.jsx +11 -5
  98. package/src/components/manage/Form/InlineForm.jsx +39 -9
  99. package/src/components/manage/Form/InlineFormState.js +8 -0
  100. package/src/components/manage/History/History.jsx +35 -18
  101. package/src/components/manage/Multilingual/CreateTranslation.jsx +2 -2
  102. package/src/components/manage/Multilingual/TranslationObject.jsx +4 -3
  103. package/src/components/manage/Preferences/ChangePassword.jsx +2 -2
  104. package/src/components/manage/Preferences/PersonalPreferences.jsx +2 -2
  105. package/src/components/manage/Toast/Toast.jsx +1 -1
  106. package/src/components/manage/Toolbar/Types.jsx +2 -2
  107. package/src/components/manage/Widgets/DatetimeWidget.jsx +9 -5
  108. package/src/components/manage/Widgets/ObjectListWidget.jsx +3 -8
  109. package/src/components/manage/Widgets/RecurrenceWidget/ByDayField.jsx +2 -1
  110. package/src/components/manage/Widgets/RecurrenceWidget/MonthOfTheYearField.jsx +2 -1
  111. package/src/components/manage/Widgets/RecurrenceWidget/Occurences.jsx +2 -1
  112. package/src/components/manage/Widgets/RecurrenceWidget/RecurrenceWidget.jsx +7 -2
  113. package/src/components/manage/Widgets/RecurrenceWidget/WeekdayOfTheMonthField.jsx +2 -1
  114. package/src/components/manage/Widgets/SelectUtils.js +1 -1
  115. package/src/components/manage/Widgets/SelectWidget.jsx +1 -1
  116. package/src/components/theme/Footer/Footer.jsx +2 -13
  117. package/src/components/theme/Header/Header.jsx +37 -63
  118. package/src/components/theme/Header/Header.test.jsx +18 -0
  119. package/src/components/theme/Icon/Icon.jsx +2 -2
  120. package/src/components/theme/LanguageSelector/LanguageSelector.js +8 -3
  121. package/src/components/theme/Login/Login.jsx +1 -0
  122. package/src/components/theme/Logo/Logo.jsx +2 -1
  123. package/src/components/theme/MultilingualRedirector/MultilingualRedirector.jsx +2 -2
  124. package/src/components/theme/Navigation/NavItem.jsx +4 -2
  125. package/src/components/theme/NotFound/NotFound.jsx +55 -41
  126. package/src/components/theme/PasswordReset/PasswordReset.jsx +7 -4
  127. package/src/components/theme/PasswordReset/RequestPasswordReset.jsx +1 -1
  128. package/src/components/theme/Sitemap/Sitemap.jsx +5 -3
  129. package/src/components/theme/View/DefaultView.jsx +1 -1
  130. package/src/components/theme/View/EventDatesInfo.jsx +2 -1
  131. package/src/components/theme/View/EventView.jsx +1 -1
  132. package/src/components/theme/View/NewsItemView.jsx +1 -1
  133. package/src/components/theme/View/RenderBlocks.jsx +7 -1
  134. package/src/components/theme/Widgets/DateWidget.jsx +2 -1
  135. package/src/components/theme/Widgets/DatetimeWidget.jsx +2 -1
  136. package/src/components/theme/Widgets/RelationsWidget.jsx +13 -11
  137. package/src/config/ControlPanels.js +2 -0
  138. package/src/config/Widgets.jsx +1 -0
  139. package/src/config/index.js +3 -0
  140. package/src/config/server.js +19 -0
  141. package/src/constants/ActionTypes.js +4 -0
  142. package/src/constants/Languages.js +8 -4
  143. package/src/express-middleware/devproxy.js +4 -2
  144. package/src/express-middleware/sitemap.js +36 -4
  145. package/src/express-middleware/static.js +32 -0
  146. package/src/helpers/Api/Api.js +1 -1
  147. package/src/helpers/FormValidation/FormValidation.js +11 -2
  148. package/src/helpers/FormValidation/FormValidation.test.js +73 -0
  149. package/src/helpers/Html/Html.jsx +3 -1
  150. package/src/helpers/Html/Html.test.jsx +5 -0
  151. package/src/helpers/MessageLabels/MessageLabels.js +72 -0
  152. package/src/helpers/Robots/Robots.js +24 -6
  153. package/src/helpers/Sitemap/Sitemap.js +44 -2
  154. package/src/helpers/Url/Url.js +27 -6
  155. package/src/helpers/Url/Url.test.js +26 -0
  156. package/src/helpers/Utils/Utils.js +38 -13
  157. package/src/helpers/Utils/Utils.test.js +4 -4
  158. package/src/helpers/index.js +7 -2
  159. package/src/hooks/userSession/useToken.js +5 -0
  160. package/src/middleware/Api.test.js +54 -0
  161. package/src/middleware/api.js +8 -4
  162. package/src/reducers/actions/actions.js +1 -1
  163. package/src/reducers/breadcrumbs/breadcrumbs.js +1 -1
  164. package/src/reducers/index.js +2 -0
  165. package/src/reducers/navigation/navigation.js +1 -1
  166. package/src/reducers/relations/relations.js +173 -0
  167. package/src/reducers/types/types.js +1 -1
  168. package/src/routes.js +5 -0
  169. package/src/server.jsx +29 -30
  170. package/src/start-server.js +4 -2
  171. package/test-setup-config.js +1 -0
  172. package/theme/themes/pastanaga/extras/blocks.less +0 -9
  173. package/theme/themes/pastanaga/extras/contents.less +1 -0
  174. package/theme/themes/pastanaga/extras/main.less +80 -1
  175. package/theme/themes/pastanaga/extras/search.less +6 -0
  176. package/theme/themes/pastanaga/extras/sidebar.less +4 -0
  177. package/theme/themes/pastanaga/extras/userscontrolpanel.less +99 -76
  178. package/.changelog.draft +0 -22
  179. package/.editorconfig +0 -36
  180. package/.storybook/main.js +0 -127
  181. package/.storybook/manager.js +0 -15
  182. package/.storybook/preview.js +0 -21
  183. package/.storybook/static/previewImage.svg +0 -48
  184. package/.yarnrc.yml +0 -5
  185. package/jsdoc.json +0 -16
  186. package/netlify.toml +0 -5
  187. package/pyvenv.cfg +0 -3
  188. package/share/man/man1/ttx.1 +0 -225
  189. package/src/components/theme/Header/Header.md +0 -27
  190. package/towncrier.toml +0 -33
@@ -14,11 +14,16 @@ function getDisplayName(WrappedComponent) {
14
14
 
15
15
  export default function withQuerystringResults(WrappedComponent) {
16
16
  function WithQuerystringResults(props) {
17
- const { data = {}, properties: content, path, variation } = props;
17
+ const {
18
+ data = {},
19
+ id = data.block,
20
+ properties: content,
21
+ path,
22
+ variation,
23
+ } = props;
18
24
  const { settings } = config;
19
25
  const querystring = data.querystring || data; // For backwards compat with data saved before Blocks schema. Note, this is also how the Search block passes data to ListingBody
20
26
 
21
- const { block } = data;
22
27
  const { b_size = settings.defaultPageSize } = querystring; // batchsize
23
28
 
24
29
  // save the path so it won't trigger dispatch on eager router location change
@@ -45,32 +50,32 @@ export default function withQuerystringResults(WrappedComponent) {
45
50
 
46
51
  const folderItems = content?.is_folderish ? content.items : [];
47
52
  const hasQuery = querystring?.query?.length > 0;
48
- const hasLoaded = hasQuery ? !querystringResults?.[block]?.loading : true;
53
+ const hasLoaded = hasQuery ? !querystringResults?.[id]?.loading : true;
49
54
 
50
55
  const listingItems =
51
- querystring?.query?.length > 0 && querystringResults?.[block]
52
- ? querystringResults?.[block]?.items || []
56
+ querystring?.query?.length > 0 && querystringResults?.[id]
57
+ ? querystringResults?.[id]?.items || []
53
58
  : folderItems;
54
59
 
55
60
  const showAsFolderListing = !hasQuery && content?.items_total > b_size;
56
61
  const showAsQueryListing =
57
- hasQuery && querystringResults?.[block]?.total > b_size;
62
+ hasQuery && querystringResults?.[id]?.total > b_size;
58
63
 
59
64
  const totalPages = showAsFolderListing
60
65
  ? Math.ceil(content.items_total / b_size)
61
66
  : showAsQueryListing
62
- ? Math.ceil(querystringResults[block].total / b_size)
67
+ ? Math.ceil(querystringResults[id].total / b_size)
63
68
  : 0;
64
69
 
65
70
  const prevBatch = showAsFolderListing
66
71
  ? content.batching?.prev
67
72
  : showAsQueryListing
68
- ? querystringResults[block].batching?.prev
73
+ ? querystringResults[id].batching?.prev
69
74
  : null;
70
75
  const nextBatch = showAsFolderListing
71
76
  ? content.batching?.next
72
77
  : showAsQueryListing
73
- ? querystringResults[block].batching?.next
78
+ ? querystringResults[id].batching?.next
74
79
  : null;
75
80
 
76
81
  const isImageGallery =
@@ -80,7 +85,7 @@ export default function withQuerystringResults(WrappedComponent) {
80
85
  useDeepCompareEffect(() => {
81
86
  if (hasQuery) {
82
87
  dispatch(
83
- getQueryStringResults(initialPath, adaptedQuery, block, currentPage),
88
+ getQueryStringResults(initialPath, adaptedQuery, id, currentPage),
84
89
  );
85
90
  } else if (isImageGallery && !hasQuery) {
86
91
  // when used as image gallery, it doesn't need a query to list children
@@ -98,14 +103,14 @@ export default function withQuerystringResults(WrappedComponent) {
98
103
  },
99
104
  ],
100
105
  },
101
- block,
106
+ id,
102
107
  ),
103
108
  );
104
109
  } else {
105
110
  dispatch(getContent(initialPath, null, null, currentPage));
106
111
  }
107
112
  }, [
108
- block,
113
+ id,
109
114
  isImageGallery,
110
115
  adaptedQuery,
111
116
  hasQuery,
@@ -118,7 +123,7 @@ export default function withQuerystringResults(WrappedComponent) {
118
123
  <WrappedComponent
119
124
  {...props}
120
125
  onPaginationChange={(e, { activePage }) => setCurrentPage(activePage)}
121
- total={querystringResults?.[block]?.total}
126
+ total={querystringResults?.[id]?.total}
122
127
  batch_size={b_size}
123
128
  currentPage={currentPage}
124
129
  totalPages={totalPages}
@@ -1,5 +1,4 @@
1
- import React from 'react';
2
- import useDeepCompareEffect from 'use-deep-compare-effect';
1
+ import React, { useEffect } from 'react';
3
2
  import { defineMessages } from 'react-intl';
4
3
  import { compose } from 'redux';
5
4
 
@@ -60,9 +59,11 @@ const SearchBlockEdit = (props) => {
60
59
  };
61
60
 
62
61
  const { query = {} } = data || {};
63
- useDeepCompareEffect(() => {
62
+ // We don't need deep compare here, as this is just json serializable data.
63
+ const deepQuery = JSON.stringify(query);
64
+ useEffect(() => {
64
65
  onTriggerSearch();
65
- }, [query, onTriggerSearch]);
66
+ }, [deepQuery, onTriggerSearch]);
66
67
 
67
68
  return (
68
69
  <>
@@ -57,7 +57,7 @@ const applyDefaults = (data, root) => {
57
57
  };
58
58
 
59
59
  const SearchBlockView = (props) => {
60
- const { data, searchData, mode = 'view', variation } = props;
60
+ const { id, data, searchData, mode = 'view', variation } = props;
61
61
 
62
62
  const Layout = variation.view;
63
63
 
@@ -89,6 +89,7 @@ const SearchBlockView = (props) => {
89
89
  setSelectedView={setSelectedView}
90
90
  >
91
91
  <ListingBody
92
+ id={id}
92
93
  variation={{ ...data, ...listingBodyVariation }}
93
94
  data={listingBodyData}
94
95
  path={props.path}
@@ -4,6 +4,7 @@ import { defineMessages, injectIntl } from 'react-intl';
4
4
  import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
5
5
  import { compose } from 'redux';
6
6
  import { Icon } from '@plone/volto/components';
7
+ import { toBackendLang } from '@plone/volto/helpers/Utils/Utils';
7
8
  import { connect } from 'react-redux';
8
9
 
9
10
  import leftKey from '@plone/volto/icons/left-key.svg';
@@ -82,7 +83,9 @@ const DateRangeFacet = (props) => {
82
83
  noBorder
83
84
  showClearDates
84
85
  customCloseIcon={<CloseIcon />}
85
- displayFormat={moment.localeData(lang).longDateFormat('L')}
86
+ displayFormat={moment
87
+ .localeData(toBackendLang(lang))
88
+ .longDateFormat('L')}
86
89
  focusedInput={focused}
87
90
  onFocusChange={(focusedInput) => setFocused(focusedInput)}
88
91
  onDatesChange={({ startDate, endDate }) => {
@@ -1,7 +1,16 @@
1
- import React from 'react';
1
+ import React, { useState, useMemo } from 'react';
2
+ import { Button, Grid } from 'semantic-ui-react';
2
3
  import { resolveExtension } from '@plone/volto/helpers/Extensions/withBlockExtensions';
3
4
  import config from '@plone/volto/registry';
4
5
  import { hasNonValueOperation, hasDateOperation } from '../utils';
6
+ import { defineMessages, useIntl } from 'react-intl';
7
+
8
+ const messages = defineMessages({
9
+ moreFilters: { id: 'More filters', defaultMessage: 'More filters' },
10
+ lessFilters: { id: 'Less filters', defaultMessage: 'Less filters' },
11
+ showFilters: { id: 'Show filters', defaultMessage: 'Show filters' },
12
+ hideFilters: { id: 'Hide filters', defaultMessage: 'Hide filters' },
13
+ });
5
14
 
6
15
  const showFacet = (index) => {
7
16
  const { values } = index;
@@ -14,6 +23,7 @@ const showFacet = (index) => {
14
23
  };
15
24
 
16
25
  const Facets = (props) => {
26
+ const [hidden, setHidden] = useState(true);
17
27
  const {
18
28
  querystring,
19
29
  data = {},
@@ -24,11 +34,29 @@ const Facets = (props) => {
24
34
  } = props;
25
35
  const { search } = config.blocks.blocksConfig;
26
36
 
37
+ const advancedFilters = useMemo(() => {
38
+ let count = 0;
39
+ for (let facetSettings of data.facets || []) {
40
+ if (facetSettings.advanced) {
41
+ count++;
42
+ }
43
+ }
44
+
45
+ if (count === data.facets?.length) {
46
+ return 2;
47
+ }
48
+ if (count) {
49
+ return 1;
50
+ }
51
+ return 0;
52
+ }, [data.facets]);
53
+
27
54
  const FacetWrapper = facetWrapper;
28
55
  const query_to_values = Object.assign(
29
56
  {},
30
57
  ...(data?.query?.query?.map(({ i, v }) => ({ [i]: v })) || []),
31
58
  );
59
+ const intl = useIntl();
32
60
 
33
61
  return (
34
62
  <>
@@ -36,6 +64,7 @@ const Facets = (props) => {
36
64
  ?.filter((facetSettings) => !facetSettings.hidden)
37
65
  .map((facetSettings) => {
38
66
  const field = facetSettings?.field?.value;
67
+ const isAdvanced = facetSettings?.advanced;
39
68
  const index = querystring.indexes[field] || {};
40
69
  const { values = {} } = index;
41
70
 
@@ -58,6 +87,7 @@ const Facets = (props) => {
58
87
 
59
88
  const isMulti = facetSettings.multiple;
60
89
  const selectedValue = facets[facetSettings?.field?.value];
90
+ const visible = (isAdvanced && !hidden) || !isAdvanced;
61
91
 
62
92
  // TODO :handle changing the type of facet (multi/nonmulti)
63
93
 
@@ -74,7 +104,11 @@ const Facets = (props) => {
74
104
  } = search.extensions.facetWidgets;
75
105
 
76
106
  return FacetWrapper && (isEditMode || showFacet(index)) ? (
77
- <FacetWrapper key={facetSettings['@id']}>
107
+ <FacetWrapper
108
+ key={facetSettings['@id']}
109
+ facetSettings={facetSettings}
110
+ visible={visible}
111
+ >
78
112
  <FacetWidget
79
113
  facet={facetSettings}
80
114
  choices={rewriteOptions(facetSettings?.field?.value, choices)}
@@ -90,6 +124,28 @@ const Facets = (props) => {
90
124
  ''
91
125
  );
92
126
  })}
127
+ {advancedFilters > 0 && (
128
+ <Grid.Column
129
+ mobile={12}
130
+ tablet={12}
131
+ computer={12}
132
+ className="toggle-advanced-facets"
133
+ >
134
+ <Button
135
+ onClick={() => {
136
+ setHidden((prevHidden) => !prevHidden);
137
+ }}
138
+ >
139
+ {hidden
140
+ ? advancedFilters === 2
141
+ ? intl.formatMessage(messages.showFilters)
142
+ : intl.formatMessage(messages.moreFilters)
143
+ : advancedFilters === 2
144
+ ? intl.formatMessage(messages.hideFilters)
145
+ : intl.formatMessage(messages.lessFilters)}
146
+ </Button>
147
+ </Grid.Column>
148
+ )}
93
149
  </>
94
150
  );
95
151
  };
@@ -114,15 +114,19 @@ function normalizeState({
114
114
  block: id,
115
115
  };
116
116
 
117
- // TODO: need to check if SearchableText facet is not already in the query
118
- // Ideally the searchtext functionality should be restructured as being just
119
- // another facet
120
- params.query = params.query.reduce(
121
- // Remove SearchableText from query
122
- (acc, kvp) => (kvp.i === 'SearchableText' ? acc : [...acc, kvp]),
123
- [],
124
- );
117
+ // Note Ideally the searchtext functionality should be restructured as being just
118
+ // another facet. But right now it's the same. This means that if a searchText
119
+ // is provided, it will override the SearchableText facet.
120
+ // If there is no searchText, the SearchableText in the query remains in effect.
121
+ // TODO eventually the searchText should be a distinct facet from SearchableText, and
122
+ // the two conditions could be combined, in comparison to the current state, when
123
+ // one overrides the other.
125
124
  if (searchText) {
125
+ params.query = params.query.reduce(
126
+ // Remove SearchableText from query
127
+ (acc, kvp) => (kvp.i === 'SearchableText' ? acc : [...acc, kvp]),
128
+ [],
129
+ );
126
130
  params.query.push({
127
131
  i: 'SearchableText',
128
132
  o: 'plone.app.querystring.operation.string.contains',
@@ -278,8 +282,14 @@ const withSearch = (options) => (WrappedComponent) => {
278
282
  const timeoutRef = React.useRef();
279
283
  const facetSettings = data?.facets;
280
284
 
285
+ const deepQuery = JSON.stringify(data.query);
281
286
  const onTriggerSearch = React.useCallback(
282
- (toSearchText, toSearchFacets, toSortOn, toSortOrder) => {
287
+ (
288
+ toSearchText = undefined,
289
+ toSearchFacets = undefined,
290
+ toSortOn = undefined,
291
+ toSortOrder = undefined,
292
+ ) => {
283
293
  if (timeoutRef.current) clearTimeout(timeoutRef.current);
284
294
  timeoutRef.current = setTimeout(
285
295
  () => {
@@ -287,7 +297,7 @@ const withSearch = (options) => (WrappedComponent) => {
287
297
  id,
288
298
  query: data.query || {},
289
299
  facets: toSearchFacets || facets,
290
- searchText: toSearchText,
300
+ searchText: toSearchText || searchText,
291
301
  sortOn: toSortOn || sortOn,
292
302
  sortOrder: toSortOrder || sortOrder,
293
303
  facetSettings,
@@ -301,11 +311,14 @@ const withSearch = (options) => (WrappedComponent) => {
301
311
  toSearchFacets ? inputDelay / 3 : inputDelay,
302
312
  );
303
313
  },
314
+ // eslint-disable-next-line react-hooks/exhaustive-deps
304
315
  [
305
- data.query,
316
+ // Use deep comparison of data.query
317
+ deepQuery,
306
318
  facets,
307
319
  id,
308
320
  setLocationSearchData,
321
+ searchText,
309
322
  sortOn,
310
323
  sortOrder,
311
324
  facetSettings,
@@ -11,6 +11,7 @@ import { Grid, Segment } from 'semantic-ui-react';
11
11
  import { Button } from 'semantic-ui-react';
12
12
  import { flushSync } from 'react-dom';
13
13
  import { defineMessages, useIntl } from 'react-intl';
14
+ import cx from 'classnames';
14
15
 
15
16
  const messages = defineMessages({
16
17
  searchButtonText: {
@@ -19,11 +20,22 @@ const messages = defineMessages({
19
20
  },
20
21
  });
21
22
 
22
- const FacetWrapper = ({ children }) => (
23
- <Segment basic className="facet">
24
- {children}
25
- </Segment>
26
- );
23
+ const FacetWrapper = ({ children, facetSettings = {}, visible }) => {
24
+ const { advanced, field = {} } = facetSettings;
25
+
26
+ return (
27
+ <Segment
28
+ basic
29
+ className={cx('facet', {
30
+ [`facet-index-${field.value}`]: !!field.value,
31
+ 'advanced-facet': advanced,
32
+ 'advanced-facet-hidden': !visible,
33
+ })}
34
+ >
35
+ {children}
36
+ </Segment>
37
+ );
38
+ };
27
39
 
28
40
  const LeftColumnFacets = (props) => {
29
41
  const {
@@ -11,6 +11,7 @@ import { Grid, Segment } from 'semantic-ui-react';
11
11
  import { Button } from 'semantic-ui-react';
12
12
  import { flushSync } from 'react-dom';
13
13
  import { defineMessages, useIntl } from 'react-intl';
14
+ import cx from 'classnames';
14
15
 
15
16
  const messages = defineMessages({
16
17
  searchButtonText: {
@@ -19,11 +20,22 @@ const messages = defineMessages({
19
20
  },
20
21
  });
21
22
 
22
- const FacetWrapper = ({ children }) => (
23
- <Segment basic className="facet">
24
- {children}
25
- </Segment>
26
- );
23
+ const FacetWrapper = ({ children, facetSettings = {}, visible }) => {
24
+ const { advanced, field = {} } = facetSettings;
25
+
26
+ return (
27
+ <Segment
28
+ basic
29
+ className={cx('facet', {
30
+ [`facet-index-${field.value}`]: !!field.value,
31
+ 'advanced-facet': advanced,
32
+ 'advanced-facet-hidden': !visible,
33
+ })}
34
+ >
35
+ {children}
36
+ </Segment>
37
+ );
38
+ };
27
39
 
28
40
  const RightColumnFacets = (props) => {
29
41
  const {
@@ -11,6 +11,7 @@ import {
11
11
  SortOn,
12
12
  ViewSwitcher,
13
13
  } from '../components';
14
+ import cx from 'classnames';
14
15
 
15
16
  const messages = defineMessages({
16
17
  searchButtonText: {
@@ -19,11 +20,24 @@ const messages = defineMessages({
19
20
  },
20
21
  });
21
22
 
22
- const FacetWrapper = ({ children }) => (
23
- <Grid.Column mobile={12} tablet={4} computer={3}>
24
- {children}
25
- </Grid.Column>
26
- );
23
+ const FacetWrapper = ({ children, facetSettings = {}, visible }) => {
24
+ const { advanced, field = {} } = facetSettings;
25
+
26
+ return (
27
+ <Grid.Column
28
+ mobile={12}
29
+ tablet={4}
30
+ computer={3}
31
+ className={cx('facet', {
32
+ [`facet-index-${field.value}`]: !!field.value,
33
+ 'advanced-facet': advanced,
34
+ 'advanced-facet-hidden': !visible,
35
+ })}
36
+ >
37
+ {children}
38
+ </Grid.Column>
39
+ );
40
+ };
27
41
 
28
42
  const TopSideFacets = (props) => {
29
43
  const {
@@ -117,6 +131,7 @@ const TopSideFacets = (props) => {
117
131
  <ViewSwitcher {...props} />
118
132
  )}
119
133
  </div>
134
+
120
135
  {data.facets?.length > 0 && (
121
136
  <div className="facets">
122
137
  {data.facetsTitle && <h3>{data.facetsTitle}</h3>}
@@ -136,6 +151,7 @@ const TopSideFacets = (props) => {
136
151
  </Grid>
137
152
  </div>
138
153
  )}
154
+
139
155
  <SearchDetails
140
156
  text={searchedText}
141
157
  total={totalItems}
@@ -88,6 +88,15 @@ const messages = defineMessages({
88
88
  defaultMessage:
89
89
  'Hidden facets will still filter the results if proper parameters are passed in URLs',
90
90
  },
91
+ advancedFacetTitle: {
92
+ id: 'Advanced facet?',
93
+ defaultMessage: 'Advanced facet?',
94
+ },
95
+ advancedFacetDescription: {
96
+ id: 'Advanced facets are initially hidden and displayed on demand',
97
+ defaultMessage:
98
+ 'Advanced facets are initially hidden and displayed on demand',
99
+ },
91
100
  facetWidget: {
92
101
  id: 'Facet widget',
93
102
  defaultMessage: 'Facet widget',
@@ -131,7 +140,7 @@ const FacetSchema = ({ intl }) => ({
131
140
  {
132
141
  id: 'default',
133
142
  title: 'Default',
134
- fields: ['title', 'field', 'type', 'hidden'],
143
+ fields: ['title', 'field', 'type', 'hidden', 'advanced'],
135
144
  },
136
145
  ],
137
146
  properties: {
@@ -170,6 +179,12 @@ const FacetSchema = ({ intl }) => ({
170
179
  default: false,
171
180
  description: intl.formatMessage(messages.hideFacetDescription),
172
181
  },
182
+ advanced: {
183
+ type: 'boolean',
184
+ title: intl.formatMessage(messages.advancedFacetTitle),
185
+ default: false,
186
+ description: intl.formatMessage(messages.advancedFacetDescription),
187
+ },
173
188
  type: {
174
189
  title: intl.formatMessage(messages.facetWidget),
175
190
  choices: config.blocks.blocksConfig.search.extensions.facetWidgets.types.map(
@@ -26,6 +26,7 @@ class Edit extends Component {
26
26
  }}
27
27
  onChangeBlock={this.props.onChangeBlock}
28
28
  formData={this.props.data}
29
+ block={this.props.block}
29
30
  />
30
31
  </SidebarPortal>
31
32
  </>