diff --git a/platypush/backend/http/webapp/src/components/Action/ActionsList.vue b/platypush/backend/http/webapp/src/components/Action/ActionsList.vue
index 4efbb453f9..faa20209b2 100644
--- a/platypush/backend/http/webapp/src/components/Action/ActionsList.vue
+++ b/platypush/backend/http/webapp/src/components/Action/ActionsList.vue
@@ -29,7 +29,7 @@
v-on="componentsData[index].on"
:collapsed="collapsedBlocks[index]"
:dragging="isDragging"
- v-else-if="fors[index]" />
+ v-else-if="loops[index]" />
-
-
+
+
+
@@ -265,9 +269,15 @@ export default {
data.props.indent = this.indent + 1
}
- const loop = this.getFor(action)
- if (loop) {
- data.props.async = loop.async
+ const forLoop = this.getFor(action)
+ if (forLoop) {
+ data.props.async = forLoop.async
+ data.props.type = 'for'
+ }
+
+ const whileLoop = this.getWhile(action)
+ if (whileLoop) {
+ data.props.type = 'while'
}
return data
@@ -338,6 +348,23 @@ export default {
}, {}) || {}
},
+ whiles() {
+ return this.newValue?.reduce?.((acc, action, index) => {
+ if (this.getWhile(action)) {
+ acc[index] = action
+ }
+
+ return acc
+ }, {}) || {}
+ },
+
+ loops() {
+ return [...Object.keys(this.fors), ...Object.keys(this.whiles)].reduce((acc, index) => {
+ acc[index] = this.newValue[index]
+ return acc
+ }, {})
+ },
+
hasChanges() {
return this.newStringValue !== this.stringValue
},
@@ -389,14 +416,17 @@ export default {
showAddButtons() {
return (
- this.newValue.length === 0 || !this.collapseAddButtons
+ (this.indent === 0 && this.newValue.length === 0) || !this.collapseAddButtons
)
},
showAddButtonsExpander() {
return (
!this.readOnly &&
- this.newValue?.length > 0 &&
+ (
+ this.newValue?.length > 0 ||
+ this.indent > 0
+ ) &&
Object.entries(this.visibleAddButtons).filter(
([key, value]) => value && key != 'action'
).length > 1
@@ -431,6 +461,7 @@ export default {
this.conditions[index] ||
this.elses[index] ||
this.fors[index] ||
+ this.whiles[index] ||
this.isAction(action) ||
this.isReturn(action) ||
this.isBreak(action) ||
@@ -448,7 +479,8 @@ export default {
action: this.allowAddButtons,
return: this.allowAddButtons,
condition: this.allowAddButtons,
- loop: this.allowAddButtons,
+ for: this.allowAddButtons,
+ while: this.allowAddButtons,
else: (
this.allowAddButtons &&
this.parent &&
@@ -663,11 +695,16 @@ export default {
this.selectLastExprEditor()
},
- addLoop() {
+ addForLoop() {
this.newValue.push({ 'for _ in ${range(10)}': [] })
this.selectLastExprEditor()
},
+ addWhileLoop() {
+ this.newValue.push({ 'while ${True}': [] })
+ this.selectLastExprEditor()
+ },
+
addBreak() {
this.newValue.push('break')
},
diff --git a/platypush/backend/http/webapp/src/components/Action/LoopBlock.vue b/platypush/backend/http/webapp/src/components/Action/LoopBlock.vue
index 56c5ecdc7f..079fcf6404 100644
--- a/platypush/backend/http/webapp/src/components/Action/LoopBlock.vue
+++ b/platypush/backend/http/webapp/src/components/Action/LoopBlock.vue
@@ -22,7 +22,7 @@
- {}
+ },
+
+ isDragging() {
+ return this.dragging_ || this.dragging
+ },
+
+ key() {
+ return this.getKey(this.value)
+ },
+
loop() {
- return this.getFor(this.key)
+ if (this.type === 'for') {
+ return this.getFor(this.key)
+ }
+
+ if (this.type === 'while') {
+ return {condition: this.getWhile(this.key)}
+ }
+
+ return {}
},
loopTileConf() {
@@ -129,10 +162,11 @@ export default {
readOnly: this.readOnly,
spacerBottom: this.spacerBottom,
spacerTop: this.spacerTop,
+ type: this.type,
},
on: {
- change: this.onLoopChange,
+ change: this.changeHandler,
delete: (event) => this.$emit('delete', event),
drag: this.onDragStart,
dragend: this.onDragEnd,
@@ -144,14 +178,6 @@ export default {
},
}
},
-
- isDragging() {
- return this.dragging_ || this.dragging
- },
-
- key() {
- return this.getKey(this.value)
- },
},
methods: {
@@ -163,7 +189,7 @@ export default {
this.$emit('input', { [this.key]: value })
},
- onLoopChange(loop) {
+ onForChange(loop) {
const iterable = loop?.iterable?.trim()
const iterator = loop?.iterator?.trim()
const async_ = loop?.async || false
@@ -177,6 +203,16 @@ export default {
this.$emit('input', { [loop]: this.value[this.key] })
},
+ onWhileChange(condition) {
+ condition = condition?.trim()
+ if (!this.key || this.readOnly || !condition?.length) {
+ return
+ }
+
+ const loop = `while \${${condition}}`
+ this.$emit('input', { [loop]: this.value[this.key] })
+ },
+
onDragStart(event) {
if (this.readOnly) {
return
diff --git a/platypush/backend/http/webapp/src/components/Action/LoopTile.vue b/platypush/backend/http/webapp/src/components/Action/LoopTile.vue
index 475bede105..a2799f798d 100644
--- a/platypush/backend/http/webapp/src/components/Action/LoopTile.vue
+++ b/platypush/backend/http/webapp/src/components/Action/LoopTile.vue
@@ -17,12 +17,17 @@
-
+
fork
in [
]
+
+
+ while [
+ ]
+
@@ -33,17 +38,23 @@
+ v-if="showLoopEditor && type === 'for'">
Loop
+
+
+ Loop Condition
+