diff --git a/packages/builder/src/components/design/AppPreview/CurrentItemPreview.svelte b/packages/builder/src/components/design/AppPreview/CurrentItemPreview.svelte index 8bf8570d31..28bc50d15a 100644 --- a/packages/builder/src/components/design/AppPreview/CurrentItemPreview.svelte +++ b/packages/builder/src/components/design/AppPreview/CurrentItemPreview.svelte @@ -68,6 +68,7 @@ customTheme: $store.customTheme, previewDevice: $store.previewDevice, messagePassing: $store.clientFeatures.messagePassing, + isBudibaseEvent: true } $: json = JSON.stringify(previewData) diff --git a/packages/builder/src/components/design/AppPreview/iframeTemplate.js b/packages/builder/src/components/design/AppPreview/iframeTemplate.js index 15321c5eff..c265a64d53 100644 --- a/packages/builder/src/components/design/AppPreview/iframeTemplate.js +++ b/packages/builder/src/components/design/AppPreview/iframeTemplate.js @@ -52,7 +52,7 @@ export default ` console.error("Client received invalid JSON") // Ignore } - if (!parsed) { + if (!parsed || !parsed.isBudibaseEvent) { return } diff --git a/packages/client/src/components/app/charts/ApexChart.svelte b/packages/client/src/components/app/charts/ApexChart.svelte index f3d745f4ba..eecf82d2ea 100644 --- a/packages/client/src/components/app/charts/ApexChart.svelte +++ b/packages/client/src/components/app/charts/ApexChart.svelte @@ -36,4 +36,13 @@ div :global(.apexcharts-datalabel) { fill: var(--spectrum-global-color-gray-800); } + div :global(.apexcharts-tooltip) { + background-color: var(--spectrum-global-color-gray-200) !important; + border-color: var(--spectrum-global-color-gray-300) !important; + box-shadow: 2px 2px 6px -4px rgba(0, 0, 0, 0.1) !important; + } + div :global(.apexcharts-tooltip-title) { + background-color: var(--spectrum-global-color-gray-100) !important; + border-color: var(--spectrum-global-color-gray-300) !important; + } diff --git a/packages/client/src/components/app/charts/BarChart.svelte b/packages/client/src/components/app/charts/BarChart.svelte index 9a340c404e..af1bb478fe 100644 --- a/packages/client/src/components/app/charts/BarChart.svelte +++ b/packages/client/src/components/app/charts/BarChart.svelte @@ -18,16 +18,53 @@ export let palette export let horizontal - $: options = setUpChart(dataProvider) + $: options = setUpChart( + title, + dataProvider, + labelColumn, + valueColumns, + xAxisLabel, + yAxisLabel, + height, + width, + dataLabels, + animate, + legend, + stacked, + yAxisUnits, + palette, + horizontal + ) - const setUpChart = provider => { + const setUpChart = ( + title, + dataProvider, + labelColumn, + valueColumns, + xAxisLabel, + yAxisLabel, + height, + width, + dataLabels, + animate, + legend, + stacked, + yAxisUnits, + palette, + horizontal + ) => { + console.log("new chart") const allCols = [labelColumn, ...(valueColumns || [null])] - if (!provider || !provider.rows?.length || allCols.find(x => x == null)) { + if ( + !dataProvider || + !dataProvider.rows?.length || + allCols.find(x => x == null) + ) { return null } // Fetch data - const { schema, rows } = provider + const { schema, rows } = dataProvider const reducer = row => (valid, column) => valid && row[column] != null const hasAllColumns = row => allCols.reduce(reducer(row), true) const data = rows.filter(row => hasAllColumns(row)).slice(0, 100) diff --git a/packages/client/src/components/app/charts/CandleStickChart.svelte b/packages/client/src/components/app/charts/CandleStickChart.svelte index b45e7fe663..b2760b005e 100644 --- a/packages/client/src/components/app/charts/CandleStickChart.svelte +++ b/packages/client/src/components/app/charts/CandleStickChart.svelte @@ -16,17 +16,48 @@ export let animate export let yAxisUnits - $: options = setUpChart(dataProvider) + $: options = setUpChart( + title, + dataProvider, + dateColumn, + openColumn, + highColumn, + lowColumn, + closeColumn, + xAxisLabel, + yAxisLabel, + height, + width, + animate, + yAxisUnits + ) - // Fetch data on mount - const setUpChart = provider => { + const setUpChart = ( + title, + dataProvider, + dateColumn, + openColumn, + highColumn, + lowColumn, + closeColumn, + xAxisLabel, + yAxisLabel, + height, + width, + animate, + yAxisUnits + ) => { const allCols = [dateColumn, openColumn, highColumn, lowColumn, closeColumn] - if (!provider || !provider.rows?.length || allCols.find(x => x == null)) { + if ( + !dataProvider || + !dataProvider.rows?.length || + allCols.find(x => x == null) + ) { return null } // Fetch data - const { schema, rows } = provider + const { schema, rows } = dataProvider const reducer = row => (valid, column) => valid && row[column] != null const hasAllColumns = row => allCols.reduce(reducer(row), true) const data = rows.filter(row => hasAllColumns(row)) diff --git a/packages/client/src/components/app/charts/LineChart.svelte b/packages/client/src/components/app/charts/LineChart.svelte index 2c05292670..afb9f14262 100644 --- a/packages/client/src/components/app/charts/LineChart.svelte +++ b/packages/client/src/components/app/charts/LineChart.svelte @@ -23,17 +23,56 @@ export let stacked export let gradient - $: options = setUpChart(dataProvider) + $: options = setUpChart( + title, + dataProvider, + labelColumn, + valueColumns, + xAxisLabel, + yAxisLabel, + height, + width, + animate, + dataLabels, + curve, + legend, + yAxisUnits, + palette, + area, + stacked, + gradient + ) - // Fetch data on mount - const setUpChart = provider => { + const setUpChart = ( + title, + dataProvider, + labelColumn, + valueColumns, + xAxisLabel, + yAxisLabel, + height, + width, + animate, + dataLabels, + curve, + legend, + yAxisUnits, + palette, + area, + stacked, + gradient + ) => { const allCols = [labelColumn, ...(valueColumns || [null])] - if (!provider || !provider.rows?.length || allCols.find(x => x == null)) { + if ( + !dataProvider || + !dataProvider.rows?.length || + allCols.find(x => x == null) + ) { return null } // Fetch, filter and sort data - const { schema, rows } = provider + const { schema, rows } = dataProvider const reducer = row => (valid, column) => valid && row[column] != null const hasAllColumns = row => allCols.reduce(reducer(row), true) const data = rows.filter(row => hasAllColumns(row)) diff --git a/packages/client/src/components/app/charts/PieChart.svelte b/packages/client/src/components/app/charts/PieChart.svelte index e14061407e..38a42ee37b 100644 --- a/packages/client/src/components/app/charts/PieChart.svelte +++ b/packages/client/src/components/app/charts/PieChart.svelte @@ -14,16 +14,44 @@ export let donut export let palette - $: options = setUpChart(dataProvider) + $: options = setUpChart( + title, + dataProvider, + labelColumn, + valueColumn, + height, + width, + dataLabels, + animate, + legend, + donut, + palette + ) - // Fetch data on mount - const setUpChart = provider => { - if (!provider || !provider.rows?.length || !labelColumn || !valueColumn) { + const setUpChart = ( + title, + dataProvider, + labelColumn, + valueColumn, + height, + width, + dataLabels, + animate, + legend, + donut, + palette + ) => { + if ( + !dataProvider || + !dataProvider.rows?.length || + !labelColumn || + !valueColumn + ) { return null } // Fetch, filter and sort data - const { schema, rows } = provider + const { schema, rows } = dataProvider const data = rows .filter(row => row[labelColumn] != null && row[valueColumn] != null) .slice(0, 100) diff --git a/packages/client/src/components/app/dynamic-filter/FilterModal.svelte b/packages/client/src/components/app/dynamic-filter/FilterModal.svelte index 447bdc1058..54ad1f3a80 100644 --- a/packages/client/src/components/app/dynamic-filter/FilterModal.svelte +++ b/packages/client/src/components/app/dynamic-filter/FilterModal.svelte @@ -4,7 +4,6 @@ Button, Combobox, DatePicker, - DrawerContent, Icon, Input, Layout, @@ -12,10 +11,12 @@ } from "@budibase/bbui" import { generate } from "shortid" import { LuceneUtils, Constants } from "@budibase/frontend-core" + import { getContext } from "svelte" export let schemaFields export let filters = [] + const context = getContext("context") const BannedTypes = ["link", "attachment", "json"] $: fieldOptions = (schemaFields ?? []) @@ -89,55 +90,55 @@ } - -
- - - {#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, idx} - onFieldChange(filter, e.detail)} + placeholder="Column" + /> + + {:else if ["options", "array"].includes(filter.type)} + - - {:else if ["options", "array"].includes(filter.type)} - - {:else if filter.type === "boolean"} - - {:else if filter.type === "datetime"} - - {:else} - - {/if} + {:else if filter.type === "datetime"} + + {:else} + + {/if} +
removeFilter(filter.id)} /> - {/each} -
- {/if} -
- +
+ {/each}
-
-
-
+ {/if} +
+ +
+ + diff --git a/packages/client/src/components/app/forms/InnerForm.svelte b/packages/client/src/components/app/forms/InnerForm.svelte index 1c757e131e..b82070681b 100644 --- a/packages/client/src/components/app/forms/InnerForm.svelte +++ b/packages/client/src/components/app/forms/InnerForm.svelte @@ -157,13 +157,9 @@ const { fieldState } = get(existingField) fieldId = fieldState.fieldId - // Use new default value if default value changed, - // otherwise use the current value if possible - if (defaultValue !== fieldState.defaultValue) { - initialValue = defaultValue - } else { - initialValue = fieldState.value ?? initialValue - } + // Determine the initial value for this field, reusing the current + // value if one exists + initialValue = fieldState.value ?? initialValue // If this field has already been registered and we previously had an // error set, then re-run the validator to see if we can unset it diff --git a/packages/client/src/stores/auth.js b/packages/client/src/stores/auth.js index 39f11319cf..214cc7bce2 100644 --- a/packages/client/src/stores/auth.js +++ b/packages/client/src/stores/auth.js @@ -6,12 +6,26 @@ const createAuthStore = () => { // Fetches the user object if someone is logged in and has reloaded the page const fetchUser = async () => { + let globalSelf = null + let appSelf = null + + // First try and get the global user, to see if we are logged in at all try { - const user = await API.fetchSelf() - store.set(user) + globalSelf = await API.fetchBuilderSelf() } catch (error) { store.set(null) + return } + + // Then try and get the user for this app to provide via context + try { + appSelf = await API.fetchSelf() + } catch (error) { + // Swallow + } + + // Use the app self if present, otherwise fallback to the global self + store.set(appSelf || globalSelf || null) } const logOut = async () => {