Prevent duplicate property names
This commit is contained in:
parent
9350debba2
commit
94671507b5
|
@ -46,7 +46,10 @@ export function changeProperty (data, path, oldProp, newProp) {
|
||||||
const object = getIn(data, dataPath)
|
const object = getIn(data, dataPath)
|
||||||
const index = object.props.findIndex(p => p.name === oldProp)
|
const index = object.props.findIndex(p => p.name === oldProp)
|
||||||
|
|
||||||
return setIn(data, dataPath.concat(['props', index, 'name']), newProp)
|
// prevent duplicate property names
|
||||||
|
const uniqueNewProp = findUniqueName(newProp, object.props.map(p => p.name))
|
||||||
|
|
||||||
|
return setIn(data, dataPath.concat(['props', index, 'name']), uniqueNewProp)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -173,6 +176,9 @@ export function duplicate (data, path, prop) {
|
||||||
const original = props[index]
|
const original = props[index]
|
||||||
const duplicate = cloneDeep(original)
|
const duplicate = cloneDeep(original)
|
||||||
|
|
||||||
|
// prevent duplicate property names
|
||||||
|
duplicate.name = findUniqueName(duplicate.name, props.map(p => p.name))
|
||||||
|
|
||||||
updated.splice(index + 1, 0, duplicate)
|
updated.splice(index + 1, 0, duplicate)
|
||||||
|
|
||||||
return updated
|
return updated
|
||||||
|
|
Loading…
Reference in New Issue