fix backend bugs - some tidy up

This commit is contained in:
Martin McKeaveney 2020-08-13 20:22:14 +01:00
parent 33a6ed835d
commit ed53c31ab3
5 changed files with 22 additions and 17 deletions

View File

@ -1,6 +1,7 @@
<script>
import { onMount } from "svelte"
import { Input, TextArea, Button, Select } from "@budibase/bbui"
import { cloneDeep, merge } from "lodash/fp"
import { store, backendUiStore } from "builderStore"
import { FIELDS } from "constants/backend"
import { notifier } from "builderStore/store/notifications"
@ -19,6 +20,7 @@
export let onClosed
export let field = {}
let fieldDefinitions = cloneDeep(FIELDS)
let originalName = field.name
$: required =
@ -26,7 +28,10 @@
field.constraints.presence &&
!field.constraints.presence.allowEmpty
$: if (field.type) {
field.constraints = FIELDS[field.type.toUpperCase()].constraints
field.constraints = merge(
fieldDefinitions[field.type.toUpperCase()].constraints,
field.constraints
)
}
async function saveColumn() {
@ -46,7 +51,7 @@
<Input placeholder="Name" thin bind:value={field.name} />
<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>
{/each}
</Select>

View File

@ -27,6 +27,7 @@
function deleteField() {
backendUiStore.actions.models.deleteField(field)
hideEditor()
}
function sort(direction, column) {

View File

@ -17,6 +17,12 @@
})
notifier.success(`Table ${name} created successfully.`)
$goto(`./model/${model._id}`)
name = ""
dropdown.hide()
}
const onClosed = () => {
name = ""
dropdown.hide()
}
</script>
@ -35,7 +41,7 @@
</div>
<footer>
<div class="button-margin-3">
<Button secondary on:click={dropdown.hide}>Cancel</Button>
<Button secondary on:click={onClosed}>Cancel</Button>
</div>
<div class="button-margin-4">
<Button primary on:click={saveTable}>Save</Button>

View File

@ -19,15 +19,12 @@
const joinPath = join("/")
const normalizedName = name =>
pipe(
name,
[
trimCharsStart("./"),
trimCharsStart("~/"),
trimCharsStart("../"),
trimChars(" "),
]
)
pipe(name, [
trimCharsStart("./"),
trimCharsStart("~/"),
trimCharsStart("../"),
trimChars(" "),
])
const changeScreen = screen => {
store.setCurrentScreen(screen.props._instanceName)

View File

@ -23,11 +23,7 @@
const capitalise = s => s.substring(0, 1).toUpperCase() + s.substring(1)
const get_name = s => (!s ? "" : last(s.split("/")))
const get_capitalised_name = name =>
pipe(
name,
[get_name, capitalise]
)
const get_capitalised_name = name => pipe(name, [get_name, capitalise])
const isScreenslot = name => name === "##builtin/screenslot"
const selectComponent = component => {