table, view, datasource selection logic
This commit is contained in:
parent
f7e3aafc4d
commit
7cb3a910a7
|
@ -53,7 +53,9 @@
|
|||
bind:hideAutocolumns
|
||||
{loading}
|
||||
>
|
||||
<CreateColumnButton />
|
||||
{#if isInternal}
|
||||
<CreateColumnButton />
|
||||
{/if}
|
||||
{#if schema && Object.keys(schema).length > 0}
|
||||
{#if !isUsersTable}
|
||||
<CreateRowButton
|
||||
|
|
|
@ -15,9 +15,6 @@
|
|||
}
|
||||
|
||||
function onClickQuery(query) {
|
||||
if ($queries.selected === query._id) {
|
||||
return
|
||||
}
|
||||
queries.select(query)
|
||||
$goto(`./datasource/${query.datasourceId}/${query._id}`)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { writable } from "svelte/store"
|
||||
import { queries } from "./"
|
||||
import { queries, tables, views } from "./"
|
||||
import api from "../../builderStore/api"
|
||||
|
||||
export const INITIAL_DATASOURCE_VALUES = {
|
||||
|
@ -26,7 +26,12 @@ export function createDatasourcesStore() {
|
|||
},
|
||||
select: async datasourceId => {
|
||||
update(state => ({ ...state, selected: datasourceId }))
|
||||
queries.update(state => ({ ...state, selected: null }))
|
||||
queries.unselect()
|
||||
tables.unselect()
|
||||
views.unselect()
|
||||
},
|
||||
unselect: () => {
|
||||
update(state => ({ ...state, selected: null }))
|
||||
},
|
||||
updateSchema: async datasource => {
|
||||
let url = `/api/datasources/${datasource._id}/schema`
|
||||
|
|
|
@ -55,10 +55,6 @@ export function createQueriesStore() {
|
|||
},
|
||||
select: query => {
|
||||
update(state => ({ ...state, selected: query._id }))
|
||||
datasources.update(state => ({
|
||||
...state,
|
||||
selected: query.datasourceId,
|
||||
}))
|
||||
tables.update(state => ({
|
||||
...state,
|
||||
selected: null,
|
||||
|
@ -66,10 +62,6 @@ export function createQueriesStore() {
|
|||
},
|
||||
unselect: () => {
|
||||
update(state => ({ ...state, selected: null }))
|
||||
datasources.update(state => ({
|
||||
...state,
|
||||
selected: null,
|
||||
}))
|
||||
},
|
||||
delete: async query => {
|
||||
const response = await api.delete(
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { writable, get } from "svelte/store"
|
||||
import { views, queries } from "./"
|
||||
import { views, queries, datasources } from "./"
|
||||
import { cloneDeep } from "lodash/fp"
|
||||
import api from "builderStore/api"
|
||||
|
||||
|
@ -25,8 +25,9 @@ export function createTablesStore() {
|
|||
selected: table,
|
||||
draft: cloneDeep(table),
|
||||
}))
|
||||
views.select({ name: table._id })
|
||||
views.unselect()
|
||||
queries.unselect()
|
||||
datasources.unselect()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -70,6 +71,12 @@ export function createTablesStore() {
|
|||
update,
|
||||
fetch,
|
||||
select,
|
||||
unselect: () => {
|
||||
update(state => ({
|
||||
...state,
|
||||
selected: null,
|
||||
}))
|
||||
},
|
||||
save,
|
||||
init: async () => {
|
||||
const response = await api.get("/api/tables")
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { writable, get } from "svelte/store"
|
||||
import { tables } from "./"
|
||||
import { tables, datasources, queries } from "./"
|
||||
import api from "builderStore/api"
|
||||
|
||||
export function createViewsStore() {
|
||||
|
@ -10,11 +10,20 @@ export function createViewsStore() {
|
|||
|
||||
return {
|
||||
subscribe,
|
||||
update,
|
||||
select: async view => {
|
||||
update(state => ({
|
||||
...state,
|
||||
selected: view,
|
||||
}))
|
||||
queries.unselect()
|
||||
datasources.unselect()
|
||||
},
|
||||
unselect: () => {
|
||||
update(state => ({
|
||||
...state,
|
||||
selected: null,
|
||||
}))
|
||||
},
|
||||
delete: async view => {
|
||||
await api.delete(`/api/views/${view}`)
|
||||
|
|
Loading…
Reference in New Issue