diff --git a/packages/builder/src/components/database/ModelView.svelte b/packages/builder/src/components/database/ModelView.svelte index c7b46df560..61768f4479 100644 --- a/packages/builder/src/components/database/ModelView.svelte +++ b/packages/builder/src/components/database/ModelView.svelte @@ -23,8 +23,7 @@ import { templateApi, pipe, validate } from "components/common/core" import ErrorsBox from "components/common/ErrorsBox.svelte" - let record - let getIndexAllowedRecords + let model let editingField = false let fieldToEdit let isNewField = false @@ -34,23 +33,15 @@ let onFinishedFieldEdit let editIndex - $: models = $store.hierarchy.children - $: parent = record && record.parent() + $: parent = model && model.parent() $: isChildModel = parent && parent.name !== "root" $: modelExistsInHierarchy = $store.currentNode && getNode($store.hierarchy, $store.currentNode.nodeId) store.subscribe($store => { - record = $store.currentNode + model = $store.currentNode const flattened = hierarchy.getFlattenedHierarchy($store.hierarchy) - getIndexAllowedRecords = compose( - join(", "), - map(id => flattened.find(n => n.nodeId === id).name), - filter(id => flattened.some(n => n.nodeId === id)), - get("allowedRecordNodeIds") - ) - newField = () => { isNewField = true fieldToEdit = templateApi($store.hierarchy).getNewField("string") @@ -94,8 +85,8 @@ const nameChanged = ev => { const pluralName = n => `${n}s` - if (record.collectionName === "") { - record.collectionName = pluralName(ev.target.value) + if (model.collectionName === "") { + model.collectionName = pluralName(ev.target.value) } } @@ -119,7 +110,7 @@