Propagate the @update event to the parent entities

This commit is contained in:
Fabio Manganiello 2023-01-21 14:55:06 +01:00
parent 4d762b81dc
commit fb562bb415
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -2,7 +2,7 @@
<div class="entity-container-wrapper" <div class="entity-container-wrapper"
:class="{'with-children': hasChildren, collapsed: isCollapsed, hidden: !value?.name?.length}"> :class="{'with-children': hasChildren, collapsed: isCollapsed, hidden: !value?.name?.length}">
<div class="row item entity-container" <div class="row item entity-container"
:class="{blink: justUpdated, 'with-children': hasChildren, collapsed: isCollapsed}"> :class="{ 'with-children': hasChildren, collapsed: isCollapsed, blink: justUpdated }">
<div class="adjuster" :class="{'col-12': !hasChildren, 'col-11': hasChildren}"> <div class="adjuster" :class="{'col-12': !hasChildren, 'col-11': hasChildren}">
<component <component
:is="component" :is="component"
@ -28,6 +28,7 @@
:value="entity" :value="entity"
:loading="loading" :loading="loading"
:level="level + 1" :level="level + 1"
@update="setJustUpdated"
@input="$emit('input', entity)" /> @input="$emit('input', entity)" />
</div> </div>
</div> </div>
@ -95,7 +96,13 @@ export default {
// Propagate the collapsed state to the wrapped component if applicable // Propagate the collapsed state to the wrapped component if applicable
if (this.instance) if (this.instance)
this.instance.collapsed = !this.instance.collapsed this.instance.collapsed = !this.instance.collapsed
} },
setJustUpdated() {
this.justUpdated = true
const self = this;
setTimeout(() => self.justUpdated = false, 1000)
},
}, },
mounted() { mounted() {
@ -110,9 +117,8 @@ export default {
if (this.valuesEqual(oldValue, newValue)) if (this.valuesEqual(oldValue, newValue))
return false return false
this.justUpdated = true this.setJustUpdated()
const self = this; this.$emit('update', {value: newValue})
setTimeout(() => self.justUpdated = false, 1000)
} }
) )