mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
class Attribute {
|
|
constructor(treeCache, row) {
|
|
this.treeCache = treeCache;
|
|
|
|
this.update(row);
|
|
}
|
|
|
|
update(row) {
|
|
/** @param {string} attributeId */
|
|
this.attributeId = row.attributeId;
|
|
/** @param {string} noteId */
|
|
this.noteId = row.noteId;
|
|
/** @param {string} type */
|
|
this.type = row.type;
|
|
/** @param {string} name */
|
|
this.name = row.name;
|
|
/** @param {string} value */
|
|
this.value = row.value;
|
|
/** @param {int} position */
|
|
this.position = row.position;
|
|
/** @param {boolean} isInheritable */
|
|
this.isInheritable = row.isInheritable;
|
|
}
|
|
|
|
/** @returns {NoteShort} */
|
|
async getNote() {
|
|
return await this.treeCache.getNote(this.noteId);
|
|
}
|
|
|
|
get jsonValue() {
|
|
try {
|
|
return JSON.parse(this.value);
|
|
}
|
|
catch (e) {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
get isAutoLink() {
|
|
return this.type === 'relation' && ['internalLink', 'imageLink', 'relationMapLink', 'includeNoteLink'].includes(this.name);
|
|
}
|
|
|
|
get toString() {
|
|
return `Attribute(attributeId=${this.attributeId}, type=${this.type}, name=${this.name}, value=${this.value})`;
|
|
}
|
|
}
|
|
|
|
export default Attribute;
|