add auto detection of id created automatically to allow to have different id when cloning (can be done via dynamic props too )

This commit is contained in:
Martin Hermant 2018-10-11 14:38:54 +02:00
parent b0f981ffac
commit dc7aa202e6
No known key found for this signature in database
GPG key ID: FA123D713AB2A87C

View file

@ -129,8 +129,16 @@ class Clone extends Widget {
this.cloneClass = [...this.cloneTarget.container.classList].filter(i=>excludedCloneClasses.indexOf(i) === -1)
this.container.classList.remove('empty')
this.container.classList.add(...this.cloneClass)
var clone = parser.parse([{...deepCopy(this.cloneTarget.props), ...this.getProp('props')}], this.widget, this)
let clonedProps = deepCopy(this.cloneTarget.props)
function resetAutoIds(ob){
if(ob.widgets)
for (const o of ob.widgets){resetAutoIds(o)}
if( ob.id && ob.id.startsWith(ob.type+'_')){
ob.id = "auto"
}
}
resetAutoIds(clonedProps)
var clone = parser.parse([{...clonedProps, ...this.getProp('props')}], this.widget, this)
if (clone.getProp('id') === this.cloneTarget.getProp('id')) {
widgetManager.trigger('change.*', [{