diff --git a/packages/backend-core/src/db/lucene.ts b/packages/backend-core/src/db/lucene.ts
index 4a2cfd34e2..d9dddd0097 100644
--- a/packages/backend-core/src/db/lucene.ts
+++ b/packages/backend-core/src/db/lucene.ts
@@ -8,19 +8,9 @@ import {
SearchParams,
WithRequired,
} from "@budibase/types"
+import { dataFilters } from "@budibase/shared-core"
-const QUERY_START_REGEX = /\d[0-9]*:/g
-
-export function removeKeyNumbering(key: any): string {
- if (typeof key === "string" && key.match(QUERY_START_REGEX) != null) {
- const parts = key.split(":")
- // remove the number
- parts.shift()
- return parts.join(":")
- } else {
- return key
- }
-}
+export const removeKeyNumbering = dataFilters.removeKeyNumbering
/**
* Class to build lucene query URLs.
diff --git a/packages/backend-core/src/users/users.ts b/packages/backend-core/src/users/users.ts
index 48920a3771..7d62a6ef39 100644
--- a/packages/backend-core/src/users/users.ts
+++ b/packages/backend-core/src/users/users.ts
@@ -17,8 +17,8 @@ import {
ContextUser,
CouchFindOptions,
DatabaseQueryOpts,
- SearchQuery,
- SearchQueryOperators,
+ SearchFilters,
+ SearchFilterOperator,
SearchUsersRequest,
User,
} from "@budibase/types"
@@ -44,11 +44,11 @@ function removeUserPassword(users: User | User[]) {
return users
}
-export function isSupportedUserSearch(query: SearchQuery) {
+export function isSupportedUserSearch(query: SearchFilters) {
const allowed = [
- { op: SearchQueryOperators.STRING, key: "email" },
- { op: SearchQueryOperators.EQUAL, key: "_id" },
- { op: SearchQueryOperators.ONE_OF, key: "_id" },
+ { op: SearchFilterOperator.STRING, key: "email" },
+ { op: SearchFilterOperator.EQUAL, key: "_id" },
+ { op: SearchFilterOperator.ONE_OF, key: "_id" },
]
for (let [key, operation] of Object.entries(query)) {
if (typeof operation !== "object") {
diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte
index 0632993cf0..6434c7710d 100644
--- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte
+++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte
@@ -14,6 +14,7 @@
notifications,
Checkbox,
DatePicker,
+ DrawerContent,
} from "@budibase/bbui"
import CreateWebhookModal from "components/automation/Shared/CreateWebhookModal.svelte"
import { automationStore, selectedAutomation, tables } from "stores/builder"
@@ -37,7 +38,7 @@
hbAutocomplete,
EditorModes,
} from "components/common/CodeEditor"
- import FilterDrawer from "components/design/settings/controls/FilterEditor/FilterDrawer.svelte"
+ import FilterBuilder from "components/design/settings/controls/FilterEditor/FilterBuilder.svelte"
import { LuceneUtils, Utils } from "@budibase/frontend-core"
import {
getSchemaForDatasourcePlus,
@@ -442,15 +443,16 @@
- (tempFilters = e.detail)}
- />
+
+ (tempFilters = e.detail)}
+ />
+
{:else if value.customType === "password"}
import { createEventDispatcher } from "svelte"
import { ActionButton, Modal, ModalContent } from "@budibase/bbui"
- import FilterDrawer from "components/design/settings/controls/FilterEditor/FilterDrawer.svelte"
+ import FilterBuilder from "components/design/settings/controls/FilterEditor/FilterBuilder.svelte"
export let schema
export let filters
@@ -40,7 +40,7 @@
onConfirm={() => dispatch("change", tempValue)}
>
-
+ import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
+ import ClientBindingPanel from "components/common/bindings/ClientBindingPanel.svelte"
+
+ import { dataFilters } from "@budibase/shared-core"
+ import { FilterBuilder } from "@budibase/frontend-core"
+
+ import { createEventDispatcher, onMount } from "svelte"
+
+ export let schemaFields
+ export let filters = []
+ export let bindings = []
+ export let panel = ClientBindingPanel
+ export let allowBindings = true
+ export let datasource
+
+ const dispatch = createEventDispatcher()
+
+ let rawFilters
+
+ $: parseFilters(rawFilters)
+ $: dispatch("change", enrichFilters(rawFilters))
+
+ // Remove field key prefixes and determine which behaviours to use
+ const parseFilters = filters => {
+ rawFilters = (filters || []).map(filter => {
+ const { field } = filter
+ let newFilter = { ...filter }
+ delete newFilter.allOr
+ newFilter.field = dataFilters.removeKeyNumbering(field)
+ return newFilter
+ })
+ }
+
+ onMount(() => {
+ parseFilters(filters)
+ rawFilters.forEach(filter => {
+ filter.type =
+ schemaFields.find(field => field.name === filter.field)?.type ||
+ filter.type
+ })
+ })
+
+ // Add field key prefixes and a special metadata filter object to indicate
+ // how to handle filter behaviour
+ const enrichFilters = rawFilters => {
+ let count = 1
+ return rawFilters
+ .filter(filter => filter.field)
+ .map(filter => ({
+ ...filter,
+ field: `${count++}:${filter.field}`,
+ }))
+ .concat(...rawFilters.filter(filter => !filter.field))
+ }
+
+
+
+
+
+ {
+ const indexToUpdate = rawFilters.findIndex(f => f.id === filter.id)
+ rawFilters[indexToUpdate] = {
+ ...rawFilters[indexToUpdate],
+ value: event.detail,
+ }
+ }}
+ />
+
diff --git a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterEditor.svelte b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterEditor.svelte
index 0f1f08d823..e481bb4381 100644
--- a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterEditor.svelte
+++ b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterEditor.svelte
@@ -1,8 +1,14 @@
-
-
-
- {#if !filters?.length}
- Add your first filter expression.
- {:else}
- Results are filtered to only those which match all of the following
- constraints.
- {/if}
-
- {#if filters?.length}
-
- {#each filters as filter}
-
- {/if}
-
-
-
-
-
-
-
+
+
+ Results are filtered to only those which match all of the following
+ constraints.
+