Skip to content

Commit

Permalink
refactor: Display List as ul, li; Register data_provenance widget by …
Browse files Browse the repository at this point in the history
…id - refs #256379
  • Loading branch information
avoinea committed Aug 15, 2023
1 parent 62ce749 commit dc69108
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/components/index.js
Original file line number Diff line number Diff line change
@@ -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';
15 changes: 11 additions & 4 deletions src/components/theme/Widgets/DataProvenance.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 ? (
<>
<FormFieldWrapper {...props} className="objectlist-inline-widget">
<DataProvenanceWidgetView value={value} />
</FormFieldWrapper>
</>
) : (
<>
<FormFieldWrapper {...props} className="objectlist-inline-widget">
<div>
Expand Down
9 changes: 4 additions & 5 deletions src/components/theme/Widgets/DataProvenanceView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@ import { UniversalLink } from '@plone/volto/components';

const DataProvenanceWidgetView = ({ value, className }) =>
value?.data ? (
<List className={cx(className, 'widget')} bulleted={true}>
<List className={cx(className, 'widget')} bulleted={true} as="ul">
{value.data.map((item, index) => (
<List.Item className="horizontal" key={index}>
<List.Content>
<List.Item className="horizontal" key={index} as="li">
<div>
{item.link ? (
<UniversalLink href={item.link}>{item.title}</UniversalLink>
) : (
item.title
)}
{item.organisation ? `, ${item.organisation}` : null}
</List.Content>
</div>
</List.Item>
))}
</List>
) : (
''
);

export default DataProvenanceWidgetView;
2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit dc69108

Please sign in to comment.