diff --git a/packages/builder/src/builderStore/store/backend.js b/packages/builder/src/builderStore/store/backend.js index 967f9c7545..3295b82006 100644 --- a/packages/builder/src/builderStore/store/backend.js +++ b/packages/builder/src/builderStore/store/backend.js @@ -1,21 +1,13 @@ import { writable } from "svelte/store" +const INITIAL_BACKEND_UI_STATE = { +} + export const getBackendUiStore = () => { - const store = writable({}) + const store = writable({ ...INITIAL_BACKEND_UI_STATE }) store.actions = { - rows: { - save: () => - store.update(state => { - state.selectedView = state.selectedView - return state - }), - delete: () => - store.update(state => { - state.selectedView = state.selectedView - return state - }), - }, + reset: () => store.set({ ...INITIAL_BACKEND_UI_STATE }), } return store diff --git a/packages/builder/src/builderStore/store/backend/index.js b/packages/builder/src/builderStore/store/backend/index.js index 441d9d6b5e..e020baaf4b 100644 --- a/packages/builder/src/builderStore/store/backend/index.js +++ b/packages/builder/src/builderStore/store/backend/index.js @@ -1,6 +1,7 @@ export { database } from "./database" export { tables } from "./tables" export { views } from "./views" +export { rows } from "./rows" export { permissions } from "./permissions" export { roles } from "./roles" export { datasources } from "./datasources" diff --git a/packages/builder/src/builderStore/store/backend/rows.js b/packages/builder/src/builderStore/store/backend/rows.js new file mode 100644 index 0000000000..0d63bbb64f --- /dev/null +++ b/packages/builder/src/builderStore/store/backend/rows.js @@ -0,0 +1,15 @@ +import { writable,get } from "svelte/store" +import { views } from './' + +function createRowsStore() { + const { subscribe } = writable([]) + + return { + subscribe, + save: () => views.select(get(views).selected), + delete: () => views.select(get(views).selected), + } +} + +export const rows = createRowsStore() + diff --git a/packages/builder/src/builderStore/store/backend/views.js b/packages/builder/src/builderStore/store/backend/views.js index 1b98ef9f8a..9c32c3da9f 100644 --- a/packages/builder/src/builderStore/store/backend/views.js +++ b/packages/builder/src/builderStore/store/backend/views.js @@ -3,7 +3,7 @@ import { tables } from "./" import api from "../../api" function createViewsStore() { - const { subscribe, set, update } = writable({ + const { subscribe, update } = writable({ list: [], selected: null }) @@ -15,7 +15,6 @@ function createViewsStore() { ...state, selected: view, })) - tables.select() }, delete: async view => { await api.delete(`/api/views/${view}`) diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditRow.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditRow.svelte index bc2098a9fa..d1fb8771a9 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditRow.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditRow.svelte @@ -1,6 +1,5 @@ diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditUser.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditUser.svelte index a7b4df5058..9d020f7c6e 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditUser.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditUser.svelte @@ -1,6 +1,5 @@ diff --git a/packages/builder/src/components/backend/DataTable/modals/DeleteRow.svelte b/packages/builder/src/components/backend/DataTable/modals/DeleteRow.svelte index a28d90de0c..dc20a65562 100644 --- a/packages/builder/src/components/backend/DataTable/modals/DeleteRow.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/DeleteRow.svelte @@ -1,5 +1,5 @@