design-comuni-plone-theme 8.0.0 → 8.0.2

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
@@ -1,5 +1,20 @@
1
1
 
2
2
 
3
+ ## [8.0.2](https://github.com/RedTurtle/design-comuni-plone-theme/compare/v8.0.1...v8.0.2) (2023-07-14)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * update withQuerystringResults customization ([4d339a9](https://github.com/RedTurtle/design-comuni-plone-theme/commit/4d339a9ef5e55be5f30ae7da1490a624eac60bf3))
9
+ * wrong block context ([#249](https://github.com/RedTurtle/design-comuni-plone-theme/issues/249)) ([2047edf](https://github.com/RedTurtle/design-comuni-plone-theme/commit/2047edf08186acd26d738683950682afcea1acba))
10
+
11
+ ## [8.0.1](https://github.com/RedTurtle/design-comuni-plone-theme/compare/v8.0.0...v8.0.1) (2023-07-12)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * grid block config, blocks editor z-index ([02724a2](https://github.com/RedTurtle/design-comuni-plone-theme/commit/02724a21b512a4effaedebecfbfe3398fdfc20d8))
17
+
3
18
  ## [8.0.0](https://github.com/RedTurtle/design-comuni-plone-theme/compare/v8.0.0-alpha.43...v8.0.0) (2023-07-12)
4
19
 
5
20
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "design-comuni-plone-theme",
3
3
  "description": "Volto Theme for Italia design guidelines",
4
4
  "license": "GPL-v3",
5
- "version": "8.0.0",
5
+ "version": "8.0.2",
6
6
  "main": "src/index.js",
7
7
  "keywords": [
8
8
  "volto-addon",
@@ -68,7 +68,7 @@ const RenderBlocks = ({
68
68
  return (
69
69
  <div key={block}>
70
70
  {intl.formatMessage(messages.unknownBlock, {
71
- block: content[blocksFieldname]?.[block]?.['@type'],
71
+ block: blockContent[blocksFieldname]?.[block]?.['@type'],
72
72
  })}
73
73
  </div>
74
74
  );
@@ -364,6 +364,10 @@ const italiaBlocks = {
364
364
 
365
365
  const getItaliaBlocks = (config) => {
366
366
  delete config.blocks.blocksConfig.teaser;
367
+ config.blocks.blocksConfig.gridBlock.allowedBlocks =
368
+ config.blocks.blocksConfig.gridBlock.allowedBlocks
369
+ .filter((item) => !['slate', 'teaser'].includes(item))
370
+ .concat(['text']);
367
371
  return italiaBlocks;
368
372
  };
369
373
  export default getItaliaBlocks;
@@ -5,16 +5,13 @@ CUSTOMIZATIONS:
5
5
  - added additional filters
6
6
  - added additional fields to pass to @querystring-search (config.settings.querystringAdditionalFields)
7
7
  - usedeepCompareEffect and integrate custom logic for searchBlock to make it work with our implementation
8
-
9
- TODO:
10
- - Needs updating, it's quite different in the latest volto version
11
8
  */
12
9
  import React, { createRef, useEffect } from 'react';
13
10
  import hoistNonReactStatics from 'hoist-non-react-statics';
14
11
  import { getContent, getQueryStringResults } from '@plone/volto/actions';
15
12
  import { useDispatch, useSelector } from 'react-redux';
16
13
  import useDeepCompareEffect from 'use-deep-compare-effect';
17
- import { flattenToAppURL } from '@plone/volto/helpers';
14
+ import { flattenToAppURL, getBaseUrl } from '@plone/volto/helpers';
18
15
  import config from '@plone/volto/registry';
19
16
 
20
17
  import { setOriginalQuery } from 'design-comuni-plone-theme/actions';
@@ -57,15 +54,22 @@ const getAdaptedQuery = (querystring, b_size, variation) => {
57
54
 
58
55
  export default function withQuerystringResults(WrappedComponent) {
59
56
  function WithQuerystringResults(props) {
60
- const { data = {}, path, properties, isEditMode } = props; //properties: content,
57
+ const {
58
+ data = {},
59
+ id = data.block,
60
+ //properties: content,
61
+ properties,
62
+ path,
63
+ variation,
64
+ isEditMode,
65
+ } = props;
61
66
  const content = useSelector((state) => state.content.data);
62
67
  const { settings } = config;
63
68
  const querystring = data.querystring || data; // For backwards compat with data saved before Blocks schema
64
- const { block } = data;
65
69
  const { b_size = settings.defaultPageSize } = querystring;
66
70
  const [firstLoading, setFirstLoading] = React.useState(true);
67
71
  // save the path so it won't trigger dispatch on eager router location change
68
- const [initialPath] = React.useState(path);
72
+ const [initialPath] = React.useState(getBaseUrl(path));
69
73
 
70
74
  const [currentPage, setCurrentPage] = React.useState(1);
71
75
  const querystringResults = useSelector(
@@ -78,44 +82,44 @@ export default function withQuerystringResults(WrappedComponent) {
78
82
 
79
83
  const originalQuery = useSelector((state) => {
80
84
  if (props?.variation?.['@type'] === 'search') {
81
- return state.originalQuery?.[path]?.[data?.block];
85
+ return state.originalQuery?.[path]?.[id];
82
86
  }
83
- return state.originalQuery?.[properties['@id']]?.[
84
- data.block
85
- ]?.toArray?.();
87
+ return state.originalQuery?.[properties['@id']]?.[id]?.toArray?.();
86
88
  });
87
89
  const folderItems = content?.is_folderish ? content.items : [];
88
90
  const hasQuery = querystring?.query?.length > 0;
89
- const hasLoaded = hasQuery ? !querystringResults?.[block]?.loading : true;
91
+ const hasLoaded = hasQuery ? querystringResults?.[id]?.loaded : true;
90
92
  const loadingQuery =
91
- querystring?.query?.length > 0 &&
92
- (querystringResults?.[block]?.loading ||
93
- !querystringResults?.[block]?.loaded);
93
+ hasQuery &&
94
+ (querystringResults?.[id]?.loading || !querystringResults?.[id]?.loaded);
94
95
 
95
- const listingItems =
96
- hasQuery && querystringResults?.[block]
97
- ? querystringResults?.[block]?.items || []
98
- : folderItems;
96
+ const listingItems = hasQuery
97
+ ? querystringResults?.[id]?.items || []
98
+ : folderItems;
99
99
 
100
100
  const showAsFolderListing = !hasQuery && content?.items_total > b_size;
101
101
  const showAsQueryListing =
102
- hasQuery && querystringResults?.[block]?.total > b_size;
102
+ hasQuery && querystringResults?.[id]?.total > b_size;
103
103
 
104
104
  const itemsTotal = showAsFolderListing
105
105
  ? content.items_total
106
- : querystringResults?.[block]?.total;
106
+ : querystringResults?.[id]?.total;
107
107
 
108
- const totalPages = itemsTotal ? Math.ceil(itemsTotal / b_size) : 0;
108
+ const totalPages = showAsFolderListing
109
+ ? Math.ceil(content.items_total / b_size)
110
+ : showAsQueryListing
111
+ ? Math.ceil(querystringResults[id].total / b_size)
112
+ : 0;
109
113
 
110
114
  const prevBatch = showAsFolderListing
111
115
  ? content.batching?.prev
112
116
  : showAsQueryListing
113
- ? querystringResults[block].batching?.prev
117
+ ? querystringResults[id].batching?.prev
114
118
  : null;
115
119
  const nextBatch = showAsFolderListing
116
120
  ? content.batching?.next
117
121
  : showAsQueryListing
118
- ? querystringResults[block].batching?.next
122
+ ? querystringResults[id].batching?.next
119
123
  : null;
120
124
 
121
125
  function handleContentPaginationChange(e, { activePage }) {
@@ -159,19 +163,17 @@ export default function withQuerystringResults(WrappedComponent) {
159
163
  );
160
164
  }
161
165
 
166
+ if (firstLoading && querystringResults[id] && !loadingQuery) {
167
+ setFirstLoading(false);
168
+ }
162
169
  // eslint-disable-next-line react-hooks/exhaustive-deps
163
170
  }, []);
164
171
 
165
- if (firstLoading && querystringResults[block] && !loadingQuery) {
166
- setFirstLoading(false);
167
- }
168
-
169
172
  useDeepCompareEffect(() => {
170
173
  if (
171
- (hasQuery > 0 &&
172
- (isEditMode ||
173
- (!isEditMode && !querystringResults[block]?.loaded))) ||
174
- (hasQuery > 0 && props.variation?.['@type'] === 'search')
174
+ (hasQuery &&
175
+ (isEditMode || (!isEditMode && !querystringResults[id]?.loaded))) ||
176
+ (hasQuery && props.variation?.['@type'] === 'search')
175
177
  ) {
176
178
  doSearch(data);
177
179
  }
@@ -220,7 +222,7 @@ export default function withQuerystringResults(WrappedComponent) {
220
222
  getQueryStringResults(
221
223
  path,
222
224
  getAdaptedQuery(_querystring, b_size, data.variation),
223
- data.block,
225
+ id,
224
226
  page,
225
227
  ),
226
228
  );
@@ -234,6 +236,7 @@ export default function withQuerystringResults(WrappedComponent) {
234
236
  path,
235
237
  {
236
238
  ...getAdaptedQuery(_dataQuerystring, b_size, data.variation),
239
+ b_size: 10000000000,
237
240
  query: [
238
241
  {
239
242
  i: 'path',
@@ -242,8 +245,7 @@ export default function withQuerystringResults(WrappedComponent) {
242
245
  },
243
246
  ],
244
247
  },
245
- data.block,
246
- page,
248
+ id,
247
249
  ),
248
250
  );
249
251
  }
@@ -268,7 +270,7 @@ export default function withQuerystringResults(WrappedComponent) {
268
270
  ? handleContentPaginationChange(e, { activePage })
269
271
  : handleQueryPaginationChange(e, { activePage });
270
272
  }}
271
- total={querystringResults?.[block]?.total}
273
+ total={querystringResults?.[id]?.total}
272
274
  batch_size={b_size}
273
275
  currentPage={currentPage}
274
276
  totalPages={totalPages}
@@ -406,6 +406,11 @@ body.cms-ui {
406
406
  .public-DraftStyleDefault-block {
407
407
  margin-bottom: unset;
408
408
  }
409
+ // z-index necessario su Volto 17 finché non passiamo ad usare slate
410
+ .DraftEditor-editorContainer,
411
+ .public-DraftEditorPlaceholder-root {
412
+ z-index: 0;
413
+ }
409
414
  }
410
415
  }
411
416