|
|
@ -9,7 +9,6 @@ |
|
|
Input, |
|
|
Input, |
|
|
Layout, |
|
|
Layout, |
|
|
Select, |
|
|
Select, |
|
|
Toggle, |
|
|
|
|
|
Label, |
|
|
Label, |
|
|
} from "@budibase/bbui" |
|
|
} from "@budibase/bbui" |
|
|
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte" |
|
|
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte" |
|
|
@ -17,7 +16,7 @@ |
|
|
import { generate } from "shortid" |
|
|
import { generate } from "shortid" |
|
|
import { LuceneUtils, Constants } from "@budibase/frontend-core" |
|
|
import { LuceneUtils, Constants } from "@budibase/frontend-core" |
|
|
import { getFields } from "helpers/searchFields" |
|
|
import { getFields } from "helpers/searchFields" |
|
|
import { createEventDispatcher } from "svelte" |
|
|
import { createEventDispatcher, onMount } from "svelte" |
|
|
|
|
|
|
|
|
const dispatch = createEventDispatcher() |
|
|
const dispatch = createEventDispatcher() |
|
|
|
|
|
|
|
|
@ -33,6 +32,11 @@ |
|
|
$: fieldOptions = enrichedSchemaFields.map(field => field.name) || [] |
|
|
$: fieldOptions = enrichedSchemaFields.map(field => field.name) || [] |
|
|
$: valueTypeOptions = allowBindings ? ["Value", "Binding"] : ["Value"] |
|
|
$: 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 = () => { |
|
|
const addFilter = () => { |
|
|
filters = [ |
|
|
filters = [ |
|
|
...filters, |
|
|
...filters, |
|
|
@ -99,6 +103,10 @@ |
|
|
const schema = enrichedSchemaFields.find(x => x.name === field) |
|
|
const schema = enrichedSchemaFields.find(x => x.name === field) |
|
|
return schema?.constraints?.inclusion || [] |
|
|
return schema?.constraints?.inclusion || [] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onMount(() => { |
|
|
|
|
|
behaviourValue = allOr ? "or" : "and" |
|
|
|
|
|
}) |
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<DrawerContent> |
|
|
<DrawerContent> |
|
|
@ -113,6 +121,21 @@ |
|
|
{/if} |
|
|
{/if} |
|
|
</Body> |
|
|
</Body> |
|
|
{#if filters?.length} |
|
|
{#if filters?.length} |
|
|
|
|
|
<div class="fields"> |
|
|
|
|
|
<Select |
|
|
|
|
|
label="Behaviour" |
|
|
|
|
|
value={behaviourValue} |
|
|
|
|
|
options={behaviourOptions} |
|
|
|
|
|
getOptionLabel={opt => opt.label} |
|
|
|
|
|
getOptionValue={opt => opt.value} |
|
|
|
|
|
on:change={e => (allOr = e.detail === "or")} |
|
|
|
|
|
placeholder={null} |
|
|
|
|
|
/> |
|
|
|
|
|
</div> |
|
|
|
|
|
<div> |
|
|
|
|
|
<div class="filter-label"> |
|
|
|
|
|
<Label>Filters</Label> |
|
|
|
|
|
</div> |
|
|
<div class="fields"> |
|
|
<div class="fields"> |
|
|
{#each filters as filter, idx} |
|
|
{#each filters as filter, idx} |
|
|
<Select |
|
|
<Select |
|
|
@ -185,17 +208,12 @@ |
|
|
/> |
|
|
/> |
|
|
{/each} |
|
|
{/each} |
|
|
</div> |
|
|
</div> |
|
|
|
|
|
</div> |
|
|
{/if} |
|
|
{/if} |
|
|
<div class="bottom"> |
|
|
<div class="bottom"> |
|
|
<Button icon="AddCircle" size="M" secondary on:click={addFilter}> |
|
|
<Button icon="AddCircle" size="M" secondary on:click={addFilter}> |
|
|
Add filter |
|
|
Add filter |
|
|
</Button> |
|
|
</Button> |
|
|
<div class="toggle"> |
|
|
|
|
|
<Toggle |
|
|
|
|
|
value={allOr} |
|
|
|
|
|
on:change={event => (allOr = event.detail)} |
|
|
|
|
|
/><Label size="L">OR conditions</Label> |
|
|
|
|
|
</div> |
|
|
|
|
|
</div> |
|
|
</div> |
|
|
</Layout> |
|
|
</Layout> |
|
|
</div> |
|
|
</div> |
|
|
@ -216,10 +234,8 @@ |
|
|
grid-template-columns: 1fr 120px 120px 1fr auto auto; |
|
|
grid-template-columns: 1fr 120px 120px 1fr auto auto; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.toggle { |
|
|
.filter-label { |
|
|
display: flex; |
|
|
margin-bottom: var(--spacing-s); |
|
|
align-items: center; |
|
|
|
|
|
padding-right: var(--spacing-s); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
.bottom { |
|
|
.bottom { |
|
|
|