This commit is contained in:
Keviin Åberg Kultalahti 2021-03-23 13:31:18 +01:00
parent 8f0324bd53
commit 976d8b3b54
10 changed files with 134 additions and 125 deletions

View File

@ -1,7 +1,10 @@
import { cloneDeep } from "lodash/fp"
import { get } from "svelte/store"
import { store } from "builderStore"
import { tables as tablesStore, queries as queriesStores } from 'builderStore/store/backend/'
import {
tables as tablesStore,
queries as queriesStores,
} from "builderStore/store/backend/"
import { findComponentPath } from "./storeUtils"
import { makePropSafe } from "@budibase/string-templates"
import { TableNames } from "../constants"

View File

@ -1,7 +1,6 @@
import { writable } from "svelte/store"
const INITIAL_BACKEND_UI_STATE = {
}
const INITIAL_BACKEND_UI_STATE = {}
export const getBackendUiStore = () => {
const store = writable({ ...INITIAL_BACKEND_UI_STATE })

View File

@ -1,4 +1,4 @@
import { writable } from "svelte/store"
import { writable, get } from "svelte/store"
import { datasources, integrations } from "./"
import api from "../../api"
@ -55,9 +55,7 @@ function createQueriesStore() {
delete: async query => {
await api.delete(`/api/queries/${query._id}/${query._rev}`)
update(state => {
state.list = state.list.filter(
existing => existing._id !== query._id
)
state.list = state.list.filter(existing => existing._id !== query._id)
if (state.selected === query._id) {
state.selected = null
}

View File

@ -1,5 +1,5 @@
import { writable, get } from "svelte/store"
import { views } from './'
import { views } from "./"
function createRowsStore() {
const { subscribe } = writable([])
@ -12,4 +12,3 @@ function createRowsStore() {
}
export const rows = createRowsStore()

View File

@ -1,5 +1,5 @@
import { writable, get } from "svelte/store"
import { views } from './'
import { views } from "./"
import { cloneDeep } from "lodash/fp"
import api from "../../api"
@ -19,13 +19,13 @@ function createTablesStore() {
async function select(table) {
if (!table) {
console.log('Setting selected to null')
console.log("Setting selected to null")
update(state => ({
...state,
selected: {}
selected: {},
}))
} else {
console.log('Setting selected to null')
console.log("Setting selected to null")
update(state => ({
...state,
selected: table,
@ -81,7 +81,7 @@ function createTablesStore() {
update(state => ({
...state,
list: state.list.filter(existing => existing._id !== table._id),
selected: {}
selected: {},
}))
},
saveField: ({ originalName, field, primaryDisplay = false, indexes }) => {

View File

@ -5,7 +5,7 @@ import api from "../../api"
function createViewsStore() {
const { subscribe, update } = writable({
list: [],
selected: null
selected: null,
})
return {

View File

@ -9,7 +9,13 @@ import {
selectedAccessRole,
} from "builderStore"
// Backendstores
import { datasources, integrations, queries, database, tables } from 'builderStore/store/backend/'
import {
datasources,
integrations,
queries,
database,
tables,
} from "builderStore/store/backend/"
import { fetchComponentLibDefinitions } from "../loadComponentLibraries"
import api from "../api"
@ -61,7 +67,12 @@ export const getFrontendStore = () => {
await hostingStore.actions.fetch()
// Initialise backend stores
const [_datasources, _integrations, _queries, _tables] = await Promise.all([
const [
_datasources,
_integrations,
_queries,
_tables,
] = await Promise.all([
api.get(`/api/datasources`).then(r => r.json()),
api.get("/api/integrations").then(r => r.json()),
api.get(`/api/queries`).then(r => r.json()),
@ -74,9 +85,8 @@ export const getFrontendStore = () => {
tables.set({
list: _tables,
selected: {},
draft: {}
draft: {},
})
},
routing: {
fetch: async () => {