diff --git a/docs/backend_api/Note.html b/docs/backend_api/Note.html
index 2c8828dbb..068be13d0 100644
--- a/docs/backend_api/Note.html
+++ b/docs/backend_api/Note.html
@@ -583,7 +583,7 @@
Source:
@@ -750,7 +750,7 @@
Source:
@@ -928,7 +928,7 @@
Source:
@@ -1034,7 +1034,7 @@
Source:
@@ -1136,7 +1136,7 @@
Source:
@@ -1242,7 +1242,7 @@
Source:
@@ -1450,7 +1450,7 @@
Source:
@@ -1683,7 +1683,7 @@
Source:
@@ -1881,7 +1881,7 @@
Source:
@@ -2079,7 +2079,7 @@
Source:
@@ -2332,7 +2332,7 @@
Source:
@@ -2499,7 +2499,7 @@
Source:
@@ -2666,7 +2666,7 @@
Source:
@@ -2821,7 +2821,7 @@
Source:
@@ -2933,7 +2933,7 @@
Source:
@@ -2987,6 +2987,114 @@
+ (async) getOwnedAttribute() → {Promise.<Attribute>}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+ attribute belonging to this specific note (excludes inherited attributes)
+
+This method can be significantly faster than the getAttribute()
+
+
+
+
+
+ -
+ Type
+
+ -
+
+Promise.<Attribute>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
(async) getOwnedAttributes() → {Promise.<Array.<Attribute>>}
@@ -3035,7 +3143,7 @@
Source:
@@ -3065,6 +3173,8 @@
attributes belonging to this specific note (excludes inherited attributes)
+
+This method can be significantly faster than the getAttributes()
@@ -3141,7 +3251,7 @@
Source:
@@ -3296,7 +3406,7 @@
Source:
@@ -3463,7 +3573,7 @@
Source:
@@ -3630,7 +3740,7 @@
Source:
@@ -3785,7 +3895,7 @@
Source:
@@ -3955,7 +4065,7 @@
Source:
@@ -4106,7 +4216,7 @@
Source:
@@ -4216,7 +4326,7 @@
Source:
@@ -4424,7 +4534,7 @@
Source:
@@ -4602,7 +4712,7 @@
Source:
@@ -4708,7 +4818,7 @@
Source:
@@ -4863,7 +4973,7 @@
Source:
@@ -5018,7 +5128,7 @@
Source:
@@ -5129,7 +5239,7 @@ Cache is note instance scoped.
Source:
@@ -5743,7 +5853,7 @@ Cache is note instance scoped.
Source:
@@ -5972,7 +6082,7 @@ Cache is note instance scoped.
Source:
@@ -6170,7 +6280,7 @@ Cache is note instance scoped.
Source:
@@ -6368,7 +6478,7 @@ Cache is note instance scoped.
Source:
@@ -6597,7 +6707,7 @@ Cache is note instance scoped.
Source:
@@ -6999,7 +7109,7 @@ Cache is note instance scoped.
Source:
@@ -7197,7 +7307,7 @@ Cache is note instance scoped.
Source:
@@ -7457,7 +7567,7 @@ Cache is note instance scoped.
Source:
@@ -7686,7 +7796,7 @@ Cache is note instance scoped.
Source:
@@ -7915,7 +8025,7 @@ Cache is note instance scoped.
Source:
diff --git a/docs/backend_api/entities_note.js.html b/docs/backend_api/entities_note.js.html
index dcc2418d9..b995a7531 100644
--- a/docs/backend_api/entities_note.js.html
+++ b/docs/backend_api/entities_note.js.html
@@ -223,9 +223,35 @@ class Note extends Entity {
/**
* @returns {Promise<Attribute[]>} attributes belonging to this specific note (excludes inherited attributes)
+ *
+ * This method can be significantly faster than the getAttributes()
*/
- async getOwnedAttributes() {
- return await repository.getEntities(`SELECT * FROM attributes WHERE isDeleted = 0 AND noteId = ?`, [this.noteId]);
+ async getOwnedAttributes(type, name) {
+ let query = `SELECT * FROM attributes WHERE isDeleted = 0 AND noteId = ?`;
+ const params = [this.noteId];
+
+ if (type) {
+ query += ` AND type = ?`;
+ params.push(type);
+ }
+
+ if (name) {
+ query += ` AND name = ?`;
+ params.push(name);
+ }
+
+ return await repository.getEntities(query, params);
+ }
+
+ /**
+ * @returns {Promise<Attribute>} attribute belonging to this specific note (excludes inherited attributes)
+ *
+ * This method can be significantly faster than the getAttribute()
+ */
+ async getOwnedAttribute(type, name) {
+ const attrs = await this.getOwnedAttributes(type, name);
+
+ return attrs.length > 0 ? attrs[0] : null;
}
/**
@@ -323,16 +349,16 @@ class Note extends Entity {
treeWithAttrs(noteId, level) AS (
SELECT * FROM tree
UNION
- SELECT attributes.value, treeWithAttrs.level + 1 FROM attributes
+ SELECT attributes.value, treeWithAttrs.level FROM attributes
JOIN treeWithAttrs ON treeWithAttrs.noteId = attributes.noteId
WHERE attributes.isDeleted = 0
AND attributes.type = 'relation'
AND attributes.name = 'template'
- AND (attributes.noteId = ? OR attributes.isInheritable = 1)
+ AND (treeWithAttrs.level = 0 OR attributes.isInheritable = 1)
)
SELECT attributes.* FROM attributes JOIN treeWithAttrs ON attributes.noteId = treeWithAttrs.noteId
- WHERE attributes.isDeleted = 0 AND (attributes.isInheritable = 1 OR attributes.noteId = ?)
- ORDER BY level, noteId, position`, [this.noteId, this.noteId, this.noteId]);
+ WHERE attributes.isDeleted = 0 AND (attributes.isInheritable = 1 OR treeWithAttrs.level = 0)
+ ORDER BY level, noteId, position`, [this.noteId]);
// attributes are ordered so that "closest" attributes are first
// we order by noteId so that attributes from same note stay together. Actual noteId ordering doesn't matter.
diff --git a/docs/frontend_api/NoteShort.html b/docs/frontend_api/NoteShort.html
index ded275cfc..6514efb81 100644
--- a/docs/frontend_api/NoteShort.html
+++ b/docs/frontend_api/NoteShort.html
@@ -30,8 +30,7 @@
NoteShort()
- This note's representation is used in note tree and is kept in TreeCache.
-Its notable omission is the note content.
+ This note's representation is used in note tree and is kept in TreeCache.
@@ -94,7 +93,7 @@ Its notable omission is the note content.
Source:
@@ -184,7 +183,65 @@ Its notable omission is the note content.
Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+cssClass
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
@@ -242,7 +299,7 @@ Its notable omission is the note content.
- Source:
@@ -300,7 +357,7 @@ Its notable omission is the note content.
- Source:
@@ -358,7 +415,7 @@ Its notable omission is the note content.
- Source:
@@ -416,7 +473,7 @@ Its notable omission is the note content.
- Source:
@@ -474,7 +531,7 @@ Its notable omission is the note content.
- Source:
@@ -622,7 +679,7 @@ Its notable omission is the note content.
- Source:
@@ -789,7 +846,7 @@ Its notable omission is the note content.
- Source:
@@ -963,7 +1020,7 @@ Its notable omission is the note content.
- Source:
@@ -1069,7 +1126,7 @@ Its notable omission is the note content.
- Source:
@@ -1171,7 +1228,7 @@ Its notable omission is the note content.
- Source:
@@ -1273,7 +1330,7 @@ Its notable omission is the note content.
- Source:
@@ -1375,7 +1432,7 @@ Its notable omission is the note content.
- Source:
@@ -1526,7 +1583,7 @@ Its notable omission is the note content.
- Source:
@@ -1693,7 +1750,7 @@ Its notable omission is the note content.
- Source:
@@ -1860,7 +1917,7 @@ Its notable omission is the note content.
- Source:
@@ -2015,7 +2072,7 @@ Its notable omission is the note content.
- Source:
@@ -2121,7 +2178,7 @@ Its notable omission is the note content.
- Source:
@@ -2223,7 +2280,7 @@ Its notable omission is the note content.
- Source:
@@ -2374,7 +2431,7 @@ Its notable omission is the note content.
- Source:
@@ -2541,7 +2598,7 @@ Its notable omission is the note content.
- Source:
@@ -2708,7 +2765,7 @@ Its notable omission is the note content.
- Source:
@@ -2863,7 +2920,7 @@ Its notable omission is the note content.
- Source:
@@ -3033,7 +3090,7 @@ Its notable omission is the note content.
- Source:
@@ -3184,7 +3241,7 @@ Its notable omission is the note content.
- Source:
@@ -3294,7 +3351,7 @@ Its notable omission is the note content.
- Source:
@@ -3468,7 +3525,7 @@ Its notable omission is the note content.
- Source:
@@ -3574,7 +3631,7 @@ Its notable omission is the note content.
- Source:
@@ -3725,7 +3782,7 @@ Its notable omission is the note content.
- Source:
@@ -3880,7 +3937,7 @@ Its notable omission is the note content.
- Source:
@@ -3991,7 +4048,7 @@ Cache is note instance scoped.
- Source:
diff --git a/docs/frontend_api/entities_note_short.js.html b/docs/frontend_api/entities_note_short.js.html
index 7dd2448df..7e0281d3b 100644
--- a/docs/frontend_api/entities_note_short.js.html
+++ b/docs/frontend_api/entities_note_short.js.html
@@ -36,7 +36,6 @@ const RELATION_DEFINITION = 'relation-definition';
/**
* This note's representation is used in note tree and is kept in TreeCache.
- * Its notable omission is the note content.
*/
class NoteShort {
constructor(treeCache, row) {
@@ -53,6 +52,7 @@ class NoteShort {
this.mime = row.mime;
/** @param {boolean} */
this.archived = row.archived;
+ /** @param {string} */
this.cssClass = row.cssClass;
}
@@ -61,6 +61,26 @@ class NoteShort {
return this.mime === "application/json";
}
+ async getContent() {
+ // we're not caching content since these objects are in treeCache and as such pretty long lived
+ const note = await server.get("notes/" + this.noteId);
+
+ return note.content;
+ }
+
+ async getJsonContent() {
+ const content = await this.getContent();
+
+ try {
+ return JSON.parse(content);
+ }
+ catch (e) {
+ console.log(`Cannot parse content of note ${this.noteId}: `, e.message);
+
+ return null;
+ }
+ }
+
/** @returns {Promise<Branch[]>} */
async getBranches() {
const branchIds = this.treeCache.parents[this.noteId].map(
diff --git a/src/public/javascripts/widgets/note_revisions.js b/src/public/javascripts/widgets/note_revisions.js
index fd1be98c6..7cbc4c186 100644
--- a/src/public/javascripts/widgets/note_revisions.js
+++ b/src/public/javascripts/widgets/note_revisions.js
@@ -37,7 +37,7 @@ class NoteRevisionsWidget extends StandardWidget {
'data-note-path': this.ctx.note.noteId,
'data-note-revision-id': item.noteRevisionId,
href: 'javascript:'
- }).text(item.dateModifiedFrom)));
+ }).text(item.dateModifiedFrom.substr(0, 16))));
}
}