Browse Source

adds an init method to the tables store

gh-pages
Keviin Åberg Kultalahti 6 years ago
parent
commit
7bb01a152c
  1. 10
      packages/builder/src/builderStore/store/frontend.js
  2. 10
      packages/builder/src/stores/backend/tables.js

10
packages/builder/src/builderStore/store/frontend.js

@ -69,20 +69,14 @@ export const getFrontendStore = () => {
// Initialise backend stores // Initialise backend stores
const [ const [
_integrations, _integrations,
_tables,
] = await Promise.all([ ] = await Promise.all([
api.get("/api/integrations").then(r => r.json()), api.get("/api/integrations").then(r => r.json())
api.get(`/api/tables`).then(r => r.json()),
]) ])
datasources.init() datasources.init()
integrations.set(_integrations) integrations.set(_integrations)
queries.init() queries.init()
database.set(application.instance) database.set(application.instance)
tables.set({ tables.init()
list: _tables,
selected: {},
draft: {},
})
}, },
routing: { routing: {
fetch: async () => { fetch: async () => {

10
packages/builder/src/stores/backend/tables.js

@ -71,10 +71,18 @@ export function createTablesStore() {
return { return {
subscribe, subscribe,
set,
fetch, fetch,
select, select,
save, save,
init: async () => {
const response = await api.get("/api/tables")
const json = await response.json()
set({
list: json,
selected: {},
draft: {},
})
},
delete: async table => { delete: async table => {
await api.delete(`/api/tables/${table._id}/${table._rev}`) await api.delete(`/api/tables/${table._id}/${table._rev}`)
update(state => ({ update(state => ({

Loading…
Cancel
Save