Filter user (single) UI

This commit is contained in:
Adria Navarro 2023-10-03 12:46:06 +02:00
parent af924ae4a2
commit 3b93748376
3 changed files with 34 additions and 0 deletions

View File

@ -17,7 +17,9 @@
import { generate } from "shortid"
import { LuceneUtils, Constants } from "@budibase/frontend-core"
import { getFields } from "helpers/searchFields"
import { FieldType } from "@budibase/types"
import { createEventDispatcher, onMount } from "svelte"
import FilterUsers from "./FilterUsers.svelte"
export let schemaFields
export let filters = []
@ -285,6 +287,8 @@
timeOnly={getSchema(filter)?.timeOnly}
bind:value={filter.value}
/>
{:else if filter.type === FieldType.BB_REFERENCE}
<FilterUsers {filter} />
{:else}
<DrawerBindableInput disabled />
{/if}

View File

@ -0,0 +1,28 @@
<script>
import { Select } from "@budibase/bbui"
import { fetchData } from "@budibase/frontend-core"
import { API } from "api"
export let filter
$: fetch = fetchData({
API,
datasource: {
type: "user",
},
options: {
limit: 100,
},
})
$: options = $fetch.rows
</script>
<Select
autocomplete
bind:value={filter.value}
{options}
getOptionLabel={option => option.email}
getOptionValue={option => option._id}
/>

View File

@ -60,6 +60,8 @@ export const getValidOperatorsForType = (
ops = numOps
} else if (type === FieldType.FORMULA) {
ops = stringOps.concat([Op.MoreThan, Op.LessThan])
} else if (type === FieldType.BB_REFERENCE) {
ops = [Op.Equals, Op.NotEquals, Op.Empty, Op.NotEmpty, Op.In]
}
// Only allow equal/not equal for _id in SQL tables