1
0
Fork 0
mirror of synced 2024-07-06 15:00:49 +12:00

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),