design-comuni-plone-theme 12.2.3 → 12.3.1

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 (52) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/CHANGELOG.md +43 -0
  3. package/RELEASE.md +22 -0
  4. package/locales/de/LC_MESSAGES/volto.po +41 -0
  5. package/locales/en/LC_MESSAGES/volto.po +41 -0
  6. package/locales/es/LC_MESSAGES/volto.po +41 -0
  7. package/locales/fr/LC_MESSAGES/volto.po +41 -0
  8. package/locales/it/LC_MESSAGES/volto.po +41 -0
  9. package/locales/volto.pot +42 -1
  10. package/package.json +1 -1
  11. package/publiccode.yml +2 -2
  12. package/src/actions/getCTSchema.js +13 -0
  13. package/src/actions/index.js +3 -0
  14. package/src/components/ItaliaTheme/Blocks/Common/SearchFilters/DateFilter.jsx +27 -2
  15. package/src/components/ItaliaTheme/Blocks/Listing/BandiInEvidenceTemplate.jsx +1 -1
  16. package/src/components/ItaliaTheme/Blocks/Listing/CardWithImage/CardWithImageDefault.jsx +9 -8
  17. package/src/components/ItaliaTheme/Blocks/Listing/CardWithSlideUpTextTemplate.jsx +9 -6
  18. package/src/components/ItaliaTheme/Blocks/Listing/Commons/ListingImage.jsx +3 -4
  19. package/src/components/ItaliaTheme/Blocks/Listing/CompleteBlockLinksTemplate.jsx +6 -1
  20. package/src/components/ItaliaTheme/Blocks/Listing/InEvidenceTemplate.jsx +5 -4
  21. package/src/components/ItaliaTheme/Blocks/Listing/RibbonCardTemplate.jsx +5 -4
  22. package/src/components/ItaliaTheme/Blocks/Listing/SimpleCard/Card/SimpleCardDefault.jsx +6 -4
  23. package/src/components/ItaliaTheme/Blocks/Listing/SimpleCard/SimpleCardTemplateCompact.jsx +6 -1
  24. package/src/components/ItaliaTheme/Blocks/Listing/SimpleCard/SimpleCardTemplateOneForRow.jsx +6 -1
  25. package/src/components/ItaliaTheme/Blocks/Listing/TableTemplate.jsx +163 -0
  26. package/src/components/ItaliaTheme/Blocks/Listing/TemplatesSkeletons/TableTemplateSkeleton.jsx +50 -0
  27. package/src/components/ItaliaTheme/Blocks/TextCard/SimpleCard/Edit.jsx +1 -1
  28. package/src/components/ItaliaTheme/Blocks/TextCard/SimpleCard/View.jsx +1 -1
  29. package/src/components/ItaliaTheme/View/Commons/SideMenu.jsx +2 -1
  30. package/src/components/ItaliaTheme/View/Commons/SideMenuByTitles.jsx +16 -8
  31. package/src/components/ItaliaTheme/index.js +5 -0
  32. package/src/components/ItaliaTheme/manage/Widgets/BlocksViewWidget.jsx +7 -0
  33. package/src/components/ItaliaTheme/manage/Widgets/CTFieldsWidget.jsx +84 -0
  34. package/src/components/ItaliaTheme/manage/Widgets/CTTitleColumnWidget.jsx +22 -0
  35. package/src/components/ItaliaTheme/manage/Widgets/DataGridWidget.jsx +26 -0
  36. package/src/components/ItaliaTheme/manage/Widgets/PDCViewWidget.jsx +21 -0
  37. package/src/config/Blocks/ListingOptions/index.js +1 -0
  38. package/src/config/Blocks/ListingOptions/tableTemplate.js +105 -0
  39. package/src/config/Blocks/listingVariations.js +18 -0
  40. package/src/config/Slate/Link/deserializer.js +5 -1
  41. package/src/config/Widgets/widgets.js +24 -1
  42. package/src/customizations/volto/helpers/Html/Html.jsx +28 -14
  43. package/src/helpers/getWidgetView.js +112 -0
  44. package/src/helpers/index.js +1 -0
  45. package/src/reducers/ctSchema.js +80 -0
  46. package/src/reducers/index.js +2 -0
  47. package/src/theme/ItaliaTheme/Blocks/_completeBlockLinkstemplate.scss +5 -8
  48. package/src/theme/ItaliaTheme/Blocks/_listing.scss +18 -0
  49. package/src/theme/ItaliaTheme/Blocks/_smallblockLinkstemplate.scss +1 -0
  50. package/src/theme/ItaliaTheme/Blocks/_tableTemplate.scss +46 -0
  51. package/src/theme/ItaliaTheme/Components/_card.scss +1 -1
  52. package/src/theme/site.scss +1 -0
