rename record

This commit is contained in:
Martin McKeaveney 2020-03-27 10:32:37 +00:00
parent ee4972a030
commit 5c7e603a5e
4 changed files with 6 additions and 4 deletions

View File

@ -244,7 +244,7 @@ export const deleteCurrentNode = store => () => {
export const saveField = store => field => { export const saveField = store => field => {
store.update(state => { 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) templateApi(state.hierarchy).addField(state.currentNode, field)
return state return state

View File

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

View File

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

View File

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