Merge pull request #1944 from Budibase/feature/plus-table-internal
Making it possible to create an internal table from the plus symbol
This commit is contained in:
commit
717d56c989
|
@ -86,6 +86,7 @@ const createScreen = table => {
|
||||||
valueType: "Binding",
|
valueType: "Binding",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
limit: table.type === "external" ? undefined : 1,
|
||||||
paginate: false,
|
paginate: false,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
name: $views.selected?.name,
|
name: $views.selected?.name,
|
||||||
}
|
}
|
||||||
$: type = $tables.selected?.type
|
$: type = $tables.selected?.type
|
||||||
$: isInternal = type === "internal"
|
$: isInternal = type !== "external"
|
||||||
|
|
||||||
// Fetch rows for specified table
|
// Fetch rows for specified table
|
||||||
$: {
|
$: {
|
||||||
|
|
|
@ -5,14 +5,17 @@
|
||||||
import ICONS from "../icons"
|
import ICONS from "../icons"
|
||||||
|
|
||||||
export let integration = {}
|
export let integration = {}
|
||||||
|
|
||||||
let integrations = []
|
let integrations = []
|
||||||
|
const INTERNAL = "BUDIBASE"
|
||||||
|
|
||||||
async function fetchIntegrations() {
|
async function fetchIntegrations() {
|
||||||
const response = await api.get("/api/integrations")
|
const response = await api.get("/api/integrations")
|
||||||
const json = await response.json()
|
const json = await response.json()
|
||||||
|
|
||||||
integrations = json
|
integrations = {
|
||||||
|
[INTERNAL]: { datasource: {}, name: "INTERNAL/CSV" },
|
||||||
|
...json,
|
||||||
|
}
|
||||||
return json
|
return json
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,7 +24,7 @@
|
||||||
|
|
||||||
// build the schema
|
// build the schema
|
||||||
const schema = {}
|
const schema = {}
|
||||||
for (let key in selected.datasource) {
|
for (let key of Object.keys(selected.datasource)) {
|
||||||
schema[key] = selected.datasource[key].default
|
schema[key] = selected.datasource[key].default
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +42,7 @@
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
<div class="integration-list">
|
<div class="integration-list">
|
||||||
{#each Object.keys(integrations) as integrationType}
|
{#each Object.entries(integrations) as [integrationType, schema]}
|
||||||
<div
|
<div
|
||||||
class="integration hoverable"
|
class="integration hoverable"
|
||||||
class:selected={integration.type === integrationType}
|
class:selected={integration.type === integrationType}
|
||||||
|
@ -50,7 +53,7 @@
|
||||||
height="50"
|
height="50"
|
||||||
width="50"
|
width="50"
|
||||||
/>
|
/>
|
||||||
<Body size="XS">{integrationType}</Body>
|
<Body size="XS">{schema.name || integrationType}</Body>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,15 +2,21 @@
|
||||||
import { goto } from "@roxi/routify"
|
import { goto } from "@roxi/routify"
|
||||||
import { datasources } from "stores/backend"
|
import { datasources } from "stores/backend"
|
||||||
import { notifications } from "@budibase/bbui"
|
import { notifications } from "@budibase/bbui"
|
||||||
import { Input, Label, ModalContent } from "@budibase/bbui"
|
import { Input, Label, ModalContent, Modal, Context } from "@budibase/bbui"
|
||||||
import TableIntegrationMenu from "../TableIntegrationMenu/index.svelte"
|
import TableIntegrationMenu from "../TableIntegrationMenu/index.svelte"
|
||||||
|
import CreateTableModal from "components/backend/TableNavigator/modals/CreateTableModal.svelte"
|
||||||
import analytics from "analytics"
|
import analytics from "analytics"
|
||||||
|
import { getContext } from "svelte"
|
||||||
|
|
||||||
let error = ""
|
const modalContext = getContext(Context.Modal)
|
||||||
|
|
||||||
|
let tableModal
|
||||||
let name
|
let name
|
||||||
|
let error = ""
|
||||||
let integration
|
let integration
|
||||||
|
|
||||||
|
$: checkOpenModal(integration && integration.type === "BUDIBASE")
|
||||||
|
|
||||||
function checkValid(evt) {
|
function checkValid(evt) {
|
||||||
const datasourceName = evt.target.value
|
const datasourceName = evt.target.value
|
||||||
if (
|
if (
|
||||||
|
@ -22,6 +28,12 @@
|
||||||
error = ""
|
error = ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function checkOpenModal(isInternal) {
|
||||||
|
if (isInternal) {
|
||||||
|
tableModal.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function saveDatasource() {
|
async function saveDatasource() {
|
||||||
const { type, plus, ...config } = integration
|
const { type, plus, ...config } = integration
|
||||||
|
|
||||||
|
@ -40,6 +52,9 @@
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
<Modal bind:this={tableModal} on:hide={modalContext.hide}>
|
||||||
|
<CreateTableModal bind:name />
|
||||||
|
</Modal>
|
||||||
<ModalContent
|
<ModalContent
|
||||||
title="Create Datasource"
|
title="Create Datasource"
|
||||||
size="L"
|
size="L"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { goto } from "@roxi/routify"
|
import { goto, url } from "@roxi/routify"
|
||||||
import { store } from "builderStore"
|
import { store } from "builderStore"
|
||||||
import { tables } from "stores/backend"
|
import { tables } from "stores/backend"
|
||||||
import { notifications } from "@budibase/bbui"
|
import { notifications } from "@budibase/bbui"
|
||||||
|
@ -27,7 +27,7 @@
|
||||||
|
|
||||||
$: tableNames = $tables.list.map(table => table.name)
|
$: tableNames = $tables.list.map(table => table.name)
|
||||||
|
|
||||||
let name
|
export let name
|
||||||
let dataImport
|
let dataImport
|
||||||
let error = ""
|
let error = ""
|
||||||
let createAutoscreens = true
|
let createAutoscreens = true
|
||||||
|
@ -91,7 +91,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Navigate to new table
|
// Navigate to new table
|
||||||
$goto(`../../table/${table._id}`)
|
const currentUrl = $url()
|
||||||
|
const path = currentUrl.endsWith("data")
|
||||||
|
? `./table/${table._id}`
|
||||||
|
: `../../table/${table._id}`
|
||||||
|
$goto(path)
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
|
|
||||||
let selected = "Sources"
|
let selected = "Sources"
|
||||||
let modal
|
let modal
|
||||||
|
|
||||||
$: isExternal =
|
$: isExternal =
|
||||||
$params.selectedDatasource &&
|
$params.selectedDatasource &&
|
||||||
$params.selectedDatasource !== BUDIBASE_INTERNAL_DB
|
$params.selectedDatasource !== BUDIBASE_INTERNAL_DB
|
||||||
|
|
Loading…
Reference in New Issue