diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index fd29414e3c..3ffc890c7d 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -45,6 +45,7 @@ const INITIAL_FRONTEND_STATE = { customThemes: false, devicePreview: false, messagePassing: false, + continueIfAction: false, }, currentFrontEndType: "none", selectedScreenId: "", diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ButtonActionEditor/actions/ContinueIf.svelte b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ButtonActionEditor/actions/ContinueIf.svelte new file mode 100644 index 0000000000..f284e24645 --- /dev/null +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ButtonActionEditor/actions/ContinueIf.svelte @@ -0,0 +1,78 @@ + + +
+ + Configure a condition to be evaluated which can stop further actions from + being executed. + + + (parameters.referenceValue = e.detail)} + {bindings} + /> +
+ + diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ButtonActionEditor/actions/index.js b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ButtonActionEditor/actions/index.js index 6593c9cbd4..2306d4a548 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ButtonActionEditor/actions/index.js +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ButtonActionEditor/actions/index.js @@ -13,3 +13,4 @@ export { default as RefreshDataProvider } from "./RefreshDataProvider.svelte" export { default as DuplicateRow } from "./DuplicateRow.svelte" export { default as S3Upload } from "./S3Upload.svelte" export { default as ExportData } from "./ExportData.svelte" +export { default as ContinueIf } from "./ContinueIf.svelte" diff --git a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ButtonActionEditor/manifest.json b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ButtonActionEditor/manifest.json index 0f6d3344b2..80464b281f 100644 --- a/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ButtonActionEditor/manifest.json +++ b/packages/builder/src/components/design/PropertiesPanel/PropertyControls/ButtonActionEditor/manifest.json @@ -84,6 +84,11 @@ { "name": "Export Data", "component": "ExportData" + }, + { + "name": "Continue if / Stop if", + "component": "ContinueIf", + "dependsOnFeature": "continueIfAction" } ] -} \ No newline at end of file +} diff --git a/packages/client/manifest.json b/packages/client/manifest.json index fab24e4aa0..4bf0631b66 100644 --- a/packages/client/manifest.json +++ b/packages/client/manifest.json @@ -7,7 +7,8 @@ "customThemes": true, "devicePreview": true, "messagePassing": true, - "rowSelection": true + "rowSelection": true, + "continueIfAction": true }, "layout": { "name": "Layout", diff --git a/packages/client/src/utils/buttonActions.js b/packages/client/src/utils/buttonActions.js index f44e7d7453..18f7d3973e 100644 --- a/packages/client/src/utils/buttonActions.js +++ b/packages/client/src/utils/buttonActions.js @@ -261,6 +261,26 @@ const exportDataHandler = async action => { } } +const continueIfHandler = action => { + const { type, value, operator, referenceValue } = action.parameters + if (!type || !operator) { + return + } + let match = false + if (value == null && referenceValue == null) { + match = true + } else if (value === referenceValue) { + match = true + } else { + match = JSON.stringify(value) === JSON.stringify(referenceValue) + } + if (type === "continue") { + return operator === "equal" ? match : !match + } else { + return operator === "equal" ? !match : match + } +} + const handlerMap = { ["Save Row"]: saveRowHandler, ["Duplicate Row"]: duplicateRowHandler, @@ -277,6 +297,7 @@ const handlerMap = { ["Update State"]: updateStateHandler, ["Upload File to S3"]: s3UploadHandler, ["Export Data"]: exportDataHandler, + ["Continue if / Stop if"]: continueIfHandler, } const confirmTextMap = {