Merge pull request #360 from marzeelabs/feature/#359_list_children_metadata

#359 - Handle metadata for all children of a list field
This commit is contained in:
Shawn Erquhart 2017-04-14 12:59:08 -04:00 committed by GitHub
commit 2047fda27c

View File

@ -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.removeIn(value.get(index).valueSeq()) };
onChange(value.remove(index), parsedMetadata);
};
}