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 {
|
2021-04-16 22:57:37 +02:00
|
|
|
constructor(froca, row) {
|
|
|
|
this.froca = froca;
|
2020-01-29 22:32:22 +01:00
|
|
|
|
|
|
|
this.update(row);
|
|
|
|
}
|
|
|
|
|
|
|
|
update(row) {
|
2021-10-29 21:37:12 +02:00
|
|
|
/** @type {string} primary key */
|
2018-03-25 12:29:00 -04:00
|
|
|
this.branchId = row.branchId;
|
2021-10-29 21:37:12 +02:00
|
|
|
/** @type {string} */
|
2018-03-25 12:29:00 -04:00
|
|
|
this.noteId = row.noteId;
|
2021-10-29 21:37:12 +02:00
|
|
|
/** @type {string} */
|
2018-03-25 12:29:00 -04:00
|
|
|
this.parentNoteId = row.parentNoteId;
|
2021-10-29 21:37:12 +02:00
|
|
|
/** @type {int} */
|
2018-03-25 12:29:00 -04:00
|
|
|
this.notePosition = row.notePosition;
|
2021-10-29 21:37:12 +02:00
|
|
|
/** @type {string} */
|
2018-03-25 12:29:00 -04:00
|
|
|
this.prefix = row.prefix;
|
2021-10-29 21:37:12 +02:00
|
|
|
/** @type {boolean} */
|
2018-11-26 14:47:46 +01:00
|
|
|
this.isExpanded = !!row.isExpanded;
|
2021-10-29 21:37:12 +02:00
|
|
|
/** @type {boolean} */
|
2020-10-20 22:33:38 +02:00
|
|
|
this.fromSearchNote = !!row.fromSearchNote;
|
2018-03-25 12:29:00 -04:00
|
|
|
}
|
|
|
|
|
2018-08-23 12:55:45 +02:00
|
|
|
/** @returns {NoteShort} */
|
2018-03-25 12:29:00 -04:00
|
|
|
async getNote() {
|
2021-04-16 22:57:37 +02:00
|
|
|
return this.froca.getNote(this.noteId);
|
2018-03-25 12:29:00 -04:00
|
|
|
}
|
|
|
|
|
2020-08-26 16:50:16 +02:00
|
|
|
/** @returns {NoteShort} */
|
|
|
|
getNoteFromCache() {
|
2021-04-16 22:57:37 +02:00
|
|
|
return this.froca.getNoteFromCache(this.noteId);
|
2020-08-26 16:50:16 +02:00
|
|
|
}
|
|
|
|
|
2020-01-12 09:57:28 +01:00
|
|
|
/** @returns {NoteShort} */
|
|
|
|
async getParentNote() {
|
2021-04-16 22:57:37 +02:00
|
|
|
return this.froca.getNote(this.parentNoteId);
|
2020-01-12 09:57:28 +01: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})`;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-20 22:33:38 +02:00
|
|
|
export default Branch;
|