diff --git a/docs/backend_api/Branch.html b/docs/backend_api/Branch.html
index db8e9e0c6..619545941 100644
--- a/docs/backend_api/Branch.html
+++ b/docs/backend_api/Branch.html
@@ -326,7 +326,7 @@ parents.
Source:
@@ -588,7 +588,7 @@ parents.
Source:
@@ -1144,7 +1144,7 @@ parents.
Source:
diff --git a/docs/backend_api/Note.html b/docs/backend_api/Note.html
index 5163824c8..9e2361403 100644
--- a/docs/backend_api/Note.html
+++ b/docs/backend_api/Note.html
@@ -978,13 +978,17 @@
- addAttribute() → {Attribute}
+ addAttribute(type, name, valueopt) → {Attribute}
+
+ Adds a new attribute to this note. The attribute is saved and returned.
+See addLabel, addRelation for more specific methods.
+
@@ -994,6 +998,130 @@
+ Parameters:
+
+
+
+
+
+
+ Name |
+
+
+ Type |
+
+
+ Attributes |
+
+
+
+
+ Description |
+
+
+
+
+
+
+
+
+ type |
+
+
+
+
+
+string
+
+
+
+ |
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+ attribute type (label / relation) |
+
+
+
+
+
+
+ name |
+
+
+
+
+
+string
+
+
+
+ |
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+ name of the attribute, not including the leading ~/# |
+
+
+
+
+
+
+ value |
+
+
+
+
+
+string
+
+
+
+ |
+
+
+
+
+ <optional>
+
+
+
+
+
+ |
+
+
+
+
+ value of the attribute - text for labels, target note ID for relations; optional. |
+
+
+
+
+
+
+
+
@@ -1026,7 +1154,7 @@
Source:
@@ -1163,6 +1291,383 @@
+
+
+
+
+
+
+ addLabel(name, valueopt) → {Attribute}
+
+
+
+
+
+
+
+ Adds a new label to this note. The label attribute is saved and returned.
+
+
+
+
+
+
+
+
+
+
+ Parameters:
+
+
+
+
+
+
+ Name |
+
+
+ Type |
+
+
+ Attributes |
+
+
+
+
+ Description |
+
+
+
+
+
+
+
+
+ name |
+
+
+
+
+
+string
+
+
+
+ |
+
+
+
+
+
+
+
+
+ |
+
+
+
+
+ name of the label, not including the leading # |
+
+
+
+
+
+
+ value |
+
+
+
+
+
+string
+
+
+
+ |
+
+
+
+
+ <optional>
+
+
+
+
+
+ |
+
+
+
+
+ text value of the label; optional |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+
+
+ -
+ Type
+
+ -
+
+Attribute
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ addRelation(name, value) → {Attribute}
+
+
+
+
+
+
+
+ Adds a new relation to this note. The relation attribute is saved and
+returned.
+
+
+
+
+
+
+
+
+
+
+ Parameters:
+
+
+
+
+
+
+ Name |
+
+
+ Type |
+
+
+
+
+
+ Description |
+
+
+
+
+
+
+
+
+ name |
+
+
+
+
+
+string
+
+
+
+ |
+
+
+
+
+
+ name of the relation, not including the leading ~ |
+
+
+
+
+
+
+ value |
+
+
+
+
+
+string
+
+
+
+ |
+
+
+
+
+
+ ID of the target note of the relation |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+
+
+ -
+ Type
+
+ -
+
+Attribute
+
+
+
+
+
+
+
+
+
+
+
@@ -1350,7 +1855,7 @@
Source:
@@ -1550,7 +2055,7 @@
Source:
@@ -1812,7 +2317,7 @@
Source:
@@ -1918,7 +2423,7 @@
Source:
@@ -3097,7 +3602,7 @@
Source:
@@ -6495,7 +7000,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -6597,7 +7102,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -6699,7 +7204,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -6801,7 +7306,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -6997,7 +7502,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -8476,7 +8981,7 @@ This method can be significantly faster than the getAttribute()
Source:
@@ -9398,7 +9903,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -9578,7 +10083,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -9758,7 +10263,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -9953,7 +10458,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -10185,7 +10690,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -10365,7 +10870,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -10525,7 +11030,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -10767,7 +11272,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -10978,7 +11483,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
Source:
@@ -11189,7 +11694,7 @@ This is a low level method, for notes and branches use `note.deleteNote()` and '
Source:
diff --git a/docs/backend_api/becca_entities_branch.js.html b/docs/backend_api/becca_entities_branch.js.html
index d02cd4fb7..e8cfd6bc4 100644
--- a/docs/backend_api/becca_entities_branch.js.html
+++ b/docs/backend_api/becca_entities_branch.js.html
@@ -98,21 +98,22 @@ class Branch extends AbstractEntity {
this.becca.childParentToBranch[`${this.noteId}-${this.parentNoteId}`] = this;
+ const childNote = this.childNote;
+
+ if (!childNote.parentBranches.includes(this)) {
+ childNote.parentBranches.push(this);
+ }
+
if (this.branchId === 'root') {
return;
}
- const childNote = this.childNote;
const parentNote = this.parentNote;
if (!childNote.parents.includes(parentNote)) {
childNote.parents.push(parentNote);
}
- if (!childNote.parentBranches.includes(this)) {
- childNote.parentBranches.push(this);
- }
-
if (!parentNote.children.includes(childNote)) {
parentNote.children.push(childNote);
}
@@ -132,9 +133,9 @@ class Branch extends AbstractEntity {
return this.childNote;
}
- /** @returns {Note} */
+ /** @returns {Note|undefined} - root branch will have undefined parent, all other branches have to have a parent note */
get parentNote() {
- if (!(this.parentNoteId in this.becca.notes)) {
+ if (!(this.parentNoteId in this.becca.notes) && this.parentNoteId !== 'none') {
// entities can come out of order in sync/import, create skeleton which will be filled later
this.becca.addNote(this.parentNoteId, new Note({noteId: this.parentNoteId}));
}
diff --git a/docs/backend_api/becca_entities_note.js.html b/docs/backend_api/becca_entities_note.js.html
index 734e64a45..a3af3312f 100644
--- a/docs/backend_api/becca_entities_note.js.html
+++ b/docs/backend_api/becca_entities_note.js.html
@@ -727,9 +727,11 @@ class Note extends AbstractEntity {
sortParents() {
this.parentBranches.sort((a, b) =>
a.branchId.startsWith('virt-')
- || a.parentNote.hasInheritableOwnedArchivedLabel() ? 1 : -1);
+ || a.parentNote?.hasInheritableOwnedArchivedLabel() ? 1 : -1);
- this.parents = this.parentBranches.map(branch => branch.parentNote);
+ this.parents = this.parentBranches
+ .map(branch => branch.parentNote)
+ .filter(note => !!note);
}
/**
@@ -1100,6 +1102,13 @@ class Note extends AbstractEntity {
}
/**
+ * Adds a new attribute to this note. The attribute is saved and returned.
+ * See addLabel, addRelation for more specific methods.
+ *
+ * @param {string} type - attribute type (label / relation)
+ * @param {string} name - name of the attribute, not including the leading ~/#
+ * @param {string} [value] - value of the attribute - text for labels, target note ID for relations; optional.
+ *
* @return {Attribute}
*/
addAttribute(type, name, value = "", isInheritable = false, position = 1000) {
@@ -1115,10 +1124,27 @@ class Note extends AbstractEntity {
}).save();
}
+ /**
+ * Adds a new label to this note. The label attribute is saved and returned.
+ *
+ * @param {string} name - name of the label, not including the leading #
+ * @param {string} [value] - text value of the label; optional
+ *
+ * @return {Attribute}
+ */
addLabel(name, value = "", isInheritable = false) {
return this.addAttribute(LABEL, name, value, isInheritable);
}
+ /**
+ * Adds a new relation to this note. The relation attribute is saved and
+ * returned.
+ *
+ * @param {string} name - name of the relation, not including the leading ~
+ * @param {string} value - ID of the target note of the relation
+ *
+ * @return {Attribute}
+ */
addRelation(name, targetNoteId, isInheritable = false) {
return this.addAttribute(RELATION, name, targetNoteId, isInheritable);
}
diff --git a/docs/frontend_api/NoteShort.html b/docs/frontend_api/NoteShort.html
index 1e7dd6ff4..c58ad3671 100644
--- a/docs/frontend_api/NoteShort.html
+++ b/docs/frontend_api/NoteShort.html
@@ -167,7 +167,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -267,7 +267,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -335,7 +335,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -403,7 +403,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -471,7 +471,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -543,7 +543,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -611,7 +611,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -679,7 +679,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -747,7 +747,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -815,7 +815,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -883,7 +883,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -955,7 +955,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -1103,7 +1103,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -1303,7 +1303,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -1481,7 +1481,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -1589,7 +1589,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -1693,7 +1693,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -1795,7 +1795,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -1897,7 +1897,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -1999,7 +1999,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -2150,7 +2150,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -2317,7 +2317,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -2472,7 +2472,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -2582,7 +2582,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -2756,7 +2756,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -2956,7 +2956,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -3134,7 +3134,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -3289,7 +3289,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -3456,7 +3456,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -3611,7 +3611,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -3766,7 +3766,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -3933,7 +3933,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -4088,7 +4088,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -4194,7 +4194,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -4296,7 +4296,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -4398,7 +4398,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -4500,7 +4500,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -4651,7 +4651,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -4818,7 +4818,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -4973,7 +4973,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5143,7 +5143,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5294,7 +5294,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5400,7 +5400,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5513,7 +5513,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5619,7 +5619,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5721,7 +5721,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -5895,7 +5895,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6001,7 +6001,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6152,7 +6152,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6330,7 +6330,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6485,7 +6485,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6640,7 +6640,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6795,7 +6795,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6903,7 +6903,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -6987,7 +6987,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -7093,7 +7093,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
@@ -7199,7 +7199,7 @@ This note's representation is used in note tree and is kept in Froca.
Source:
diff --git a/docs/frontend_api/entities_note_short.js.html b/docs/frontend_api/entities_note_short.js.html
index 323a0ef60..6ed141e1b 100644
--- a/docs/frontend_api/entities_note_short.js.html
+++ b/docs/frontend_api/entities_note_short.js.html
@@ -31,6 +31,7 @@ import noteAttributeCache from "../services/note_attribute_cache.js";
import ws from "../services/ws.js";
import options from "../services/options.js";
import froca from "../services/froca.js";
+import protectedSessionHolder from "../services/protected_session_holder.js";
const LABEL = 'label';
const RELATION = 'relation';
@@ -840,6 +841,10 @@ class NoteShort {
return false;
}
+
+ isContentAvailable() {
+ return !this.isProtected || protectedSessionHolder.isProtectedSessionAvailable()
+ }
}
export default NoteShort;
diff --git a/src/becca/entities/note.js b/src/becca/entities/note.js
index 1e4b9bf3d..e00f83364 100644
--- a/src/becca/entities/note.js
+++ b/src/becca/entities/note.js
@@ -1074,6 +1074,13 @@ class Note extends AbstractEntity {
}
/**
+ * Adds a new attribute to this note. The attribute is saved and returned.
+ * See addLabel, addRelation for more specific methods.
+ *
+ * @param {string} type - attribute type (label / relation)
+ * @param {string} name - name of the attribute, not including the leading ~/#
+ * @param {string} [value] - value of the attribute - text for labels, target note ID for relations; optional.
+ *
* @return {Attribute}
*/
addAttribute(type, name, value = "", isInheritable = false, position = 1000) {
@@ -1089,10 +1096,27 @@ class Note extends AbstractEntity {
}).save();
}
+ /**
+ * Adds a new label to this note. The label attribute is saved and returned.
+ *
+ * @param {string} name - name of the label, not including the leading #
+ * @param {string} [value] - text value of the label; optional
+ *
+ * @return {Attribute}
+ */
addLabel(name, value = "", isInheritable = false) {
return this.addAttribute(LABEL, name, value, isInheritable);
}
+ /**
+ * Adds a new relation to this note. The relation attribute is saved and
+ * returned.
+ *
+ * @param {string} name - name of the relation, not including the leading ~
+ * @param {string} value - ID of the target note of the relation
+ *
+ * @return {Attribute}
+ */
addRelation(name, targetNoteId, isInheritable = false) {
return this.addAttribute(RELATION, name, targetNoteId, isInheritable);
}