Add 'continue if' button action
This commit is contained in:
parent
8887b67ecc
commit
ff327423e1
|
@ -45,6 +45,7 @@ const INITIAL_FRONTEND_STATE = {
|
||||||
customThemes: false,
|
customThemes: false,
|
||||||
devicePreview: false,
|
devicePreview: false,
|
||||||
messagePassing: false,
|
messagePassing: false,
|
||||||
|
continueIfAction: false,
|
||||||
},
|
},
|
||||||
currentFrontEndType: "none",
|
currentFrontEndType: "none",
|
||||||
selectedScreenId: "",
|
selectedScreenId: "",
|
||||||
|
|
|
@ -0,0 +1,78 @@
|
||||||
|
<script>
|
||||||
|
import { Select, Body } from "@budibase/bbui"
|
||||||
|
import { onMount } from "svelte"
|
||||||
|
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
|
||||||
|
export let parameters
|
||||||
|
export let bindings
|
||||||
|
|
||||||
|
const typeOptions = [
|
||||||
|
{
|
||||||
|
label: "Continue if",
|
||||||
|
value: "continue",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Stop if",
|
||||||
|
value: "stop",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
const operatorOptions = [
|
||||||
|
{
|
||||||
|
label: "Equals",
|
||||||
|
value: "equal",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Not equals",
|
||||||
|
value: "notEqual",
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
if (!parameters.type) {
|
||||||
|
parameters.type = "continue"
|
||||||
|
}
|
||||||
|
if (!parameters.operator) {
|
||||||
|
parameters.operator = "equal"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="root">
|
||||||
|
<Body size="S">
|
||||||
|
Configure a condition to be evaluated which can stop further actions from
|
||||||
|
being executed.
|
||||||
|
</Body>
|
||||||
|
<Select
|
||||||
|
bind:value={parameters.type}
|
||||||
|
options={typeOptions}
|
||||||
|
placeholder={null}
|
||||||
|
/>
|
||||||
|
<DrawerBindableInput
|
||||||
|
placeholder="Value"
|
||||||
|
value={parameters.value}
|
||||||
|
on:change={e => (parameters.value = e.detail)}
|
||||||
|
{bindings}
|
||||||
|
/>
|
||||||
|
<Select
|
||||||
|
bind:value={parameters.operator}
|
||||||
|
options={operatorOptions}
|
||||||
|
placeholder={null}
|
||||||
|
/>
|
||||||
|
<DrawerBindableInput
|
||||||
|
placeholder="Reference value"
|
||||||
|
bind:value={parameters.referenceValue}
|
||||||
|
on:change={e => (parameters.referenceValue = e.detail)}
|
||||||
|
{bindings}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.root {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: var(--spacing-l);
|
||||||
|
justify-content: flex-start;
|
||||||
|
align-items: stretch;
|
||||||
|
max-width: 400px;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -13,3 +13,4 @@ export { default as RefreshDataProvider } from "./RefreshDataProvider.svelte"
|
||||||
export { default as DuplicateRow } from "./DuplicateRow.svelte"
|
export { default as DuplicateRow } from "./DuplicateRow.svelte"
|
||||||
export { default as S3Upload } from "./S3Upload.svelte"
|
export { default as S3Upload } from "./S3Upload.svelte"
|
||||||
export { default as ExportData } from "./ExportData.svelte"
|
export { default as ExportData } from "./ExportData.svelte"
|
||||||
|
export { default as ContinueIf } from "./ContinueIf.svelte"
|
||||||
|
|
|
@ -84,6 +84,11 @@
|
||||||
{
|
{
|
||||||
"name": "Export Data",
|
"name": "Export Data",
|
||||||
"component": "ExportData"
|
"component": "ExportData"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Continue if / Stop if",
|
||||||
|
"component": "ContinueIf",
|
||||||
|
"dependsOnFeature": "continueIfAction"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
|
@ -7,7 +7,8 @@
|
||||||
"customThemes": true,
|
"customThemes": true,
|
||||||
"devicePreview": true,
|
"devicePreview": true,
|
||||||
"messagePassing": true,
|
"messagePassing": true,
|
||||||
"rowSelection": true
|
"rowSelection": true,
|
||||||
|
"continueIfAction": true
|
||||||
},
|
},
|
||||||
"layout": {
|
"layout": {
|
||||||
"name": "Layout",
|
"name": "Layout",
|
||||||
|
|
|
@ -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 = {
|
const handlerMap = {
|
||||||
["Save Row"]: saveRowHandler,
|
["Save Row"]: saveRowHandler,
|
||||||
["Duplicate Row"]: duplicateRowHandler,
|
["Duplicate Row"]: duplicateRowHandler,
|
||||||
|
@ -277,6 +297,7 @@ const handlerMap = {
|
||||||
["Update State"]: updateStateHandler,
|
["Update State"]: updateStateHandler,
|
||||||
["Upload File to S3"]: s3UploadHandler,
|
["Upload File to S3"]: s3UploadHandler,
|
||||||
["Export Data"]: exportDataHandler,
|
["Export Data"]: exportDataHandler,
|
||||||
|
["Continue if / Stop if"]: continueIfHandler,
|
||||||
}
|
}
|
||||||
|
|
||||||
const confirmTextMap = {
|
const confirmTextMap = {
|
||||||
|
|
Loading…
Reference in New Issue