move rows to it's separate store
This commit is contained in:
parent
9d3088c3f3
commit
3e58ad9031
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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()
|
||||
|
|
@ -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}`)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<script>
|
||||
import { backendUiStore } from "builderStore"
|
||||
import { tables } from 'builderStore/store/backend/'
|
||||
import { tables, rows } from 'builderStore/store/backend/'
|
||||
import { notifier } from "builderStore/store/notifications"
|
||||
import RowFieldControl from "../RowFieldControl.svelte"
|
||||
import * as api from "../api"
|
||||
|
@ -35,7 +34,7 @@
|
|||
}
|
||||
|
||||
notifier.success("Row saved successfully.")
|
||||
backendUiStore.actions.rows.save(rowResponse)
|
||||
rows.save(rowResponse)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
<script>
|
||||
import { backendUiStore } from "builderStore"
|
||||
import { tables } from 'builderStore/store/backend/'
|
||||
import { tables, rows } from 'builderStore/store/backend/'
|
||||
import { roles } from 'builderStore/store/backend/'
|
||||
import { notifier } from "builderStore/store/notifications"
|
||||
import RowFieldControl from "../RowFieldControl.svelte"
|
||||
|
@ -68,7 +67,7 @@
|
|||
}
|
||||
|
||||
notifier.success("User saved successfully.")
|
||||
backendUiStore.actions.rows.save(rowResponse)
|
||||
rows.save(rowResponse)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script>
|
||||
import { backendUiStore } from "builderStore"
|
||||
import { rows } from 'builderStore/store/backend/'
|
||||
import * as api from "../api"
|
||||
import { notifier } from "builderStore/store/notifications"
|
||||
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
|
||||
|
@ -15,7 +15,7 @@
|
|||
async function deleteRow() {
|
||||
await api.deleteRow(row)
|
||||
notifier.success("Row deleted")
|
||||
backendUiStore.actions.rows.delete(row)
|
||||
rows.delete(row)
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Reference in New Issue