Adding the ability to create options based on CSV, this will use the import data to create options.
This commit is contained in:
parent
0e9a2c8e9b
commit
48b7a31c2a
|
@ -8,7 +8,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<p
|
<p
|
||||||
style="{textAlign ? `text-align:${textAlign}` : ``}"
|
style={textAlign ? `text-align:${textAlign}` : ``}
|
||||||
class:noPadding
|
class:noPadding
|
||||||
class="spectrum-Body spectrum-Body--size{size}"
|
class="spectrum-Body spectrum-Body--size{size}"
|
||||||
class:spectrum-Body--serif={serif}
|
class:spectrum-Body--serif={serif}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<h1
|
<h1
|
||||||
style="{textAlign ? `text-align:${textAlign}` : ``}"
|
style={textAlign ? `text-align:${textAlign}` : ``}
|
||||||
class:noPadding
|
class:noPadding
|
||||||
class="spectrum-Heading spectrum-Heading--size{size}"
|
class="spectrum-Heading spectrum-Heading--size{size}"
|
||||||
>
|
>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { Select, Label } from "@budibase/bbui"
|
import { Select } from "@budibase/bbui"
|
||||||
import { notifications } from "@budibase/bbui"
|
import { notifications } from "@budibase/bbui"
|
||||||
import { FIELDS } from "constants/backend"
|
import { FIELDS } from "constants/backend"
|
||||||
import api from "builderStore/api"
|
import api from "builderStore/api"
|
||||||
|
@ -99,15 +99,19 @@
|
||||||
const typeOptions = [
|
const typeOptions = [
|
||||||
{
|
{
|
||||||
label: "Text",
|
label: "Text",
|
||||||
value: "string",
|
value: FIELDS.STRING.type,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Number",
|
label: "Number",
|
||||||
value: "number",
|
value: FIELDS.NUMBER.type,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Date",
|
label: "Date",
|
||||||
value: "datetime",
|
value: FIELDS.DATETIME.type,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Options",
|
||||||
|
value: FIELDS.OPTIONS.type,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -3,7 +3,14 @@
|
||||||
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"
|
||||||
import { Input, Label, ModalContent, Toggle, Divider } from "@budibase/bbui"
|
import {
|
||||||
|
Input,
|
||||||
|
Label,
|
||||||
|
ModalContent,
|
||||||
|
Toggle,
|
||||||
|
Divider,
|
||||||
|
Layout,
|
||||||
|
} from "@budibase/bbui"
|
||||||
import TableDataImport from "../TableDataImport.svelte"
|
import TableDataImport from "../TableDataImport.svelte"
|
||||||
import analytics from "analytics"
|
import analytics from "analytics"
|
||||||
import screenTemplates from "builderStore/store/screenTemplates"
|
import screenTemplates from "builderStore/store/screenTemplates"
|
||||||
|
@ -123,8 +130,10 @@
|
||||||
bind:value={createAutoscreens}
|
bind:value={createAutoscreens}
|
||||||
/>
|
/>
|
||||||
<div>
|
<div>
|
||||||
<Label grey extraSmall>Create Table from CSV (Optional)</Label>
|
<Layout gap="XS" noPadding>
|
||||||
<TableDataImport bind:dataImport />
|
<Label grey extraSmall>Create Table from CSV (Optional)</Label>
|
||||||
|
<TableDataImport bind:dataImport />
|
||||||
|
</Layout>
|
||||||
</div>
|
</div>
|
||||||
</ModalContent>
|
</ModalContent>
|
||||||
|
|
||||||
|
|
|
@ -30,12 +30,14 @@
|
||||||
<Layout gap="XS" noPadding>
|
<Layout gap="XS" noPadding>
|
||||||
<Heading textAlign="center">Forgotten your password?</Heading>
|
<Heading textAlign="center">Forgotten your password?</Heading>
|
||||||
<Body size="S" textAlign="center">
|
<Body size="S" textAlign="center">
|
||||||
No problem! Just enter your account's email address and we'll send
|
No problem! Just enter your account's email address and we'll send you
|
||||||
you a link to reset it.
|
a link to reset it.
|
||||||
</Body>
|
</Body>
|
||||||
<Input label="Email" bind:value={email} />
|
<Input label="Email" bind:value={email} />
|
||||||
</Layout>
|
</Layout>
|
||||||
<Button cta on:click={forgot} disabled={!email}>Reset your password</Button>
|
<Button cta on:click={forgot} disabled={!email}
|
||||||
|
>Reset your password</Button
|
||||||
|
>
|
||||||
</Layout>
|
</Layout>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
notifications.error("Unable to reset password")
|
notifications.error("Unable to reset password")
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -33,7 +32,9 @@
|
||||||
</Body>
|
</Body>
|
||||||
<PasswordRepeatInput bind:password bind:error />
|
<PasswordRepeatInput bind:password bind:error />
|
||||||
</Layout>
|
</Layout>
|
||||||
<Button cta on:click={reset} disabled={error || !resetCode}>Reset your password</Button>
|
<Button cta on:click={reset} disabled={error || !resetCode}
|
||||||
|
>Reset your password</Button
|
||||||
|
>
|
||||||
</Layout>
|
</Layout>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -6,7 +6,7 @@ const {
|
||||||
InternalTables,
|
InternalTables,
|
||||||
} = require("../../../db/utils")
|
} = require("../../../db/utils")
|
||||||
const { isEqual } = require("lodash/fp")
|
const { isEqual } = require("lodash/fp")
|
||||||
const { AutoFieldSubTypes } = require("../../../constants")
|
const { AutoFieldSubTypes, FieldTypes } = require("../../../constants")
|
||||||
const { inputProcessing } = require("../../../utilities/rowProcessor")
|
const { inputProcessing } = require("../../../utilities/rowProcessor")
|
||||||
const { USERS_TABLE_SCHEMA } = require("../../../constants")
|
const { USERS_TABLE_SCHEMA } = require("../../../constants")
|
||||||
|
|
||||||
|
@ -72,18 +72,21 @@ exports.handleDataImport = async (appId, user, table, dataImport) => {
|
||||||
row._id = generateRowID(table._id)
|
row._id = generateRowID(table._id)
|
||||||
row.tableId = table._id
|
row.tableId = table._id
|
||||||
const processed = inputProcessing(user, table, row)
|
const processed = inputProcessing(user, table, row)
|
||||||
|
table = processed.table
|
||||||
row = processed.row
|
row = processed.row
|
||||||
// these auto-fields will never actually link anywhere (always builder)
|
|
||||||
for (let [fieldName, schema] of Object.entries(table.schema)) {
|
for (let [fieldName, schema] of Object.entries(table.schema)) {
|
||||||
|
// check whether the options need to be updated for inclusion as part of the data import
|
||||||
if (
|
if (
|
||||||
schema.autocolumn &&
|
schema.type === FieldTypes.OPTIONS &&
|
||||||
(schema.subtype === AutoFieldSubTypes.CREATED_BY ||
|
(!schema.constraints.inclusion ||
|
||||||
schema.subtype === AutoFieldSubTypes.UPDATED_BY)
|
schema.constraints.inclusion.indexOf(row[fieldName]) === -1)
|
||||||
) {
|
) {
|
||||||
delete row[fieldName]
|
schema.constraints.inclusion = [
|
||||||
|
...schema.constraints.inclusion,
|
||||||
|
row[fieldName],
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
table = processed.table
|
|
||||||
data[i] = row
|
data[i] = row
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,16 @@
|
||||||
const csv = require("csvtojson")
|
const csv = require("csvtojson")
|
||||||
|
const { FieldTypes } = require("../constants")
|
||||||
|
|
||||||
const VALIDATORS = {
|
const VALIDATORS = {
|
||||||
string: () => true,
|
[FieldTypes.STRING]: () => true,
|
||||||
number: attribute => !isNaN(Number(attribute)),
|
[FieldTypes.OPTIONS]: () => true,
|
||||||
datetime: attribute => !isNaN(new Date(attribute).getTime()),
|
[FieldTypes.NUMBER]: attribute => !isNaN(Number(attribute)),
|
||||||
|
[FieldTypes.DATETIME]: attribute => !isNaN(new Date(attribute).getTime()),
|
||||||
}
|
}
|
||||||
|
|
||||||
const PARSERS = {
|
const PARSERS = {
|
||||||
number: attribute => Number(attribute),
|
[FieldTypes.NUMBER]: attribute => Number(attribute),
|
||||||
datetime: attribute => new Date(attribute).toISOString(),
|
[FieldTypes.DATETIME]: attribute => new Date(attribute).toISOString(),
|
||||||
}
|
}
|
||||||
|
|
||||||
function parse(csvString, parsers) {
|
function parse(csvString, parsers) {
|
||||||
|
|
Loading…
Reference in New Issue