Merge pull request #538 from Budibase/backend-bug-fixes
fix backend bugs - some tidy up
This commit is contained in:
commit
249e44e273
|
@ -1,6 +1,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { onMount } from "svelte"
|
import { onMount } from "svelte"
|
||||||
import { Input, TextArea, Button, Select } from "@budibase/bbui"
|
import { Input, TextArea, Button, Select } from "@budibase/bbui"
|
||||||
|
import { cloneDeep, merge } from "lodash/fp"
|
||||||
import { store, backendUiStore } from "builderStore"
|
import { store, backendUiStore } from "builderStore"
|
||||||
import { FIELDS } from "constants/backend"
|
import { FIELDS } from "constants/backend"
|
||||||
import { notifier } from "builderStore/store/notifications"
|
import { notifier } from "builderStore/store/notifications"
|
||||||
|
@ -19,6 +20,7 @@
|
||||||
export let onClosed
|
export let onClosed
|
||||||
export let field = {}
|
export let field = {}
|
||||||
|
|
||||||
|
let fieldDefinitions = cloneDeep(FIELDS)
|
||||||
let originalName = field.name
|
let originalName = field.name
|
||||||
|
|
||||||
$: required =
|
$: required =
|
||||||
|
@ -26,7 +28,10 @@
|
||||||
field.constraints.presence &&
|
field.constraints.presence &&
|
||||||
!field.constraints.presence.allowEmpty
|
!field.constraints.presence.allowEmpty
|
||||||
$: if (field.type) {
|
$: if (field.type) {
|
||||||
field.constraints = FIELDS[field.type.toUpperCase()].constraints
|
field.constraints = merge(
|
||||||
|
fieldDefinitions[field.type.toUpperCase()].constraints,
|
||||||
|
field.constraints
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function saveColumn() {
|
async function saveColumn() {
|
||||||
|
@ -46,7 +51,7 @@
|
||||||
<Input placeholder="Name" thin bind:value={field.name} />
|
<Input placeholder="Name" thin bind:value={field.name} />
|
||||||
|
|
||||||
<Select secondary thin bind:value={field.type}>
|
<Select secondary thin bind:value={field.type}>
|
||||||
{#each Object.values(FIELDS) as field}
|
{#each Object.values(fieldDefinitions) as field}
|
||||||
<option value={field.type}>{field.name}</option>
|
<option value={field.type}>{field.name}</option>
|
||||||
{/each}
|
{/each}
|
||||||
</Select>
|
</Select>
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
function deleteField() {
|
function deleteField() {
|
||||||
backendUiStore.actions.models.deleteField(field)
|
backendUiStore.actions.models.deleteField(field)
|
||||||
|
hideEditor()
|
||||||
}
|
}
|
||||||
|
|
||||||
function sort(direction, column) {
|
function sort(direction, column) {
|
||||||
|
|
|
@ -17,6 +17,12 @@
|
||||||
})
|
})
|
||||||
notifier.success(`Table ${name} created successfully.`)
|
notifier.success(`Table ${name} created successfully.`)
|
||||||
$goto(`./model/${model._id}`)
|
$goto(`./model/${model._id}`)
|
||||||
|
name = ""
|
||||||
|
dropdown.hide()
|
||||||
|
}
|
||||||
|
|
||||||
|
const onClosed = () => {
|
||||||
|
name = ""
|
||||||
dropdown.hide()
|
dropdown.hide()
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -35,7 +41,7 @@
|
||||||
</div>
|
</div>
|
||||||
<footer>
|
<footer>
|
||||||
<div class="button-margin-3">
|
<div class="button-margin-3">
|
||||||
<Button secondary on:click={dropdown.hide}>Cancel</Button>
|
<Button secondary on:click={onClosed}>Cancel</Button>
|
||||||
</div>
|
</div>
|
||||||
<div class="button-margin-4">
|
<div class="button-margin-4">
|
||||||
<Button primary on:click={saveTable}>Save</Button>
|
<Button primary on:click={saveTable}>Save</Button>
|
||||||
|
|
|
@ -19,15 +19,12 @@
|
||||||
const joinPath = join("/")
|
const joinPath = join("/")
|
||||||
|
|
||||||
const normalizedName = name =>
|
const normalizedName = name =>
|
||||||
pipe(
|
pipe(name, [
|
||||||
name,
|
trimCharsStart("./"),
|
||||||
[
|
trimCharsStart("~/"),
|
||||||
trimCharsStart("./"),
|
trimCharsStart("../"),
|
||||||
trimCharsStart("~/"),
|
trimChars(" "),
|
||||||
trimCharsStart("../"),
|
])
|
||||||
trimChars(" "),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
const changeScreen = screen => {
|
const changeScreen = screen => {
|
||||||
store.setCurrentScreen(screen.props._instanceName)
|
store.setCurrentScreen(screen.props._instanceName)
|
||||||
|
|
|
@ -23,11 +23,7 @@
|
||||||
const capitalise = s => s.substring(0, 1).toUpperCase() + s.substring(1)
|
const capitalise = s => s.substring(0, 1).toUpperCase() + s.substring(1)
|
||||||
const get_name = s => (!s ? "" : last(s.split("/")))
|
const get_name = s => (!s ? "" : last(s.split("/")))
|
||||||
|
|
||||||
const get_capitalised_name = name =>
|
const get_capitalised_name = name => pipe(name, [get_name, capitalise])
|
||||||
pipe(
|
|
||||||
name,
|
|
||||||
[get_name, capitalise]
|
|
||||||
)
|
|
||||||
const isScreenslot = name => name === "##builtin/screenslot"
|
const isScreenslot = name => name === "##builtin/screenslot"
|
||||||
|
|
||||||
const selectComponent = component => {
|
const selectComponent = component => {
|
||||||
|
|
Loading…
Reference in New Issue