generate hidden subtree declaratively

This commit is contained in:
zadam
2022-12-07 12:46:41 +01:00
parent 5fc9f5f3f9
commit 2ad19ddd36
7 changed files with 306 additions and 492 deletions

View File

@@ -62,7 +62,6 @@ class Attribute extends AbstractEntity {
return this;
}
init() {
if (this.attributeId) {
this.becca.attributes[this.attributeId] = this;
@@ -163,11 +162,11 @@ class Attribute extends AbstractEntity {
}
beforeSaving() {
if (!this.value) {
if (this.type === 'relation') {
throw new Error(`Cannot save relation ${this.name} since it does not target any note.`);
if (this.type === 'relation') {
if (!(this.value in this.becca.notes)) {
throw new Error(`Cannot save relation '${this.name}' since it target not existing note '${this.value}'.`);
}
} else if (!this.value) {
// null value isn't allowed
this.value = "";
}