@@ -140,10 +140,11 @@ const RibbonCardTemplate = (props) => {
140
140
  >
141
141
  {date && <div className="dates">{date}</div>}
142
142
  <CardTitle
143
- tag="h3"
144
- className={`${
145
- isEventAppointment ? 'rassegna-appointment-title' : ''
146
- }`}
143
+ tag={title ? 'h3' : 'h2'}
144
+ className={cx('', {
145
+ 'rassegna-appointment-title': isEventAppointment,
146
+ h3: !title,
147
+ })}
147
148
  >
148
149
  <UniversalLink
149
150
  item={!isEditMode ? item : null}
@@ -58,6 +58,7 @@ const SimpleCardDefault = (props) => {
58
58
  id_lighthouse,
59
59
  rrule,
60
60
  index,
61
+ title,
61
62
  } = props;
62
63
 
63
64
  const getItemClass = (item) => {
@@ -123,10 +124,11 @@ const SimpleCardDefault = (props) => {
123
124
  </CardCategory>
124
125
  )}
125
126
  <CardTitle
126
- tag="h3"
127
- className={`${
128
- isEventAppointment ? 'rassegna-appointment-title' : ''
129
- }`}
127
+ tag={title ? 'h3' : 'h2'}
128
+ className={cx('', {
129
+ 'rassegna-appointment-title': isEventAppointment,
130
+ h3: !title,
131
+ })}
130
132
  >
131
133
  <UniversalLink
132
134
  item={!isEditMode ? item : null}
@@ -67,7 +67,12 @@ const SimpleCardTemplateCompact = ({
67
67
  </div>
68
68
  )}
69
69
  <CardBody>
70
- <CardTitle tag="h3">
70
+ <CardTitle
71
+ tag={title ? 'h3' : 'h2'}
72
+ className={cx('', {
73
+ h3: !title,
74
+ })}
75
+ >
71
76
  <UniversalLink
72
77
  item={!isEditMode ? item : null}
73
78
  href={isEditMode ? '#' : null}
@@ -218,7 +218,12 @@ const SimpleCardTemplateDefaultOneForRow = (props) => {
218
218
  )}
219
219
  </CardCategory>
220
220
  )}
221
- <CardTitle tag="h3">
221
+ <CardTitle
222
+ tag={title ? 'h3' : 'h2'}
223
+ className={cx('', {
224
+ h3: !title,
225
+ })}
226
+ >
222
227
  <UniversalLink
223
228
  item={!isEditMode ? item : null}
224
229
  href={isEditMode ? '#' : null}
