- really create unique IDs for widgets if id=auto (iterating over stored IDs to avoid doubles)
- deep id/label/linkId resetting when pasting but not cloning a widget
This commit is contained in:
parent
bf7362834d
commit
9d2e5de17f
2 changed files with 13 additions and 4 deletions
|
|
@ -77,9 +77,7 @@ var init = function(){
|
|||
actions['<i class="fa fa-paste"></i> Paste'] = {
|
||||
'<i class="fa fa-object-ungroup"></i> New ID':function(){
|
||||
data.widgets = data.widgets || []
|
||||
var newData = JSON.parse(JSON.stringify(CLIPBOARD))
|
||||
delete newData.id
|
||||
delete newData.label
|
||||
var newData = JSON.parse(JSON.stringify(CLIPBOARD).replace(/\"(id|label|linkId)\"\:\"([^\"]*)\"\,?/g,''))
|
||||
data.widgets.push(newData)
|
||||
updateDom(container,data)
|
||||
},
|
||||
|
|
|
|||
|
|
@ -78,7 +78,18 @@ module.exports.widgets = function(data,parent) {
|
|||
if (i.indexOf('separator')==-1 && widgetData[i]===undefined) widgetData[i] = tmpWidgetOptions[widgetData.type][i]
|
||||
}
|
||||
|
||||
widgetData.id = widgetData.id=='auto'?widgetData.type+'_'+getIterator(widgetData.type,'widget'):widgetData.id.replace(' ','_')
|
||||
if (widgetData.id=='auto') {
|
||||
var id
|
||||
while (id=widgetData.type+'_'+getIterator(widgetData.type,'widget')) {
|
||||
if (!WIDGETS.hasOwnProperty(id)) {
|
||||
widgetData.id = id
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
widgetData.id = widgetData.id.replace(' ','_')
|
||||
}
|
||||
|
||||
widgetData.label = widgetData.label=='auto'?widgetData.id:widgetData.label
|
||||
widgetData.path = widgetData.path=='auto'?'/' + widgetData.id:widgetData.path
|
||||
widgetData.target = widgetData.target?(Array.isArray(widgetData.target)?widgetData.target:[widgetData.target]):false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue