widgets: expose widgets unique identifiers as with property name "uuid"
This commit is contained in:
parent
70067b1c57
commit
f839d647ff
3 changed files with 13 additions and 4 deletions
|
|
@ -12,6 +12,9 @@
|
|||
- add keyboard shortcut to show widget in project tree
|
||||
- selected widget is not showed on top of the others anymore
|
||||
|
||||
- widgets
|
||||
- expose widgets unique identifiers as with property name "uuid"
|
||||
|
||||
## 1.3.0
|
||||
|
||||
- bug fixes
|
||||
|
|
|
|||
|
|
@ -16,6 +16,10 @@ The property name (and the dot) can be omitted and defaults to `value` (`@{widge
|
|||
|
||||
A widget can fetch its own properties or its direct parent's by using the keywords `this` or `parent` instead of `id`. When `this` or `parent` can be used, using the target widget's `id` instead won't work.
|
||||
|
||||
#### `uuid`
|
||||
|
||||
Each widget has a unique random identifier that can be retreived with the property name `uuid` (e.g. `@{this.uuid}`, `@{parent.uuid}`).
|
||||
|
||||
#### Dynamic properties
|
||||
|
||||
Some properties, when changed, trigger a complete widget recreation that ends any ongoing user interaction. Also, updating these properties continuously (e.g. when linked to a slider's dynamic value) can be very cpu expensive.
|
||||
|
|
|
|||
|
|
@ -357,6 +357,7 @@ class Widget extends EventEmitter {
|
|||
|
||||
// Cache resolved props
|
||||
this.cachedProps = {}
|
||||
this.cachedProps.uuid = this.hash
|
||||
|
||||
for (var k in this.props) {
|
||||
if (k != 'widgets' && k != 'tabs') {
|
||||
|
|
@ -567,15 +568,16 @@ class Widget extends EventEmitter {
|
|||
|
||||
if (widgets[i] === widgetManager) continue
|
||||
|
||||
if (widgets[i].props[k] !== undefined || k === 'value') {
|
||||
if (widgets[i].props[k] !== undefined || k === 'value' || k === 'uuid') {
|
||||
|
||||
if (k !== 'value' && originalPropName === k && widgets[i] === originalWidget) {
|
||||
return 'ERR_CIRCULAR_REF'
|
||||
}
|
||||
|
||||
var r = k == 'value' ?
|
||||
widgets[i].getValue(true) :
|
||||
widgets[i].resolveProp(k, undefined, storeLinks, originalWidget, originalPropName)
|
||||
var r
|
||||
if (k === 'value') r = widgets[i].getValue(true)
|
||||
else if (k === 'uuid') r = widgets[i].hash
|
||||
else r = widgets[i].resolveProp(k, undefined, storeLinks, originalWidget, originalPropName)
|
||||
|
||||
if (subk !== undefined && r !== undefined) r = r[subk]
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue