Remove autocolumns on creation
This commit is contained in:
parent
19fab7fa97
commit
911a352844
|
@ -2,21 +2,13 @@
|
||||||
import { goto, url } from "@roxi/routify"
|
import { goto, url } from "@roxi/routify"
|
||||||
import { tables } from "stores/backend"
|
import { tables } from "stores/backend"
|
||||||
import { notifications } from "@budibase/bbui"
|
import { notifications } from "@budibase/bbui"
|
||||||
import {
|
import { Input, Label, ModalContent, Layout } from "@budibase/bbui"
|
||||||
Input,
|
|
||||||
Label,
|
|
||||||
ModalContent,
|
|
||||||
Toggle,
|
|
||||||
Divider,
|
|
||||||
Layout,
|
|
||||||
} from "@budibase/bbui"
|
|
||||||
import { datasources } from "stores/backend"
|
import { datasources } from "stores/backend"
|
||||||
import TableDataImport from "../TableDataImport.svelte"
|
import TableDataImport from "../TableDataImport.svelte"
|
||||||
import {
|
import {
|
||||||
BUDIBASE_INTERNAL_DB_ID,
|
BUDIBASE_INTERNAL_DB_ID,
|
||||||
BUDIBASE_DATASOURCE_TYPE,
|
BUDIBASE_DATASOURCE_TYPE,
|
||||||
} from "constants/backend"
|
} from "constants/backend"
|
||||||
import { buildAutoColumn, getAutoColumnInformation } from "builderStore/utils"
|
|
||||||
|
|
||||||
$: tableNames = $tables.list.map(table => table.name)
|
$: tableNames = $tables.list.map(table => table.name)
|
||||||
$: selectedSource = $datasources.list.find(
|
$: selectedSource = $datasources.list.find(
|
||||||
|
@ -43,28 +35,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
let error = ""
|
let error = ""
|
||||||
let autoColumns = getAutoColumnInformation()
|
|
||||||
let schema = {}
|
let schema = {}
|
||||||
let rows = []
|
let rows = []
|
||||||
let allValid = true
|
let allValid = true
|
||||||
let displayColumn = null
|
let displayColumn = null
|
||||||
|
|
||||||
function getAutoColumns() {
|
|
||||||
const selectedAutoColumns = {}
|
|
||||||
|
|
||||||
Object.entries(autoColumns).forEach(([subtype, column]) => {
|
|
||||||
if (column.enabled) {
|
|
||||||
selectedAutoColumns[column.name] = buildAutoColumn(
|
|
||||||
name,
|
|
||||||
column.name,
|
|
||||||
subtype
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
return selectedAutoColumns
|
|
||||||
}
|
|
||||||
|
|
||||||
function checkValid(evt) {
|
function checkValid(evt) {
|
||||||
const tableName = evt.target.value
|
const tableName = evt.target.value
|
||||||
if (tableNames.includes(tableName)) {
|
if (tableNames.includes(tableName)) {
|
||||||
|
@ -77,7 +53,7 @@
|
||||||
async function saveTable() {
|
async function saveTable() {
|
||||||
let newTable = {
|
let newTable = {
|
||||||
name,
|
name,
|
||||||
schema: { ...schema, ...getAutoColumns() },
|
schema: { ...schema },
|
||||||
rows,
|
rows,
|
||||||
type: "internal",
|
type: "internal",
|
||||||
sourceId: targetDatasourceId,
|
sourceId: targetDatasourceId,
|
||||||
|
@ -118,21 +94,6 @@
|
||||||
bind:value={name}
|
bind:value={name}
|
||||||
{error}
|
{error}
|
||||||
/>
|
/>
|
||||||
<div class="autocolumns">
|
|
||||||
<Label extraSmall grey>Auto Columns</Label>
|
|
||||||
<div class="toggles">
|
|
||||||
<div class="toggle-1">
|
|
||||||
<Toggle text="Created by" bind:value={autoColumns.createdBy.enabled} />
|
|
||||||
<Toggle text="Created at" bind:value={autoColumns.createdAt.enabled} />
|
|
||||||
<Toggle text="Auto ID" bind:value={autoColumns.autoID.enabled} />
|
|
||||||
</div>
|
|
||||||
<div class="toggle-2">
|
|
||||||
<Toggle text="Updated by" bind:value={autoColumns.updatedBy.enabled} />
|
|
||||||
<Toggle text="Updated at" bind:value={autoColumns.updatedAt.enabled} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<Divider />
|
|
||||||
</div>
|
|
||||||
<div>
|
<div>
|
||||||
<Layout gap="XS" noPadding>
|
<Layout gap="XS" noPadding>
|
||||||
<Label grey extraSmall
|
<Label grey extraSmall
|
||||||
|
@ -148,24 +109,3 @@
|
||||||
</Layout>
|
</Layout>
|
||||||
</div>
|
</div>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
|
||||||
<style>
|
|
||||||
.autocolumns {
|
|
||||||
margin-bottom: -10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toggles {
|
|
||||||
display: flex;
|
|
||||||
width: 100%;
|
|
||||||
margin-top: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toggle-1 :global(> *) {
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toggle-2 :global(> *) {
|
|
||||||
margin-bottom: 10px;
|
|
||||||
margin-left: 20px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
Loading…
Reference in New Issue