clone: remove vars prop, add "props" prop for overriding anything

This commit is contained in:
jean-emmanuel 2017-08-02 10:46:55 +02:00
parent 877a13a508
commit 7209a64d89
2 changed files with 16 additions and 3 deletions

View file

@ -138,3 +138,15 @@ Modals are buttons that turn into a centered popup panels when enabled. They can
- type: `string`
- default: `empty`
- usage: `id` of the widget to clone
### `props`
- type: `object`
- default: `{}`
- usage: cloned widget's properties to override
- example:
```json
{
"variables": { "n": 2 },
"color": "orange"
}
```

View file

@ -25,9 +25,9 @@ module.exports = class Clone extends _widgets_base {
widgetId:'',
_children:'children',
_overrides:'overrides',
variables:'@{parent.variables}',
props:{},
}
}
@ -35,6 +35,7 @@ module.exports = class Clone extends _widgets_base {
constructor(options) {
options.props.label = false
options.props.variables = '@{parent.variables}'
super({...options, html: '<div class="clone"></div>'})
@ -79,7 +80,7 @@ module.exports = class Clone extends _widgets_base {
this.cloneClass = widgets[i].container.attr('class').match(/[^\s]*-container/)[0]
this.container.addClass(this.cloneClass)
var c = parsewidgets([_widgets_base.deepCopy(widgets[i].props)], this.widget, this)
var c = parsewidgets([{..._widgets_base.deepCopy(widgets[i].props), ...this.getProp('props')}], this.widget, this)
this.widget.find('.widget').addClass('not-editable')