2018-08-23 12:55:45 +02:00
|
|
|
/** Represents mapping between note and parent note */
|
2018-03-25 12:29:00 -04:00
|
|
|
class Branch {
|
|
|
|
constructor(treeCache, row) {
|
|
|
|
this.treeCache = treeCache;
|
2018-08-23 12:55:45 +02:00
|
|
|
/** @param {string} primary key */
|
2018-03-25 12:29:00 -04:00
|
|
|
this.branchId = row.branchId;
|
2018-08-23 12:55:45 +02:00
|
|
|
/** @param {string} */
|
2018-03-25 12:29:00 -04:00
|
|
|
this.noteId = row.noteId;
|
|
|
|
this.note = null;
|
2018-08-23 12:55:45 +02:00
|
|
|
/** @param {string} */
|
2018-03-25 12:29:00 -04:00
|
|
|
this.parentNoteId = row.parentNoteId;
|
2018-08-23 12:55:45 +02:00
|
|
|
/** @param {int} */
|
2018-03-25 12:29:00 -04:00
|
|
|
this.notePosition = row.notePosition;
|
2018-08-23 12:55:45 +02:00
|
|
|
/** @param {string} */
|
2018-03-25 12:29:00 -04:00
|
|
|
this.prefix = row.prefix;
|
2018-08-23 12:55:45 +02:00
|
|
|
/** @param {boolean} */
|
2018-03-25 12:29:00 -04:00
|
|
|
this.isExpanded = row.isExpanded;
|
|
|
|
}
|
|
|
|
|
2018-08-23 12:55:45 +02:00
|
|
|
/** @returns {NoteShort} */
|
2018-03-25 12:29:00 -04:00
|
|
|
async getNote() {
|
2018-03-25 14:49:20 -04:00
|
|
|
return await this.treeCache.getNote(this.noteId);
|
2018-03-25 12:29:00 -04:00
|
|
|
}
|
|
|
|
|
2018-08-23 12:55:45 +02:00
|
|
|
/** @returns {boolean} true if it's top level, meaning its parent is root note */
|
2018-04-08 22:38:52 -04:00
|
|
|
isTopLevel() {
|
|
|
|
return this.parentNoteId === 'root';
|
|
|
|
}
|
|
|
|
|
2018-03-25 12:29:00 -04:00
|
|
|
get toString() {
|
|
|
|
return `Branch(branchId=${this.branchId})`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Branch;
|