[ProcedureEditor] Emit input upon action changes.

This commit is contained in:
Fabio Manganiello 2023-12-16 23:29:57 +01:00
parent 1bd2361a3d
commit b916c98b70
Signed by: blacklight
GPG key ID: D90FBA7F76362774

View file

@ -37,8 +37,8 @@
draggable with-delete draggable with-delete
@drag="dragItem = index" @drag="dragItem = index"
@drop="dragItem = undefined" @drop="dragItem = undefined"
@input="newValue.actions[index] = $event" @input="editAction($event, index)"
@delete="newValue.actions.splice(index, 1)" /> @delete="deleteAction(index)" />
<div class="drop-target-container" <div class="drop-target-container"
:class="{active: dropIndex === index}" :class="{active: dropIndex === index}"
@ -55,7 +55,7 @@
</div> </div>
<div class="row item"> <div class="row item">
<ActionTile :value="newAction" @input="newValue.actions.push($event)" /> <ActionTile :value="newAction" @input="addAction" />
</div> </div>
</div> </div>
@ -126,6 +126,10 @@ export default {
this.running = false this.running = false
}, },
emitInput() {
this.$emit('input', this.newValue)
},
onDrop(index) { onDrop(index) {
if (this.dragItem === undefined) if (this.dragItem === undefined)
return return
@ -133,6 +137,8 @@ export default {
this.newValue.actions.splice( this.newValue.actions.splice(
index, 0, this.newValue.actions.splice(this.dragItem, 1)[0] index, 0, this.newValue.actions.splice(this.dragItem, 1)[0]
) )
this.emitInput()
}, },
executeAction() { executeAction() {
@ -142,6 +148,21 @@ export default {
this.running = true this.running = true
this.execute(this.value.actions).then(this.onResponse).catch(this.onError).finally(this.onDone) this.execute(this.value.actions).then(this.onResponse).catch(this.onError).finally(this.onDone)
}, },
editAction(action, index) {
this.newValue.actions[index] = action
this.emitInput()
},
addAction(action) {
this.newValue.actions.push(action)
this.emitInput()
},
deleteAction(index) {
this.newValue.actions.splice(index, 1)
this.emitInput()
},
}, },
watch: { watch: {