From dc691081d050a18eee8984096b2e0e7f9f80125d Mon Sep 17 00:00:00 2001 From: Alin Voinea Date: Tue, 15 Aug 2023 17:22:26 +0300 Subject: [PATCH] refactor: Display List as ul, li; Register data_provenance widget by id - refs #256379 --- package.json | 2 +- src/components/index.js | 2 +- src/components/theme/Widgets/DataProvenance.jsx | 15 +++++++++++---- .../theme/Widgets/DataProvenanceView.jsx | 9 ++++----- src/index.js | 2 ++ 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index d28c614..ec6a965 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eeacms/volto-widget-dataprovenance", - "version": "0.3.3", + "version": "0.4.0", "description": "@eeacms/volto-widget-dataprovenance: Volto Data Provenance add-on", "main": "src/index.js", "author": "European Environment Agency: IDM2 A-Team", diff --git a/src/components/index.js b/src/components/index.js index 5113100..4cdd6e8 100644 --- a/src/components/index.js +++ b/src/components/index.js @@ -1,2 +1,2 @@ export { DataProvenance } from '@eeacms/volto-widget-dataprovenance/components/theme/Widgets/DataProvenance'; -export DataProvenanceWidgetView from '@eeacms/volto-widget-dataprovenance/components/theme/Widgets/DataProvenanceView'; +export { default as DataProvenanceWidgetView } from '@eeacms/volto-widget-dataprovenance/components/theme/Widgets/DataProvenanceView'; diff --git a/src/components/theme/Widgets/DataProvenance.jsx b/src/components/theme/Widgets/DataProvenance.jsx index 5d55ed9..9f3b85f 100644 --- a/src/components/theme/Widgets/DataProvenance.jsx +++ b/src/components/theme/Widgets/DataProvenance.jsx @@ -6,7 +6,7 @@ import { DragDropList, } from '@plone/volto/components'; import { ObjectWidget } from '@plone/volto/components'; - +import { default as DataProvenanceWidgetView } from './DataProvenanceView'; import deleteSVG from '@plone/volto/icons/delete.svg'; import addSVG from '@plone/volto/icons/add.svg'; import dragSVG from '@plone/volto/icons/drag.svg'; @@ -15,10 +15,17 @@ import Schema from './schema'; import './style.css'; export const DataProvenance = (props) => { - const { id, value = [], onChange, defaultData = {} } = props; + const { id, value = {}, defaultData = {}, onChange } = props; + const { readOnly = false, data = [] } = value; const predefinedSchema = Schema(props); - const flatListValue = value?.data || []; - return ( + const flatListValue = data || []; + return readOnly ? ( + <> + + + + + ) : ( <>
diff --git a/src/components/theme/Widgets/DataProvenanceView.jsx b/src/components/theme/Widgets/DataProvenanceView.jsx index 27de93e..0841e5d 100644 --- a/src/components/theme/Widgets/DataProvenanceView.jsx +++ b/src/components/theme/Widgets/DataProvenanceView.jsx @@ -5,22 +5,21 @@ import { UniversalLink } from '@plone/volto/components'; const DataProvenanceWidgetView = ({ value, className }) => value?.data ? ( - + {value.data.map((item, index) => ( - - + +
{item.link ? ( {item.title} ) : ( item.title )} {item.organisation ? `, ${item.organisation}` : null} - +
))}
) : ( '' ); - export default DataProvenanceWidgetView; diff --git a/src/index.js b/src/index.js index e78c31a..76f89f3 100644 --- a/src/index.js +++ b/src/index.js @@ -4,9 +4,11 @@ import { } from '@eeacms/volto-widget-dataprovenance/components'; const applyConfig = (config) => { + config.widgets.id.data_provenance = DataProvenance; config.widgets.widget.data_provenance = DataProvenance; if (config.widgets.views?.widget) { + config.widgets.views.id.data_provenance = DataProvenanceWidgetView; config.widgets.views.widget.data_provenance = DataProvenanceWidgetView; }