improvements in mobile layout for launchbar

This commit is contained in:
zadam
2022-12-12 23:48:34 +01:00
parent d1b989ac12
commit 2957e1d78a
10 changed files with 51 additions and 18 deletions

View File

@@ -63,6 +63,8 @@ class Attribute extends AbstractEntity {
}
init() {
this.validate();
if (this.attributeId) {
this.becca.attributes[this.attributeId] = this;
}
@@ -85,6 +87,16 @@ class Attribute extends AbstractEntity {
}
}
validate() {
if (!["label", "relation"].includes(this.type)) {
throw new Error(`Invalid attribute type '${this.type}' in attribute '${this.attributeId}'`);
}
if (!this.name?.trim()) {
throw new Error(`Invalid empty name in attribute '${this.attributeId}'`);
}
}
get isAffectingSubtree() {
return this.isInheritable
|| (this.type === 'relation' && this.name === 'template');
@@ -162,6 +174,8 @@ class Attribute extends AbstractEntity {
}
beforeSaving() {
this.validate();
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}'.`);