Skip to content

Commit

Permalink
store data_provinance as obj in backend
Browse files Browse the repository at this point in the history
  • Loading branch information
nileshgulia1 committed Jun 2, 2022
1 parent 1e74b58 commit 78db22a
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/components/theme/Widgets/DataProvenance.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import Schema from './schema';
import './style.css';

export const DataProvenance = (props) => {
const { id, value = [], onChange, defaultData = {} } = props;
const { id, value = {}, onChange, defaultData = {} } = props;
const predefinedSchema = Schema(props);
const flatListValue = isArray(value) ? value : [];
const flatListValue = isArray(value) ? value : Object.values(value);
return (
<>
<FormFieldWrapper {...props} className="objectlist-inline-widget">
Expand Down Expand Up @@ -103,7 +103,17 @@ export const DataProvenance = (props) => {
const newvalue = flatListValue.map((v, i) =>
i !== index ? v : fv,
);
onChange(id, newvalue);
// const da = newvalue.map((item) => ({
// [item['@id']]: { ...item },
// }));

onChange(
id,
newvalue.reduce(
(a, v) => ({ ...a, [v['@id']]: v }),
{},
),
);
}}
/>
</Segment>
Expand Down

0 comments on commit 78db22a

Please sign in to comment.