@@ -0,0 +1,163 @@
1
+ /*
2
+ * Template a tabella
3
+ */
4
+ import React, { useEffect } from 'react';
5
+ import cx from 'classnames';
6
+ import PropTypes from 'prop-types';
7
+ import { useDispatch, useSelector } from 'react-redux';
8
+ import { useIntl, defineMessages } from 'react-intl';
9
+ import { getCTSchema } from 'design-comuni-plone-theme/actions';
10
+ import { Table, Container } from 'design-react-kit';
11
+ import UniversalLink from '@plone/volto/components/manage/UniversalLink/UniversalLink';
12
+
13
+ import { ListingLinkMore } from 'design-comuni-plone-theme/components/ItaliaTheme';
14
+ import { getWidget } from '@plone/volto/helpers/Widget/utils';
15
+
16
+ import config from '@plone/volto/registry';
17
+
18
+ const messages = defineMessages({
19
+ title: { id: 'tabletemplate_column_title', defaultMessage: 'Titolo' },
20
+ });
21
+
22
+ const TableTemplate = (props) => {
23
+ const {
24
+ columns,
25
+ alternate_rows,
26
+ items,
27
+ isEditMode,
28
+ linkAlign,
29
+ linkTitle,
30
+ linkHref,
31
+ linkmore_id_lighthouse,
32
+ } = props;
33
+
34
+ const intl = useIntl();
35
+ const { views } = config.widgets;
36
+
37
+ // necessario per gli edditor nel momento in cui aggiungono nuove colonne
38
+ const ct_schema = useSelector((state) => state.ct_schema?.subrequests);
39
+
40
+ let render_columns =
41
+ (columns ?? []).filter((c) => c.field === 'title').length > 0
42
+ ? columns
43
+ : [
44
+ { field: 'title', title: intl.formatMessage(messages.title) },
45
+ ...(columns ?? []),
46
+ ];
47
+ return (
48
+ <div className="table-template">
49
+ <Container className="px-4 pt-3">
50
+ <Table size="sm" responsive bordered striped={alternate_rows ?? false}>
51
+ <thead className="table-light">
52
+ <tr>
53
+ {render_columns.map((c, index) => {
54
+ const field_properties =
55
+ c.field_properties ??
56
+ ct_schema?.[c.ct]?.result?.properties?.[c.field] ??
57
+ {};
58
+
59
+ return (
60
+ <th
61
+ scope="col"
62
+ className={cx(c.ct + '-' + c.field, {
63
+ 'date-column':
64
+ field_properties.widget === 'date' ||
65
+ field_properties.widget === 'datetime',
66
+ })}
67
+ key={index}
68
+ >
69
+ {c.title}
70
+ </th>
71
+ );
72
+ })}
73
+ </tr>
74
+ </thead>
75
+ <tbody>
76
+ {items.map((item, index) => (
77
+ <tr key={index}>
78
+ {render_columns.map((c, index) => {
79
+ const field_properties =
80
+ c.field_properties ??
81
+ ct_schema?.[c.ct]?.result?.properties?.[c.field] ??
82
+ {};
83
+ let render_value = JSON.stringify(item[c.field]);
84
+
85
+ if (field_properties) {
86
+ const field = {
87
+ ...field_properties,
88
+ id: c.field,
89
+ widget: getWidget(c.field, field_properties),
90
+ };
91
+ const Widget = views?.getWidget(field);
92
+
93
+ const widget_props = {
94
+ behavior: field_properties.behavior,
95
+ };
96
+ switch (c.field) {
97
+ case 'apertura_bando':
98
+ case 'chiusura_procedimento_bando':
99
+ case 'scadenza_domande_bando':
100
+ case 'scadenza_bando':
101
+ widget_props.format = 'DD MMM yyyy';
102
+ break;
103
+ default:
104
+ break;
105
+ }
106
+ // rimuove ora, se non valorizzata
107
+ if (
108
+ field_properties.widget === 'datetime' &&
109
+ c.field !== 'whole_day' &&
110
+ c.field !== 'open_end' &&
111
+ item?.[c.field]?.indexOf('T00:00') > 0
112
+ ) {
113
+ widget_props.format = 'DD MMM yyyy';
114
+ }
115
+ if (field_properties.vocabulary) {
116
+ widget_props.vocabulary =
117
+ field_properties.vocabulary['@id'];
118
+ }
119
+ render_value = (
120
+ <Widget value={item[c.field]} {...widget_props} />
121
+ );
122
+ }
123
+ if (c.field === 'title') {
124
+ render_value = (
125
+ <UniversalLink
126
+ item={!isEditMode ? item : null}
127
+ href={isEditMode ? '#' : ''}
128
+ className="img-link"
129
+ >
130
+ {item[c.field]}
131
+ </UniversalLink>
132
+ );
133
+ }
134
+
135
+ // return <td key={index}>ciao</td>;
136
+ return <td key={index}>{render_value}</td>;
137
+ })}
138
+ </tr>
139
+ ))}
140
+ </tbody>
141
+ </Table>
142
+
143
+ <ListingLinkMore
144
+ title={linkTitle}
145
+ href={linkHref}
146
+ linkAlign={linkAlign}
147
+ className="my-4"
148
+ linkmoreIdLighthouse={linkmore_id_lighthouse}
149
+ />
150
+ </Container>
151
+ </div>
152
+ );
153
+ };
154
+
155
+ TableTemplate.propTypes = {
156
+ items: PropTypes.arrayOf(PropTypes.any).isRequired,
157
+ linkTitle: PropTypes.any,
158
+ linkHref: PropTypes.any,
159
+ isEditMode: PropTypes.bool,
160
+ title: PropTypes.string,
161
+ };
162
+
163
+ export default TableTemplate;
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import { Row, Col, Table, Container } from 'design-react-kit';
4
+
5
+ const SimpleListTemplateSkeleton = (props) => {
6
+ const { title, linkHref } = props;
7
+ return (
8
+ <div className="table-skeleton-template">
9
+ <Container className="px-4">
10
+ <div className="skeleton-template">
11
+ {title && (
12
+ <Row>
13
+ <Col>
14
+ <h2 className="mb-4">{title}</h2>
15
+ </Col>
16
+ </Row>
17
+ )}
18
+
19
+ <Table size="sm" responsive bordered>
20
+ <thead>
21
+ <tr>
22
+ {[0, 1, 2, 3, 4].map((i) => (
23
+ <th scope="col" key={i}></th>
24
+ ))}
25
+ </tr>
26
+ </thead>
27
+ <tbody>
28
+ {[0, 1, 2, 3, 4, 5, 6].map((i) => (
29
+ <tr key={i}>
30
+ {[0, 1, 2, 3, 4].map((i) => (
31
+ <td key={i}></td>
32
+ ))}
33
+ </tr>
34
+ ))}
35
+ </tbody>
36
+ </Table>
37
+ {linkHref && <div className="link-button text-center my-5"></div>}
38
+ </div>
39
+ </Container>
40
+ </div>
41
+ );
42
+ };
43
+
44
+ SimpleListTemplateSkeleton.propTypes = {
45
+ linkHref: PropTypes.any,
46
+ isEditMode: PropTypes.bool,
47
+ title: PropTypes.string,
48
+ };
49
+
50
+ export default SimpleListTemplateSkeleton;
@@ -55,7 +55,7 @@ const Edit = (props) => {
55
55
  >
56
56
  <CardBody>
57
57
  <div className="simple-text-card cms-ui">
58
- <CardTitle tag="h3" className="h4">
58
+ <CardTitle tag="h2" className="h4">
59
59
  <TextEditorWidget
60
60
  {...otherProps}
61
61
  showToolbar={false}
@@ -27,7 +27,7 @@ const TextCardView = ({ data, id, block }) => {
27
27
  tag="div"
28
28
  >
29
29
  <CardBody>
30
- <CardTitle tag="h3" className="h4" id={id + '-title'}>
30
+ <CardTitle tag="h2" className="h4" id={id + '-title'}>
31
31
  {data.simple_card_title}
32
32
  </CardTitle>
33
33
  <hr />
@@ -176,7 +176,8 @@ const SideMenu = ({ data, content_uid }) => {
176
176
  <div className="mb-3">
177
177
  <Progress
178
178
  value={progressValue > 0 ? 100 * progressValue : 0}
179
- role="progressbar"
179
+ role="progressbar"
180
+ aria-labelledby={`item-${activeSection}`}
180
181
  />
181
182
  </div>
182
183
  <AccordionBody active={isNavOpen} id="side-menu-body">
@@ -20,11 +20,16 @@ const messages = defineMessages({
20
20
  id: 'index',
21
21
  defaultMessage: 'Indice della pagina',
22
22
  },
23
+ sideMenuNavigation: {
24
+ id: 'sideMenuNavigation',
25
+ defaultMessage: 'Navigazione della pagina',
26
+ },
23
27
  });
24
28
 
25
29
  const extractHeaders = (elements, intl) => {
26
30
  let item;
27
31
  let headers = [];
32
+
28
33
  for (var index = 0; index < elements.length; index++) {
29
34
  item = elements[index];
30
35
 
@@ -140,7 +145,10 @@ const SideMenuByTitles = ({ data, content_uid, index_title }) => {
140
145
 
141
146
  return headers?.length > 0 ? (
142
147
  <div className="sticky-wrapper navbar-wrapper page-side-menu">
143
- <nav className="navbar it-navscroll-wrapper navbar-expand-lg">
148
+ <nav
149
+ className="navbar it-navscroll-wrapper navbar-expand-lg"
150
+ aria-label={intl.formatMessage(messages.sideMenuNavigation)}
151
+ >
144
152
  <div className="menu-wrapper">
145
153
  <div className="link-list-wrapper menu-link-list">
146
154
  <div className="accordion-wrapper">
@@ -151,20 +159,20 @@ const SideMenuByTitles = ({ data, content_uid, index_title }) => {
151
159
  setIsNavOpen(!isNavOpen);
152
160
  }}
153
161
  aria-controls="side-menu-body"
162
+ aria-expanded={isNavOpen}
154
163
  >
155
- <h3>{index_title ?? intl.formatMessage(messages.index)}</h3>
164
+ <h2 className="h3">
165
+ {index_title ?? intl.formatMessage(messages.index)}
166
+ </h2>
156
167
  </AccordionHeader>
157
168
  <div className="mb-3">
158
169
  <Progress
159
170
  value={progressValue > 0 ? 100 * progressValue : 0}
160
- role="progressbar"
171
+ role="progressbar"
172
+ aria-labelledby={`item-${activeSection}`}
161
173
  />
162
174
  </div>
163
- <AccordionBody
164
- active={isNavOpen}
165
- id="side-menu-body"
166
- role="region"
167
- >
175
+ <AccordionBody active={isNavOpen} id="side-menu-body">
168
176
  <ul className="link-list" data-element="page-index">
169
177
  {headers.map((item, i) => {
170
178
  return (
@@ -17,6 +17,11 @@ export FileWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/
17
17
  export PathFiltersWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/PathFiltersWidget';
18
18
  export LocationFiltersWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/LocationFiltersWidget';
19
19
  export CanaleDigitaleWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/CanaleDigitaleWidget';
20
+ export CTFieldsWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/CTFieldsWidget';
21
+ export CTTitleColumnWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/CTTitleColumnWidget';
22
+ export BlocksViewWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/BlocksViewWidget.jsx';
23
+ export PDCViewWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/PDCViewWidget.jsx';
24
+ export DataGridWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/DataGridWidget.jsx';
20
25
 
21
26
  /********* ICONS ********* */
22
27
  export getItemIcon from 'design-comuni-plone-theme/components/ItaliaTheme/Icons/common/common';
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { RichTextRender } from 'design-comuni-plone-theme/components/ItaliaTheme/View';
3
+ const BlocksViewWidget = ({ value, children, className }) => {
4
+ return <RichTextRender data={value} add_class={className} serif={false} />;
5
+ };
6
+
7
+ export default BlocksViewWidget;
@@ -0,0 +1,84 @@
1
+ import React, { useEffect } from 'react';
2
+ import { useIntl } from 'react-intl';
3
+ import { useDispatch, useSelector } from 'react-redux';
4
+ import { getCTSchema } from 'design-comuni-plone-theme/actions';
5
+ import { injectLazyLibs } from '@plone/volto/helpers/Loadable/Loadable';
6
+ import FormFieldWrapper from '@plone/volto/components/manage/Widgets/FormFieldWrapper';
7
+ import { normalizeValue } from '@plone/volto/components/manage/Widgets/SelectUtils';
8
+
9
+ import {
10
+ Option,
11
+ DropdownIndicator,
12
+ selectTheme,
13
+ customSelectStyles,
14
+ } from '@plone/volto/components/manage/Widgets/SelectStyling';
15
+
16
+ const CTFieldsWidget = ({ ct, reactSelect, value, ...props }) => {
17
+ const intl = useIntl();
18
+ const dispatch = useDispatch();
19
+ const Select = reactSelect.default;
20
+ const exclude_fieldsets = ['ownership', 'seo', 'settings'];
21
+ const ct_schema = useSelector(
22
+ (state) => state.ct_schema?.subrequests?.[ct]?.result,
23
+ );
24
+
25
+ useEffect(() => {
26
+ if (!ct_schema) {
27
+ dispatch(getCTSchema(ct));
28
+ }
29
+ }, [ct, ct_schema, dispatch]);
30
+
31
+ const groups_choices =
32
+ ct_schema?.fieldsets
33
+ ?.filter((fieldset) => exclude_fieldsets.indexOf(fieldset.id) < 0)
34
+ .map((fieldset) => {
35
+ return {
36
+ label: fieldset.title,
37
+ options: fieldset.fields.map((f) => {
38
+ return {
39
+ value: f,
40
+ label: ct_schema.properties[f].title,
41
+ };
42
+ }),
43
+ };
44
+ }) ?? [];
45
+
46
+ const disabled = props.disabled || props.isDisabled;
47
+ const normalizedValue = normalizeValue(
48
+ groups_choices.reduce((acc, fieldset) => {
49
+ return [...acc, ...fieldset.options];
50
+ }, []),
51
+ value,
52
+ intl,
53
+ );
54
+
55
+ return groups_choices?.length > 0 ? (
56
+ <FormFieldWrapper {...props}>
57
+ <Select
58
+ id={`field-${props.id}`}
59
+ name={props.id}
60
+ disabled={disabled}
61
+ className="react-select-container"
62
+ classNamePrefix="react-select"
63
+ placeholder={props.placeholder ?? 'Seleziona un valore'}
64
+ options={groups_choices}
65
+ styles={customSelectStyles}
66
+ theme={selectTheme}
67
+ components={{ DropdownIndicator, Option }}
68
+ value={normalizedValue}
69
+ onChange={(selectedOption) => {
70
+ props.onChange(
71
+ props.id,
72
+ selectedOption && selectedOption.value !== 'no-value'
73
+ ? selectedOption.value
74
+ : undefined,
75
+ );
76
+ }}
77
+ />
78
+ </FormFieldWrapper>
79
+ ) : (
80
+ <></>
81
+ );
82
+ };
83
+
84
+ export default injectLazyLibs('reactSelect')(CTFieldsWidget);
@@ -0,0 +1,22 @@
1
+ import React, { useEffect } from 'react';
2
+ import { useSelector } from 'react-redux';
3
+ import { TextWidget } from '@plone/volto/components';
4
+
5
+ const CTTitleColumnWidget = (props) => {
6
+ const { onChange, id } = props;
7
+ const { ct, field } = props.objectvalue;
8
+ const ct_schema = useSelector(
9
+ (state) => state.ct_schema?.subrequests?.[ct]?.result,
10
+ );
11
+
12
+ useEffect(() => {
13
+ const field_label = ct_schema?.properties?.[field]?.title;
14
+ if (field_label) {
15
+ onChange(id, field_label);
16
+ }
17
+ }, [field]);
18
+
19
+ return <TextWidget {...props} className="text" />;
20
+ };
21
+
22
+ export default CTTitleColumnWidget;
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import cx from 'classnames';
3
+
4
+ const DataGridWidget = ({ value, children, className }) => {
5
+ return value ? (
6
+ <span className={cx(className, 'array', 'widget')}>
7
+ {value.map((item, key) =>
8
+ Object.keys(item).length > 0 ? (
9
+ <div>
10
+ {Object.keys(item).map((el) => (
11
+ <div>
12
+ <span className="fw-bold">{el}</span>: <span>{item[el]}</span>
13
+ </div>
14
+ ))}
15
+ </div>
16
+ ) : (
17
+ <></>
18
+ ),
19
+ )}
20
+ </span>
21
+ ) : (
22
+ ''
23
+ );
24
+ };
25
+
26
+ export default DataGridWidget;
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { useIntl } from 'react-intl';
3
+ import { renderPDCItemValue } from 'design-comuni-plone-theme/helpers';
4
+ const PDCViewWidget = ({ value }) => {
5
+ const intl = useIntl();
6
+
7
+ return (
8
+ <div className="d-flex flex-column">
9
+ {value
10
+ ? value.map((pdc) => (
11
+ <div>
12
+ <span className="me-2">{pdc.pdc_desc}</span>
13
+ <span>{renderPDCItemValue(pdc, intl)}</span>
14
+ </div>
15
+ ))
16
+ : null}
17
+ </div>
18
+ );
19
+ };
20
+
21
+ export default PDCViewWidget;
@@ -22,3 +22,4 @@ export { addCardWithSlideUpTextTemplateOptions } from 'design-comuni-plone-theme
22
22
  export { addPhotogalleryTemplateOptions } from 'design-comuni-plone-theme/config/Blocks/ListingOptions/photogalleryTemplate';
23
23
  export { addSmallBlockLinksTemplateOptions } from 'design-comuni-plone-theme/config/Blocks/ListingOptions/smallBlockLinksTemplate';
24
24
  export { addAttachmentCardTemplateOptions } from 'design-comuni-plone-theme/config/Blocks/ListingOptions/attachmentCardTemplate';
25
+ export { addTableTemplateOptions } from 'design-comuni-plone-theme/config/Blocks/ListingOptions/tableTemplate';
@@ -0,0 +1,105 @@
1
+ import { defineMessages } from 'react-intl';
2
+ import cloneDeep from 'lodash/cloneDeep';
3
+
4
+ import { addSchemaField } from 'design-comuni-plone-theme/config/Blocks/ListingOptions';
5
+
6
+ const messages = defineMessages({
7
+ columns: {
8
+ id: 'table_variation_columns',
9
+ defaultMessage: 'Colonne della tabella',
10
+ },
11
+ alternate_rows: {
12
+ id: 'table_variation_alternate_rows',
13
+ defaultMessage: 'Colore delle righe alternato',
14
+ },
15
+ column: {
16
+ id: 'table_variaton_column',
17
+ defaultMessage: 'Colonna',
18
+ },
19
+ ct: { id: 'table_variaton_ct', defaultMessage: 'Tipo di contenuto' },
20
+ field: { id: 'table_variaton_field', defaultMessage: 'Campo' },
21
+ title: {
22
+ id: 'table_variaton_title',
23
+ defaultMessage: 'Titolo',
24
+ },
25
+ title_description: {
26
+ id: 'table_variaton_title_description',
27
+ defaultMessage:
28
+ 'Titolo della colonna. Se vuoi, puoi modificare il titolo di default.',
29
+ },
30
+ //sortable: { id: 'table_variaton_sortable', defaultMessage: 'Ordinabile' },
31
+ });
32
+
33
+ const ColumnSchema = ({ intl }) => ({
34
+ title: intl.formatMessage(messages.column),
35
+ fieldsets: [
36
+ {
37
+ id: 'default',
38
+ title: 'Default',
39
+ fields: ['ct' /*'field', 'title', 'sortable'*/], //questi campi commentati vengono aggiunti solo quando è valorizzato il campo ct
40
+ },
41
+ ],
42
+ properties: {
43
+ ct: {
44
+ title: intl.formatMessage(messages.ct),
45
+ vocabulary: {
46
+ '@id': 'plone.app.vocabularies.ReallyUserFriendlyTypes',
47
+ },
48
+ },
49
+ field: {
50
+ title: intl.formatMessage(messages.field),
51
+ widget: 'ct_fields',
52
+ },
53
+ title: {
54
+ title: intl.formatMessage(messages.title),
55
+ description: intl.formatMessage(messages.title_description),
56
+ widget: 'ct_title_column',
57
+ },
58
+ // sortable: {
59
+ // title: intl.formatMessage(messages.sortable),
60
+ // type: 'boolean',
61
+ // },
62
+ },
63
+ });
64
+
65
+ export const addTableTemplateOptions = (
66
+ schema,
67
+ formData,
68
+ intl,
69
+ position = 1,
70
+ ) => {
71
+ let pos = position;
72
+
73
+ addSchemaField(
74
+ schema,
75
+ 'alternate_rows',
76
+ intl.formatMessage(messages.alternate_rows),
77
+ null,
78
+ { type: 'boolean', default: true },
79
+ pos,
80
+ );
81
+ pos++;
82
+
83
+ addSchemaField(
84
+ schema,
85
+ 'columns',
86
+ intl.formatMessage(messages.columns),
87
+ null,
88
+ {
89
+ widget: 'object_list',
90
+ schema: ColumnSchema({ intl }),
91
+ schemaExtender: (schema, data, intl) => {
92
+ const mutated = cloneDeep(schema);
93
+ if (data.ct) {
94
+ mutated.fieldsets[0].fields.push('field', 'title' /*, 'sortable'*/);
95
+ mutated.properties.field.ct = data.ct;
96
+ }
97
+ return mutated;
98
+ },
99
+ },
100
+ pos,
101
+ );
102
+ pos++;
103
+
104
+ return pos;
105
+ };