diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js index 25eb24d79b..a5a79ead64 100644 --- a/packages/builder/src/builderStore/store/backend.js +++ b/packages/builder/src/builderStore/store/backend.js @@ -83,8 +83,10 @@ export const getBackendUiStore = () => { delete: async model => { await api.delete(`/api/models/${model._id}/${model._rev}`) store.update(state => { - state.models = state.models.filter(existing => existing._id !== model._id) - state.selectedModel = state.models[0] || {} + state.models = state.models.filter( + existing => existing._id !== model._id + ) + state.selectedModel = state.models[0] || {} return state }) }, @@ -105,7 +107,7 @@ export const getBackendUiStore = () => { store.actions.models.save(state.draftModel) return state }) - } + }, }, views: { select: view => @@ -126,7 +128,9 @@ export const getBackendUiStore = () => { await api.post(`/api/views`, view) store.update(state => { - const viewModel = state.models.find(model => model._id === view.modelId) + const viewModel = state.models.find( + model => model._id === view.modelId + ) // TODO: Cleaner? if (!viewModel.views) viewModel.views = {} if (view.originalName) delete viewModel.views[view.originalName] @@ -136,7 +140,7 @@ export const getBackendUiStore = () => { state.selectedView = view return state }) - } + }, }, users: { create: user => diff --git a/packages/builder/src/components/database/DataTable/ModelDataTable.svelte b/packages/builder/src/components/database/DataTable/ModelDataTable.svelte index 486eec5633..2b1f9288c4 100644 --- a/packages/builder/src/components/database/DataTable/ModelDataTable.svelte +++ b/packages/builder/src/components/database/DataTable/ModelDataTable.svelte @@ -27,7 +27,10 @@ let search $: { - if ($backendUiStore.selectedView && $backendUiStore.selectedView.name.startsWith("all_")) { + if ( + $backendUiStore.selectedView && + $backendUiStore.selectedView.name.startsWith("all_") + ) { api.fetchDataForView($backendUiStore.selectedView).then(records => { data = records || [] }) diff --git a/packages/builder/src/components/database/DataTable/ViewDataTable.svelte b/packages/builder/src/components/database/DataTable/ViewDataTable.svelte index 5c1317dd24..b42aec4b91 100644 --- a/packages/builder/src/components/database/DataTable/ViewDataTable.svelte +++ b/packages/builder/src/components/database/DataTable/ViewDataTable.svelte @@ -30,37 +30,36 @@ }, { name: "min", - key: "value.min" + key: "value.min", }, { name: "max", - key: "value.max" + key: "value.max", }, { name: "sumsqr", - key: "value.sumsqr" + key: "value.sumsqr", }, { name: "count", - key: "value.count" + key: "value.count", }, { name: "avg", - key: "value.avg" - } + key: "value.avg", + }, ] export let view = {} let data = [] - $: viewName = view.name - $: !viewName.startsWith("all_") && fetchViewData(viewName) + $: !view.name.startsWith("all_") && fetchViewData(view) - async function fetchViewData(viewName) { - let QUERY_VIEW_URL = `/api/views/${viewName}?stats=true` - if (view.groupBy) { - QUERY_VIEW_URL += `&group=${view.groupBy}` + async function fetchViewData({ name, groupBy }) { + let QUERY_VIEW_URL = `/api/views/${name}?stats=true` + if (groupBy) { + QUERY_VIEW_URL += `&group=${groupBy}` } const response = await api.get(QUERY_VIEW_URL) @@ -68,11 +67,7 @@ } -
Group By