rename record

This commit is contained in:
Martin McKeaveney 2020-03-27 10:32:37 +00:00
parent 337d4019c1
commit 72ce6833c0
4 changed files with 6 additions and 4 deletions

View File

@ -244,7 +244,7 @@ export const deleteCurrentNode = store => () => {
export const saveField = store => field => {
store.update(state => {
state.currentNode.fields = state.currentNode.fields.filter(f => f.name !== field.name)
state.currentNode.fields = state.currentNode.fields.filter(f => f.id !== field.id)
templateApi(state.hierarchy).addField(state.currentNode, field)
return state

View File

@ -59,7 +59,7 @@
errors = validate.field(allFields)(clonedField)
if (errors.length > 0) return
field.typeOptions = cloneDeep(clonedField.typeOptions)
onFinished({ ...clonedField, ...field })
onFinished({ ...field, ...clonedField })
}
</script>

View File

@ -38,8 +38,8 @@
$: models = $store.hierarchy.children
$: parent = record && record.parent()
$: isChildModel = parent.name !== "root"
$: modelExistsInHierarchy = getNode(
$: isChildModel = parent && parent.name !== "root"
$: modelExistsInHierarchy = $store.currentNode && getNode(
$store.hierarchy,
$store.currentNode.nodeId
)

View File

@ -9,6 +9,7 @@ import {
import { all, getDefaultOptions } from "../types"
import { applyRuleSet, makerule } from "../common/validationCommon"
import { BadRequestError } from "../common/errors"
import { generate } from "shortid"
export const fieldErrors = {
AddFieldValidationFailed: "Add field validation: ",
@ -17,6 +18,7 @@ export const fieldErrors = {
export const allowedTypes = () => keys(all)
export const getNewField = type => ({
id: generate(),
name: "", // how field is referenced internally
type,
typeOptions: getDefaultOptions(type),