diff --git a/packages/bbui/src/Form/Core/Picker.svelte b/packages/bbui/src/Form/Core/Picker.svelte
index 16d13ef2cc..97bd1394b4 100644
--- a/packages/bbui/src/Form/Core/Picker.svelte
+++ b/packages/bbui/src/Form/Core/Picker.svelte
@@ -205,7 +205,10 @@
width: 100%;
}
.spectrum-Popover.auto-width :global(.spectrum-Menu-itemLabel) {
+ max-width: 400px;
white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
}
.spectrum-Picker {
width: 100%;
diff --git a/packages/builder/src/builderStore/dataBinding.js b/packages/builder/src/builderStore/dataBinding.js
index 536692eecc..d188073b95 100644
--- a/packages/builder/src/builderStore/dataBinding.js
+++ b/packages/builder/src/builderStore/dataBinding.js
@@ -481,6 +481,7 @@ const getSelectedRowsBindings = asset => {
block._id + "-table"
)}.${makePropSafe("selectedRows")}`,
readableBinding: `${block._instanceName}.Selected rows`,
+ category: "Selected rows",
}))
)
}
@@ -1004,7 +1005,10 @@ const bindingReplacement = (
* {{ literal [componentId] }}
*/
const extractLiteralHandlebarsID = value => {
- return value?.match(/{{\s*literal\s*\[+([^\]]+)].*}}/)?.[1]
+ if (!value || typeof value !== "string") {
+ return null
+ }
+ return value.match(/{{\s*literal\s*\[+([^\]]+)].*}}/)?.[1]
}
/**
diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js
index e831f6a343..b596a13450 100644
--- a/packages/builder/src/builderStore/store/frontend.js
+++ b/packages/builder/src/builderStore/store/frontend.js
@@ -1049,8 +1049,8 @@ export const getFrontendStore = () => {
const updatedSetting = settings.find(setting => setting.key === name)
if (
- updatedSetting.type === "dataSource" ||
- updatedSetting.type === "table"
+ updatedSetting?.type === "dataSource" ||
+ updatedSetting?.type === "table"
) {
const { schema } = getSchemaForDatasource(null, value)
const columnNames = Object.keys(schema || {})
diff --git a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte
index 4fd2f40391..d09faa34c9 100644
--- a/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte
+++ b/packages/builder/src/components/automation/SetupPanel/AutomationBlockSetup.svelte
@@ -38,13 +38,15 @@
export let testData
export let schemaProperties
export let isTestModal = false
+
let webhookModal
let drawer
- let tempFilters = lookForFilters(schemaProperties) || []
let fillWidth = true
let codeBindingOpen = false
let inputData
+ $: filters = lookForFilters(schemaProperties) || []
+ $: tempFilters = filters
$: stepId = block.stepId
$: bindings = getAvailableBindings(
block || $automationStore.selectedBlock,
@@ -222,16 +224,17 @@
{:else if value.customType === "filters"}
Define filters
- saveFilters(key)}
- >Save
+ saveFilters(key)}>
+ Save
+
(tempFilters = e.detail)}
/>
{:else if value.customType === "password"}
diff --git a/packages/builder/src/components/backend/DataTable/DataTable.svelte b/packages/builder/src/components/backend/DataTable/DataTable.svelte
index 7cb368830e..6a135b5428 100644
--- a/packages/builder/src/components/backend/DataTable/DataTable.svelte
+++ b/packages/builder/src/components/backend/DataTable/DataTable.svelte
@@ -25,6 +25,7 @@
import { API } from "api"
let hideAutocolumns = true
+ let filters
$: isUsersTable = $tables.selected?._id === TableNames.USERS
$: type = $tables.selected?.type
@@ -102,8 +103,9 @@
// Fetch data whenever filters change
const onFilter = e => {
+ filters = e.detail
fetch.update({
- filter: e.detail,
+ filter: filters,
})
}
@@ -178,6 +180,7 @@
{#key id}
diff --git a/packages/builder/src/components/backend/DataTable/buttons/TableFilterButton.svelte b/packages/builder/src/components/backend/DataTable/buttons/TableFilterButton.svelte
index 633c7e1ad1..be9c6259c6 100644
--- a/packages/builder/src/components/backend/DataTable/buttons/TableFilterButton.svelte
+++ b/packages/builder/src/components/backend/DataTable/buttons/TableFilterButton.svelte
@@ -8,9 +8,10 @@
export let disabled = false
const dispatch = createEventDispatcher()
- let modal
- let tempValue = filters || []
+ let modal
+
+ $: tempValue = filters || []
$: schemaFields = Object.values(schema || {})
@@ -34,8 +35,9 @@
(tempValue = e.detail)}
/>
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 019a61a3bf..d495e37216 100644
--- a/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte
+++ b/packages/builder/src/components/design/settings/controls/FilterEditor/FilterDrawer.svelte
@@ -17,22 +17,30 @@
import { generate } from "shortid"
import { LuceneUtils, Constants } from "@budibase/frontend-core"
import { getFields } from "helpers/searchFields"
- import { createEventDispatcher, onMount } from "svelte"
-
- const dispatch = createEventDispatcher()
- const { OperatorOptions } = Constants
- const { getValidOperatorsForType } = LuceneUtils
+ import { createEventDispatcher } from "svelte"
export let schemaFields
export let filters = []
export let bindings = []
export let panel = ClientBindingPanel
export let allowBindings = true
- export let allOr = false
export let fillWidth = false
export let tableId
- $: dispatch("change", filters)
+ const dispatch = createEventDispatcher()
+ const { OperatorOptions } = Constants
+ const { getValidOperatorsForType } = LuceneUtils
+ const KeyedFieldRegex = /\d[0-9]*:/g
+ const behaviourOptions = [
+ { value: "and", label: "Match all filters" },
+ { value: "or", label: "Match any filter" },
+ ]
+
+ let rawFilters
+ let matchAny = false
+
+ $: parseFilters(filters)
+ $: dispatch("change", enrichFilters(rawFilters, matchAny))
$: enrichedSchemaFields = getFields(
schemaFields || [],
{ allowLinks: true },
@@ -41,14 +49,41 @@
$: 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" },
- ]
+ // Remove field key prefixes and determine whether to use the "match all"
+ // or "match any" behaviour
+ const parseFilters = filters => {
+ matchAny = filters?.find(filter => filter.operator === "allOr") != null
+ rawFilters = (filters || [])
+ .filter(filter => filter.operator !== "allOr")
+ .map(filter => {
+ const { field } = filter
+ let newFilter = { ...filter }
+ delete newFilter.allOr
+ if (typeof field === "string" && field.match(KeyedFieldRegex) != null) {
+ const parts = field.split(":")
+ parts.shift()
+ newFilter.field = parts.join(":")
+ }
+ return newFilter
+ })
+ }
+
+ // Add field key prefixes and a special metadata filter object to indicate
+ // whether to use the "match all" or "match any" behaviour
+ const enrichFilters = (rawFilters, matchAny) => {
+ let count = 1
+ return rawFilters
+ .filter(filter => filter.field)
+ .map(filter => ({
+ ...filter,
+ field: `${count++}:${filter.field}`,
+ }))
+ .concat(matchAny ? [{ operator: "allOr" }] : [])
+ }
+
const addFilter = () => {
- filters = [
- ...filters,
+ rawFilters = [
+ ...rawFilters,
{
id: generate(),
field: null,
@@ -60,13 +95,13 @@
}
const removeFilter = id => {
- filters = filters.filter(field => field.id !== id)
+ rawFilters = rawFilters.filter(field => field.id !== id)
}
const duplicateFilter = id => {
- const existingFilter = filters.find(filter => filter.id === id)
+ const existingFilter = rawFilters.find(filter => filter.id === id)
const duplicate = { ...existingFilter, id: generate() }
- filters = [...filters, duplicate]
+ rawFilters = [...rawFilters, duplicate]
}
const getSchema = filter => {
@@ -133,32 +168,22 @@
const schema = enrichedSchemaFields.find(x => x.name === field)
return schema?.constraints?.inclusion || []
}
-
- onMount(() => {
- behaviourValue = allOr ? "or" : "and"
- })
-
- {#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}
+ {#if !rawFilters?.length}
+ Add your first filter expression.
+ {:else}
opt.label}
getOptionValue={opt => opt.value}
- on:change={e => (allOr = e.detail === "or")}
+ on:change={e => (matchAny = e.detail === "or")}
placeholder={null}
/>
@@ -167,7 +192,7 @@
Filters
- {#each filters as filter, idx}
+ {#each rawFilters as filter, idx}
filter.operator !== "allOr")
- if (allOr && filters) {
- filters.push({ operator: "allOr" })
- }
- // only save if anything was updated
- if (filters) {
- dispatch("change", addNumbering(filters))
- }
- notifications.success("Filters saved.")
+ dispatch("change", tempValue)
+ notifications.success("Filters saved")
drawer.hide()
}
@@ -85,13 +33,10 @@
Save
{
- toSaveFilters = event.detail
- }}
+ on:change={e => (tempValue = e.detail)}
/>
diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/AppPanel.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/AppPanel.svelte
index c4b80dcc3a..e97e3ee15c 100644
--- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/AppPanel.svelte
+++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/_components/AppPanel.svelte
@@ -61,6 +61,13 @@
align-items: center;
gap: var(--spacing-l);
}
+ .header-left {
+ flex: 1 1 auto;
+ width: 0;
+ }
+ .header-left :global(> *) {
+ max-width: 100%;
+ }
.header-left :global(.spectrum-Picker) {
font-weight: 600;
color: var(--spectrum-global-color-gray-900);
diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/settings/ConditionalUIDrawer.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/settings/ConditionalUIDrawer.svelte
index 74f0c930cd..855c42173b 100644
--- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/settings/ConditionalUIDrawer.svelte
+++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/settings/ConditionalUIDrawer.svelte
@@ -282,12 +282,16 @@
gap: var(--spacing-l);
display: grid;
align-items: center;
- grid-template-columns: auto 160px auto 1fr 130px 130px 1fr auto auto;
+ grid-template-columns:
+ auto 150px auto minmax(140px, 1fr) 120px 100px minmax(140px, 1fr)
+ auto auto;
border-radius: var(--border-radius-s);
transition: background-color ease-in-out 130ms;
}
.condition.update {
- grid-template-columns: auto 160px 1fr auto 1fr auto 1fr 130px 130px 1fr auto auto;
+ grid-template-columns:
+ auto 150px minmax(140px, 1fr) auto minmax(140px, 1fr) auto
+ minmax(140px, 1fr) 120px 100px minmax(140px, 1fr) auto auto;
}
.condition:hover {
background-color: var(--spectrum-global-color-gray-100);
diff --git a/packages/client/src/components/app/SidePanel.svelte b/packages/client/src/components/app/SidePanel.svelte
index 8731c7191e..825b401bb8 100644
--- a/packages/client/src/components/app/SidePanel.svelte
+++ b/packages/client/src/components/app/SidePanel.svelte
@@ -29,6 +29,17 @@
// Derive visibility
$: open = $sidePanelStore.contentId === $component.id
+ // Derive a render key which is only changed whenever this panel is made
+ // visible after being hidden. We need to key the content to avoid showing
+ // stale data when re-revealing a side panel that was closed, but we cannot
+ // hide the content altogether when hidden as this breaks ejection.
+ let renderKey = null
+ $: {
+ if (open) {
+ renderKey = Math.random()
+ }
+ }
+
const showInSidePanel = (el, visible) => {
const update = visible => {
const target = document.getElementById("side-panel-container")
@@ -47,7 +58,10 @@
// Apply initial visibility
update(visible)
- return { update }
+ return {
+ update,
+ destroy: () => update(false),
+ }
}
@@ -57,9 +71,9 @@
class="side-panel"
class:open
>
- {#if $sidePanelStore.open}
+ {#key renderKey}
- {/if}
+ {/key}