design-comuni-plone-theme 11.31.2 → 11.32.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.
- package/.yarn/install-state.gz +0 -0
- package/CHANGELOG.md +41 -0
- package/RELEASE.md +22 -0
- package/locales/de/LC_MESSAGES/volto.po +41 -0
- package/locales/en/LC_MESSAGES/volto.po +41 -0
- package/locales/es/LC_MESSAGES/volto.po +41 -0
- package/locales/fr/LC_MESSAGES/volto.po +41 -0
- package/locales/it/LC_MESSAGES/volto.po +41 -0
- package/locales/volto.pot +42 -1
- package/package.json +1 -1
- package/publiccode.yml +2 -2
- package/src/actions/getCTSchema.js +13 -0
- package/src/actions/index.js +3 -0
- package/src/components/ItaliaTheme/Blocks/Common/SearchFilters/DateFilter.jsx +27 -2
- package/src/components/ItaliaTheme/Blocks/Listing/CardWithImage/CardWithImageDefault.jsx +2 -4
- package/src/components/ItaliaTheme/Blocks/Listing/Commons/ListingImage.jsx +1 -1
- package/src/components/ItaliaTheme/Blocks/Listing/TableTemplate.jsx +163 -0
- package/src/components/ItaliaTheme/Blocks/Listing/TemplatesSkeletons/TableTemplateSkeleton.jsx +50 -0
- package/src/components/ItaliaTheme/View/Commons/SideMenu.jsx +2 -1
- package/src/components/ItaliaTheme/View/Commons/SideMenuByTitles.jsx +16 -8
- package/src/components/ItaliaTheme/index.js +5 -0
- package/src/components/ItaliaTheme/manage/Widgets/BlocksViewWidget.jsx +7 -0
- package/src/components/ItaliaTheme/manage/Widgets/CTFieldsWidget.jsx +84 -0
- package/src/components/ItaliaTheme/manage/Widgets/CTTitleColumnWidget.jsx +22 -0
- package/src/components/ItaliaTheme/manage/Widgets/DataGridWidget.jsx +26 -0
- package/src/components/ItaliaTheme/manage/Widgets/PDCViewWidget.jsx +21 -0
- package/src/config/Blocks/ListingOptions/index.js +1 -0
- package/src/config/Blocks/ListingOptions/tableTemplate.js +105 -0
- package/src/config/Blocks/listingVariations.js +18 -0
- package/src/config/Widgets/widgets.js +24 -1
- package/src/customizations/volto/helpers/Html/Html.jsx +28 -14
- package/src/helpers/getWidgetView.js +112 -0
- package/src/helpers/index.js +1 -0
- package/src/reducers/ctSchema.js +80 -0
- package/src/reducers/index.js +2 -0
- package/src/theme/ItaliaTheme/Blocks/_completeBlockLinkstemplate.scss +5 -8
- package/src/theme/ItaliaTheme/Blocks/_listing.scss +18 -0
- package/src/theme/ItaliaTheme/Blocks/_smallblockLinkstemplate.scss +1 -0
- package/src/theme/ItaliaTheme/Blocks/_tableTemplate.scss +46 -0
- package/src/theme/site.scss +1 -0
|
@@ -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;
|
package/src/components/ItaliaTheme/Blocks/Listing/TemplatesSkeletons/TableTemplateSkeleton.jsx
ADDED
|
@@ -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;
|
|
@@ -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
|
|
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
|
-
<
|
|
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;
|
|
@@ -23,3 +23,4 @@ export { addCardWithSlideUpTextTemplateOptions } from 'design-comuni-plone-theme
|
|
|
23
23
|
export { addPhotogalleryTemplateOptions } from 'design-comuni-plone-theme/config/Blocks/ListingOptions/photogalleryTemplate';
|
|
24
24
|
export { addSmallBlockLinksTemplateOptions } from 'design-comuni-plone-theme/config/Blocks/ListingOptions/smallBlockLinksTemplate';
|
|
25
25
|
export { addAttachmentCardTemplateOptions } from 'design-comuni-plone-theme/config/Blocks/ListingOptions/attachmentCardTemplate';
|
|
26
|
+
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
|
+
};
|
|
@@ -47,6 +47,8 @@ import CardWithSlideUpTextTemplateSkeleton from 'design-comuni-plone-theme/compo
|
|
|
47
47
|
|
|
48
48
|
import AttachmentCardTemplate from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/Listing/AttachmentCardTemplate';
|
|
49
49
|
|
|
50
|
+
import TableTemplate from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/Listing/TableTemplate.jsx';
|
|
51
|
+
import TableTemplateSkeleton from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/Listing/TemplatesSkeletons/TableTemplateSkeleton';
|
|
50
52
|
// import AmministrazioneTrasparenteTablesTemplate from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/Listing/AmministrazioneTrasparenteTablesTemplate';
|
|
51
53
|
// import AmministrazioneTrasparenteTablesTemplateSkeleton from 'design-comuni-plone-theme/components/ItaliaTheme/Blocks/Listing/TemplatesSkeletons/AmministrazioneTrasparenteTablesTemplateSkeleton';
|
|
52
54
|
|
|
@@ -67,6 +69,7 @@ import {
|
|
|
67
69
|
addSmallBlockLinksTemplateOptions,
|
|
68
70
|
addAttachmentCardTemplateOptions,
|
|
69
71
|
cloneBlock,
|
|
72
|
+
addTableTemplateOptions,
|
|
70
73
|
} from 'design-comuni-plone-theme/config/Blocks/ListingOptions';
|
|
71
74
|
|
|
72
75
|
import { addLighthouseField } from 'design-comuni-plone-theme/config/Blocks/ListingOptions/utils';
|
|
@@ -293,6 +296,21 @@ const italiaListingVariations = [
|
|
|
293
296
|
},
|
|
294
297
|
cloneData: cloneBlock,
|
|
295
298
|
},
|
|
299
|
+
{
|
|
300
|
+
id: 'table',
|
|
301
|
+
isDefault: false,
|
|
302
|
+
title: 'Tabella',
|
|
303
|
+
template: TableTemplate,
|
|
304
|
+
skeleton: TableTemplateSkeleton,
|
|
305
|
+
schemaEnhancer: ({ schema, formData, intl }) => {
|
|
306
|
+
let pos = addDefaultOptions(schema, formData, intl);
|
|
307
|
+
addTableTemplateOptions(schema, formData, intl, pos);
|
|
308
|
+
addLinkMoreOptions(schema, formData, intl);
|
|
309
|
+
return schema;
|
|
310
|
+
},
|
|
311
|
+
fullobjects: true,
|
|
312
|
+
cloneData: cloneBlock,
|
|
313
|
+
},
|
|
296
314
|
// {
|
|
297
315
|
// id: 'amministrazioneTrasparenteTablesTemplate',
|
|
298
316
|
// isDefault: false,
|
|
@@ -10,12 +10,20 @@ import MenuConfigurationForm from 'design-comuni-plone-theme/components/ItaliaTh
|
|
|
10
10
|
import SecondaryMenuConfigurationForm from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/SecondaryMenuConfigurationForm';
|
|
11
11
|
import SubFooterConfigurationForm from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/SubFooterConfigurationForm';
|
|
12
12
|
import SearchSectionsConfigurationWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/SearchSectionsConfigurationWidget/SearchSectionsConfigurationWidget';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
defaultIconWidgetOptions,
|
|
15
|
+
getWidgetView,
|
|
16
|
+
} from 'design-comuni-plone-theme/helpers';
|
|
14
17
|
import {
|
|
15
18
|
ColorListWidget,
|
|
16
19
|
PathFiltersWidget,
|
|
17
20
|
LocationFiltersWidget,
|
|
18
21
|
CanaleDigitaleWidget,
|
|
22
|
+
CTFieldsWidget,
|
|
23
|
+
CTTitleColumnWidget,
|
|
24
|
+
BlocksViewWidget,
|
|
25
|
+
PDCViewWidget,
|
|
26
|
+
DataGridWidget,
|
|
19
27
|
} from 'design-comuni-plone-theme/components/ItaliaTheme';
|
|
20
28
|
import LuoghiCorrelatiEventoWidget from 'design-comuni-plone-theme/components/ItaliaTheme/manage/Widgets/LuoghiCorrelatiEventoWidget';
|
|
21
29
|
|
|
@@ -88,6 +96,21 @@ const getItaliaWidgets = (config) => {
|
|
|
88
96
|
path_filters: PathFiltersWidget,
|
|
89
97
|
location_filter: LocationFiltersWidget,
|
|
90
98
|
luoghi_correlati_evento: LuoghiCorrelatiEventoWidget,
|
|
99
|
+
ct_fields: CTFieldsWidget,
|
|
100
|
+
ct_title_column: CTTitleColumnWidget,
|
|
101
|
+
},
|
|
102
|
+
views: {
|
|
103
|
+
...config.widgets.views,
|
|
104
|
+
getWidget: getWidgetView,
|
|
105
|
+
widget: {
|
|
106
|
+
...config.widgets.views.widget,
|
|
107
|
+
blocks: BlocksViewWidget,
|
|
108
|
+
data_grid: DataGridWidget,
|
|
109
|
+
},
|
|
110
|
+
id: {
|
|
111
|
+
...config.widgets.views.id,
|
|
112
|
+
value_punto_contatto: PDCViewWidget,
|
|
113
|
+
},
|
|
91
114
|
},
|
|
92
115
|
};
|
|
93
116
|
};
|