diff --git a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte index 1d9c3dea09..fcec0e35ac 100644 --- a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte +++ b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte @@ -9,7 +9,6 @@ Input, Layout, Select, - Toggle, Label, } from "@budibase/bbui" import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte" @@ -17,7 +16,7 @@ import { generate } from "shortid" import { LuceneUtils, Constants } from "@budibase/frontend-core" import { getFields } from "helpers/searchFields" - import { createEventDispatcher } from "svelte" + import { createEventDispatcher, onMount } from "svelte" const dispatch = createEventDispatcher() @@ -33,6 +32,11 @@ $: fieldOptions = enrichedSchemaFields.map(field => field.name) || [] $: valueTypeOptions = allowBindings ? ["Value", "Binding"] : ["Value"] + let behaviourValue + const behaviourOptions = [ + { value: "and", label: "Match all of the following filters" }, + { value: "or", label: "Match any of the following filters" }, + ] const addFilter = () => { filters = [ ...filters, @@ -99,6 +103,10 @@ const schema = enrichedSchemaFields.find(x => x.name === field) return schema?.constraints?.inclusion || [] } + + onMount(() => { + behaviourValue = allOr ? "or" : "and" + }) @@ -114,88 +122,98 @@ {#if filters?.length}
- {#each filters as filter, idx} - onOperatorChange(filter, e.detail)} - placeholder={null} - /> - opt.label} + getOptionValue={opt => opt.value} + on:change={e => (allOr = e.detail === "or")} + placeholder={null} + /> +
+
+
+ +
+
+ {#each filters as filter, idx} + - {:else if ["options", "array"].includes(filter.type)} - onOperatorChange(filter, e.detail)} + placeholder={null} /> - {:else if filter.type === "boolean"} - - {:else if filter.type === "datetime"} - (filter.value = event.detail)} + /> + {:else if ["string", "longform", "number", "formula"].includes(filter.type)} + + {:else if ["options", "array"].includes(filter.type)} + + {:else if filter.type === "boolean"} + + {:else if filter.type === "datetime"} + + {:else} + + {/if} + duplicateFilter(filter.id)} /> - {:else} - - {/if} - duplicateFilter(filter.id)} - /> - removeFilter(filter.id)} - /> - {/each} + removeFilter(filter.id)} + /> + {/each} +
{/if}
-
- (allOr = event.detail)} - /> -
@@ -216,10 +234,8 @@ grid-template-columns: 1fr 120px 120px 1fr auto auto; } - .toggle { - display: flex; - align-items: center; - padding-right: var(--spacing-s); + .filter-label { + margin-bottom: var(--spacing-s); } .bottom {