Merge pull request #7729 from Budibase/cheeks-fixes
Fix client side lucene filtering
This commit is contained in:
commit
4891943f53
|
@ -127,7 +127,9 @@
|
||||||
// Empty components are those which accept children but do not have any.
|
// Empty components are those which accept children but do not have any.
|
||||||
// Empty states can be shown for these components, but can be disabled
|
// Empty states can be shown for these components, but can be disabled
|
||||||
// in the component manifest.
|
// in the component manifest.
|
||||||
$: empty = interactive && !children.length && hasChildren
|
$: empty =
|
||||||
|
(interactive && !children.length && hasChildren) ||
|
||||||
|
hasMissingRequiredSettings
|
||||||
$: emptyState = empty && showEmptyState
|
$: emptyState = empty && showEmptyState
|
||||||
|
|
||||||
// Enrich component settings
|
// Enrich component settings
|
||||||
|
|
|
@ -2,28 +2,25 @@
|
||||||
import { getContext } from "svelte"
|
import { getContext } from "svelte"
|
||||||
import { builderStore } from "stores"
|
import { builderStore } from "stores"
|
||||||
|
|
||||||
const { styleable } = getContext("sdk")
|
|
||||||
const component = getContext("component")
|
const component = getContext("component")
|
||||||
|
|
||||||
$: requiredSetting = $component.missingRequiredSettings?.[0]
|
$: requiredSetting = $component.missingRequiredSettings?.[0]
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if $builderStore.inBuilder && requiredSetting}
|
{#if $builderStore.inBuilder && requiredSetting}
|
||||||
<div use:styleable={$component.styles}>
|
<div class="component-placeholder">
|
||||||
<div class="component-placeholder">
|
<span>
|
||||||
<span>
|
Add the <mark>{requiredSetting.label}</mark> setting to start using your component
|
||||||
Add the <mark>{requiredSetting.label}</mark> setting to start using your
|
-
|
||||||
component -
|
</span>
|
||||||
</span>
|
<span
|
||||||
<span
|
class="spectrum-Link"
|
||||||
class="spectrum-Link"
|
on:click={() => {
|
||||||
on:click={() => {
|
builderStore.actions.highlightSetting(requiredSetting.key)
|
||||||
builderStore.actions.highlightSetting(requiredSetting.key)
|
}}
|
||||||
}}
|
>
|
||||||
>
|
Show me
|
||||||
Show me
|
</span>
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
import { getContext } from "svelte"
|
import { getContext } from "svelte"
|
||||||
import { ProgressCircle, Pagination } from "@budibase/bbui"
|
import { ProgressCircle, Pagination } from "@budibase/bbui"
|
||||||
import Placeholder from "./Placeholder.svelte"
|
|
||||||
import { fetchData, LuceneUtils } from "@budibase/frontend-core"
|
import { fetchData, LuceneUtils } from "@budibase/frontend-core"
|
||||||
|
|
||||||
export let dataSource
|
export let dataSource
|
||||||
|
@ -133,11 +132,7 @@
|
||||||
<ProgressCircle />
|
<ProgressCircle />
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
{#if $component.emptyState}
|
<slot />
|
||||||
<Placeholder />
|
|
||||||
{:else}
|
|
||||||
<slot />
|
|
||||||
{/if}
|
|
||||||
{#if paginate && $fetch.supportsPagination}
|
{#if paginate && $fetch.supportsPagination}
|
||||||
<div class="pagination">
|
<div class="pagination">
|
||||||
<Pagination
|
<Pagination
|
||||||
|
|
|
@ -80,6 +80,19 @@ const cleanupQuery = query => {
|
||||||
return query
|
return query
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a numeric prefix on field names designed to give fields uniqueness
|
||||||
|
*/
|
||||||
|
const removeKeyNumbering = key => {
|
||||||
|
if (typeof key === "string" && key.match(/\d[0-9]*:/g) != null) {
|
||||||
|
const parts = key.split(":")
|
||||||
|
parts.shift()
|
||||||
|
return parts.join(":")
|
||||||
|
} else {
|
||||||
|
return key
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a lucene JSON query from the filter structure generated in the builder
|
* Builds a lucene JSON query from the filter structure generated in the builder
|
||||||
* @param filter the builder filter structure
|
* @param filter the builder filter structure
|
||||||
|
@ -194,7 +207,7 @@ export const runLuceneQuery = (docs, query) => {
|
||||||
const filters = Object.entries(query[type] || {})
|
const filters = Object.entries(query[type] || {})
|
||||||
for (let i = 0; i < filters.length; i++) {
|
for (let i = 0; i < filters.length; i++) {
|
||||||
const [key, testValue] = filters[i]
|
const [key, testValue] = filters[i]
|
||||||
const docValue = Helpers.deepGet(doc, key)
|
const docValue = Helpers.deepGet(doc, removeKeyNumbering(key))
|
||||||
if (failFn(docValue, testValue)) {
|
if (failFn(docValue, testValue)) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue