mirror of
https://github.com/zadam/trilium.git
synced 2025-10-28 00:36:33 +01:00
backend API to create a launcher
This commit is contained in:
@@ -117,11 +117,15 @@ class Attribute extends AbstractEntity {
|
||||
|
||||
validate() {
|
||||
if (!["label", "relation"].includes(this.type)) {
|
||||
throw new Error(`Invalid attribute type '${this.type}' in attribute '${this.attributeId}'`);
|
||||
throw new Error(`Invalid attribute type '${this.type}' in attribute '${this.attributeId}' of note '${this.noteId}'`);
|
||||
}
|
||||
|
||||
if (!this.name?.trim()) {
|
||||
throw new Error(`Invalid empty name in attribute '${this.attributeId}'`);
|
||||
throw new Error(`Invalid empty name in attribute '${this.attributeId}' of note '${this.noteId}'`);
|
||||
}
|
||||
|
||||
if (this.type === 'relation' && !(this.value in this.becca.notes)) {
|
||||
throw new Error(`Cannot save relation '${this.name}' of note '${this.noteId}' since it target not existing note '${this.value}'.`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -204,11 +208,7 @@ 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}'.`);
|
||||
}
|
||||
} else if (!this.value) {
|
||||
if (!this.value) {
|
||||
// null value isn't allowed
|
||||
this.value = "";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user