From 805f958165c26df4815da9c1f253bcf1f2700bb7 Mon Sep 17 00:00:00 2001 From: Luis Correia Date: Thu, 13 Apr 2017 11:02:06 +0100 Subject: [PATCH 1/3] #359 - Handle metadata for all children of a list field --- src/components/Widgets/ListControl.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/Widgets/ListControl.js b/src/components/Widgets/ListControl.js index 579f3352..cbebdb86 100644 --- a/src/components/Widgets/ListControl.js +++ b/src/components/Widgets/ListControl.js @@ -89,17 +89,21 @@ export default class ListControl extends Component { handleChangeFor(index) { return (newValue, newMetadata) => { - const { value, onChange } = this.props; + const { value, metadata, onChange, forID } = this.props; const parsedValue = (this.valueType === valueTypes.SINGLE) ? newValue.first() : newValue; - onChange(value.set(index, parsedValue), newMetadata); + const parsedMetadata = { + [forID]: Object.assign(metadata ? metadata.toJS() : {}, newMetadata ? newMetadata[forID] : {}), + }; + onChange(value.set(index, parsedValue), parsedMetadata); }; } handleRemove(index) { return (e) => { e.preventDefault(); - const { value, onChange } = this.props; - onChange(value.remove(index)); + const { value, metadata, onChange, forID } = this.props; + const parsedMetadata = { [forID]: metadata.remove(metadata.keySeq().get(0)) }; + onChange(value.remove(index), parsedMetadata); }; } @@ -193,3 +197,7 @@ export default class ListControl extends Component { />); } } + + +// WEBPACK FOOTER // +// ./components/Widgets/ListControl.js From b75f86f4c204da9d295897c5fccccaa9b8cae8d4 Mon Sep 17 00:00:00 2001 From: Luis Correia Date: Thu, 13 Apr 2017 12:45:32 +0100 Subject: [PATCH 2/3] #359 - Delete metadata by key of deleted value (previously harcoded) --- src/components/Widgets/ListControl.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Widgets/ListControl.js b/src/components/Widgets/ListControl.js index cbebdb86..1b0ee239 100644 --- a/src/components/Widgets/ListControl.js +++ b/src/components/Widgets/ListControl.js @@ -102,7 +102,7 @@ export default class ListControl extends Component { return (e) => { e.preventDefault(); const { value, metadata, onChange, forID } = this.props; - const parsedMetadata = { [forID]: metadata.remove(metadata.keySeq().get(0)) }; + const parsedMetadata = { [forID]: metadata.removeIn(value.get(index).valueSeq()) }; onChange(value.remove(index), parsedMetadata); }; } From e2f471e8635a5a0c800bd2bc4861c93466f676cb Mon Sep 17 00:00:00 2001 From: Joseph Earl Date: Fri, 14 Apr 2017 13:56:24 +0100 Subject: [PATCH 3/3] Remove webpack footer --- src/components/Widgets/ListControl.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/components/Widgets/ListControl.js b/src/components/Widgets/ListControl.js index 1b0ee239..9210ae30 100644 --- a/src/components/Widgets/ListControl.js +++ b/src/components/Widgets/ListControl.js @@ -197,7 +197,3 @@ export default class ListControl extends Component { />); } } - - -// WEBPACK FOOTER // -// ./components/Widgets/ListControl.js