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