From e57dda576b114972c3743aac4a88126feec150f1 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Tue, 18 Aug 2020 17:14:26 +0100 Subject: [PATCH] tidy up and lint :sparkles: --- .../builder/src/builderStore/store/backend.js | 14 +++++--- .../database/DataTable/ModelDataTable.svelte | 5 ++- .../database/DataTable/ViewDataTable.svelte | 35 ++++++++----------- .../DataTable/popovers/GroupBy.svelte | 5 ++- .../database/DataTable/popovers/View.svelte | 7 +++- .../nav/ModelNavigator/EditView.svelte | 2 +- .../[application]/backend/_layout.svelte | 2 +- packages/server/src/api/controllers/model.js | 1 + packages/server/src/api/controllers/record.js | 7 ++-- .../server/src/api/controllers/view/index.js | 7 ++-- .../src/api/controllers/view/viewBuilder.js | 14 +++----- packages/server/src/app.js | 2 +- packages/server/src/electron.js | 4 +-- 13 files changed, 53 insertions(+), 52 deletions(-) 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 @@ } - - - -
\ No newline at end of file + + + +
diff --git a/packages/builder/src/components/database/DataTable/popovers/GroupBy.svelte b/packages/builder/src/components/database/DataTable/popovers/GroupBy.svelte index 241933ebb3..e7d9f10754 100644 --- a/packages/builder/src/components/database/DataTable/popovers/GroupBy.svelte +++ b/packages/builder/src/components/database/DataTable/popovers/GroupBy.svelte @@ -19,8 +19,7 @@ $: viewModel = $backendUiStore.models.find( ({ _id }) => _id === $backendUiStore.selectedView.modelId ) - $: fields = - viewModel && Object.keys(viewModel.schema) + $: fields = viewModel && Object.keys(viewModel.schema) function saveView() { backendUiStore.actions.views.save(view) @@ -40,7 +39,7 @@

Group By