mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	updated API docs
This commit is contained in:
		| @@ -3010,7 +3010,7 @@ the backend. | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line234">line 234</a> | ||||
|         <a href="services_backend_script_api.js.html">services/backend_script_api.js</a>, <a href="services_backend_script_api.js.html#line236">line 236</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -133,6 +133,11 @@ class Attribute extends Entity { | ||||
|             this.dateModified = dateUtils.nowDate(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // cannot be static! | ||||
|     updatePojo(pojo) { | ||||
|         delete pojo.isOwned; | ||||
|     } | ||||
| } | ||||
|  | ||||
| module.exports = Attribute;</code></pre> | ||||
|   | ||||
| @@ -87,6 +87,11 @@ class Branch extends Entity { | ||||
|             this.dateModified = dateUtils.nowDate(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // cannot be static! | ||||
|     updatePojo(pojo) { | ||||
|         delete pojo.origParentNoteId; | ||||
|     } | ||||
| } | ||||
|  | ||||
| module.exports = Branch;</code></pre> | ||||
|   | ||||
| @@ -32,6 +32,7 @@ const Entity = require('./entity'); | ||||
| const Attribute = require('./attribute'); | ||||
| const protectedSessionService = require('../services/protected_session'); | ||||
| const repository = require('../services/repository'); | ||||
| const sql = require('../services/sql'); | ||||
| const dateUtils = require('../services/date_utils'); | ||||
|  | ||||
| const LABEL = 'label'; | ||||
| @@ -102,7 +103,9 @@ class Note extends Entity { | ||||
|     /** @returns {boolean} true if this note is JavaScript (code or attachment) */ | ||||
|     isJavaScript() { | ||||
|         return (this.type === "code" || this.type === "file") | ||||
|             && (this.mime.startsWith("application/javascript") || this.mime === "application/x-javascript"); | ||||
|             && (this.mime.startsWith("application/javascript") | ||||
|                 || this.mime === "application/x-javascript" | ||||
|                 || this.mime === "text/javascript"); | ||||
|     } | ||||
|  | ||||
|     /** @returns {boolean} true if this note is HTML */ | ||||
| @@ -394,6 +397,16 @@ class Note extends Entity { | ||||
|      */ | ||||
|     async getRelationValue(name) { return await this.getAttributeValue(RELATION, name); } | ||||
|  | ||||
|     /** | ||||
|      * @param {string} name | ||||
|      * @returns {Promise<Note>|null} target note of the relation or null (if target is empty or note was not found) | ||||
|      */ | ||||
|     async getRelationTarget(name) { | ||||
|         const relation = await this.getRelation(name); | ||||
|  | ||||
|         return relation ? await repository.getNote(relation.value) : null; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Based on enabled, label is either set or removed. | ||||
|      * | ||||
| @@ -451,24 +464,32 @@ class Note extends Entity { | ||||
|     async removeRelation(name, value) { return await this.removeAttribute(RELATION, name, value); } | ||||
|  | ||||
|     /** | ||||
|      * @param {string} name | ||||
|      * @returns {Promise<Note>|null} target note of the relation or null (if target is empty or note was not found) | ||||
|      * @return {Promise<string[]>} return list of all descendant noteIds of this note. Returning just noteIds because number of notes can be huge. Includes also this note's noteId | ||||
|      */ | ||||
|     async getRelationTarget(name) { | ||||
|         const relation = await this.getRelation(name); | ||||
|  | ||||
|         return relation ? await repository.getNote(relation.value) : null; | ||||
|     async getDescendantNoteIds() { | ||||
|         return await sql.getColumn(` | ||||
|             WITH RECURSIVE | ||||
|             tree(noteId) AS ( | ||||
|                 SELECT ? | ||||
|                 UNION | ||||
|                 SELECT branches.noteId FROM branches | ||||
|                     JOIN tree ON branches.parentNoteId = tree.noteId | ||||
|                     JOIN notes ON notes.noteId = branches.noteId | ||||
|                 WHERE notes.isDeleted = 0 | ||||
|                   AND branches.isDeleted = 0 | ||||
|             ) | ||||
|             SELECT noteId FROM tree`, [this.noteId]); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Finds child notes with given attribute name and value. Only own attributes are considered, not inherited ones | ||||
|      * Finds descendant notes with given attribute name and value. Only own attributes are considered, not inherited ones | ||||
|      * | ||||
|      * @param {string} type - attribute type (label, relation, etc.) | ||||
|      * @param {string} name - attribute name | ||||
|      * @param {string} [value] - attribute value | ||||
|      * @returns {Promise<Note[]>} | ||||
|      */ | ||||
|     async findChildNotesWithAttribute(type, name, value) { | ||||
|     async getDescendantNotesWithAttribute(type, name, value) { | ||||
|         const params = [this.noteId, name]; | ||||
|         let valueCondition = ""; | ||||
|  | ||||
| @@ -500,22 +521,22 @@ class Note extends Entity { | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Finds notes with given label name and value. Only own labels are considered, not inherited ones | ||||
|      * Finds descendant notes with given label name and value. Only own labels are considered, not inherited ones | ||||
|      * | ||||
|      * @param {string} name - label name | ||||
|      * @param {string} [value] - label value | ||||
|      * @returns {Promise<Note[]>} | ||||
|      */ | ||||
|     async findChildNotesWithLabel(name, value) { return await this.findChildNotesWithAttribute(LABEL, name, value); } | ||||
|     async getDescendantNotesWithLabel(name, value) { return await this.getDescendantNotesWithAttribute(LABEL, name, value); } | ||||
|  | ||||
|     /** | ||||
|      * Finds notes with given relation name and value. Only own relations are considered, not inherited ones | ||||
|      * Finds descendant notes with given relation name and value. Only own relations are considered, not inherited ones | ||||
|      * | ||||
|      * @param {string} name - relation name | ||||
|      * @param {string} [value] - relation value | ||||
|      * @returns {Promise<Note[]>} | ||||
|      */ | ||||
|     async findChildNotesWithRelation(name, value) { return await this.findChildNotesWithAttribute(RELATION, name, value); } | ||||
|     async getDescendantNotesWithRelation(name, value) { return await this.getDescendantNotesWithAttribute(RELATION, name, value); } | ||||
|  | ||||
|     /** | ||||
|      * Returns note revisions of this note. | ||||
| @@ -615,10 +636,6 @@ class Note extends Entity { | ||||
|         // we do this here because encryption needs the note ID for the IV | ||||
|         this.generateIdIfNecessary(); | ||||
|  | ||||
|         if (this.isProtected) { | ||||
|             protectedSessionService.encryptNote(this); | ||||
|         } | ||||
|  | ||||
|         if (!this.isDeleted) { | ||||
|             this.isDeleted = false; | ||||
|         } | ||||
| @@ -633,6 +650,17 @@ class Note extends Entity { | ||||
|             this.dateModified = dateUtils.nowDate(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     // cannot be static! | ||||
|     updatePojo(pojo) { | ||||
|         if (pojo.isProtected) { | ||||
|             protectedSessionService.encryptNote(pojo); | ||||
|         } | ||||
|  | ||||
|         delete pojo.jsonContent; | ||||
|         delete pojo.isContentAvailable; | ||||
|         delete pojo.__attributeCache; | ||||
|     } | ||||
| } | ||||
|  | ||||
| module.exports = Note;</code></pre> | ||||
|   | ||||
| @@ -253,6 +253,8 @@ function BackendScriptApi(startNote, currentNote, originEntity) { | ||||
|      */ | ||||
|     this.transactional = sql.transactional; | ||||
|  | ||||
|     this.sql = sql; | ||||
|  | ||||
|     /** | ||||
|      * Trigger tree refresh in all connected clients. This is required when some tree change happens in | ||||
|      * the backend. | ||||
|   | ||||
| @@ -81,7 +81,7 @@ | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line16">line 16</a> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line17">line 17</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
| @@ -221,7 +221,7 @@ | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line22">line 22</a> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line23">line 23</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
| @@ -334,7 +334,7 @@ | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line24">line 24</a> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line25">line 25</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
| @@ -444,7 +444,7 @@ | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line20">line 20</a> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line21">line 21</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
| @@ -573,7 +573,7 @@ | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line41">line 41</a> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line42">line 42</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
| @@ -726,7 +726,7 @@ | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line33">line 33</a> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line34">line 34</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
| @@ -879,7 +879,7 @@ | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line60">line 60</a> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line61">line 61</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
| @@ -1057,7 +1057,7 @@ | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line197">line 197</a> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line198">line 198</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
| @@ -1188,7 +1188,7 @@ | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line157">line 157</a> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line158">line 158</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
| @@ -1292,7 +1292,7 @@ | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line221">line 221</a> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line222">line 222</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
| @@ -1396,7 +1396,7 @@ | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line203">line 203</a> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line204">line 204</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
| @@ -1500,7 +1500,7 @@ | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line215">line 215</a> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line216">line 216</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
| @@ -1609,7 +1609,7 @@ if some action needs to happen on only one specific instance. | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line150">line 150</a> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line151">line 151</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
| @@ -1808,7 +1808,7 @@ otherwise (by e.g. createNoteLink()) | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line142">line 142</a> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line143">line 143</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
| @@ -1957,7 +1957,7 @@ otherwise (by e.g. createNoteLink()) | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line209">line 209</a> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line210">line 210</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
| @@ -2088,7 +2088,7 @@ otherwise (by e.g. createNoteLink()) | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line164">line 164</a> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line165">line 165</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
| @@ -2196,7 +2196,7 @@ otherwise (by e.g. createNoteLink()) | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line188">line 188</a> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line189">line 189</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
| @@ -2373,7 +2373,7 @@ Internally this serializes the anonymous function into string and sends it to ba | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line110">line 110</a> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line111">line 111</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
| @@ -2526,7 +2526,138 @@ Internally this serializes the anonymous function into string and sends it to ba | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line227">line 227</a> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line228">line 228</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
| </dl> | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|          | ||||
|              | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|     <h4 class="name" id="setupElementTooltip"><span class="type-signature"></span>setupElementTooltip<span class="signature">($el)</span><span class="type-signature"></span></h4> | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|     <h5>Parameters:</h5> | ||||
|      | ||||
|  | ||||
| <table class="params"> | ||||
|     <thead> | ||||
|     <tr> | ||||
|          | ||||
|         <th>Name</th> | ||||
|          | ||||
|  | ||||
|         <th>Type</th> | ||||
|  | ||||
|          | ||||
|  | ||||
|          | ||||
|  | ||||
|         <th class="last">Description</th> | ||||
|     </tr> | ||||
|     </thead> | ||||
|  | ||||
|     <tbody> | ||||
|      | ||||
|  | ||||
|         <tr> | ||||
|              | ||||
|                 <td class="name"><code>$el</code></td> | ||||
|              | ||||
|  | ||||
|             <td class="type"> | ||||
|              | ||||
|                  | ||||
| <span class="param-type">object</span> | ||||
|  | ||||
|  | ||||
|              | ||||
|             </td> | ||||
|  | ||||
|              | ||||
|  | ||||
|              | ||||
|  | ||||
|             <td class="description last">jquery object on which to setup the tooltip</td> | ||||
|         </tr> | ||||
|  | ||||
|      | ||||
|     </tbody> | ||||
| </table> | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| <dl class="details"> | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|  | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line234">line 234</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
| @@ -2661,7 +2792,7 @@ Internally this serializes the anonymous function into string and sends it to ba | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line180">line 180</a> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line181">line 181</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
| @@ -2796,7 +2927,7 @@ Internally this serializes the anonymous function into string and sends it to ba | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line172">line 172</a> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line173">line 173</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
|   | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										84
									
								
								docs/frontend_api/entities_attribute.js.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										84
									
								
								docs/frontend_api/entities_attribute.js.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,84 @@ | ||||
| <!DOCTYPE html> | ||||
| <html lang="en"> | ||||
| <head> | ||||
|     <meta charset="utf-8"> | ||||
|     <title>JSDoc: Source: entities/attribute.js</title> | ||||
|  | ||||
|     <script src="scripts/prettify/prettify.js"> </script> | ||||
|     <script src="scripts/prettify/lang-css.js"> </script> | ||||
|     <!--[if lt IE 9]> | ||||
|       <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> | ||||
|     <![endif]--> | ||||
|     <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> | ||||
|     <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> | ||||
| </head> | ||||
|  | ||||
| <body> | ||||
|  | ||||
| <div id="main"> | ||||
|  | ||||
|     <h1 class="page-title">Source: entities/attribute.js</h1> | ||||
|  | ||||
|      | ||||
|  | ||||
|  | ||||
|  | ||||
|      | ||||
|     <section> | ||||
|         <article> | ||||
|             <pre class="prettyprint source linenums"><code>class Attribute { | ||||
|     constructor(treeCache, row) { | ||||
|         this.treeCache = treeCache; | ||||
|         /** @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; | ||||
|         /** @param {boolean} isDeleted */ | ||||
|         this.isDeleted = row.isDeleted; | ||||
|         /** @param {string} dateCreated */ | ||||
|         this.dateCreated = row.dateCreated; | ||||
|         /** @param {string} dateModified */ | ||||
|         this.dateModified = row.dateModified; | ||||
|     } | ||||
|  | ||||
|     /** @returns {NoteShort} */ | ||||
|     async getNote() { | ||||
|         return await this.treeCache.getNote(this.noteId); | ||||
|     } | ||||
|  | ||||
|     get toString() { | ||||
|         return `Attribute(attributeId=${this.attributeId}, type=${this.type}, name=${this.name})`; | ||||
|     } | ||||
| }</code></pre> | ||||
|         </article> | ||||
|     </section> | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
| </div> | ||||
|  | ||||
| <nav> | ||||
|     <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Branch.html">Branch</a></li><li><a href="FrontendScriptApi.html">FrontendScriptApi</a></li><li><a href="NoteFull.html">NoteFull</a></li><li><a href="NoteShort.html">NoteShort</a></li></ul><h3><a href="global.html">Global</a></h3> | ||||
| </nav> | ||||
|  | ||||
| <br class="clear"> | ||||
|  | ||||
| <footer> | ||||
|     Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> | ||||
| </footer> | ||||
|  | ||||
| <script> prettyPrint(); </script> | ||||
| <script src="scripts/linenumber.js"> </script> | ||||
| </body> | ||||
| </html> | ||||
| @@ -42,7 +42,7 @@ class Branch { | ||||
|         /** @param {string} */ | ||||
|         this.prefix = row.prefix; | ||||
|         /** @param {boolean} */ | ||||
|         this.isExpanded = row.isExpanded; | ||||
|         this.isExpanded = !!row.isExpanded; | ||||
|     } | ||||
|  | ||||
|     /** @returns {NoteShort} */ | ||||
|   | ||||
| @@ -26,7 +26,14 @@ | ||||
|      | ||||
|     <section> | ||||
|         <article> | ||||
|             <pre class="prettyprint source linenums"><code>/** | ||||
|             <pre class="prettyprint source linenums"><code>import server from '../services/server.js'; | ||||
|  | ||||
| const LABEL = 'label'; | ||||
| const LABEL_DEFINITION = 'label-definition'; | ||||
| const RELATION = 'relation'; | ||||
| 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. | ||||
|  */ | ||||
| @@ -99,6 +106,140 @@ class NoteShort { | ||||
|         return await this.treeCache.getNotes(this.getChildNoteIds()); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param {string} [name] - attribute name to filter | ||||
|      * @returns {Promise<Attribute[]>} | ||||
|      */ | ||||
|     async getAttributes(name) { | ||||
|         if (!this.attributeCache) { | ||||
|             this.attributeCache = await server.get('notes/' + this.noteId + '/attributes'); | ||||
|         } | ||||
|  | ||||
|         if (name) { | ||||
|             return this.attributeCache.filter(attr => attr.name === name); | ||||
|         } | ||||
|         else { | ||||
|             return this.attributeCache; | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param {string} [name] - label name to filter | ||||
|      * @returns {Promise<Attribute[]>} all note's labels (attributes with type label), including inherited ones | ||||
|      */ | ||||
|     async getLabels(name) { | ||||
|         return (await this.getAttributes(name)).filter(attr => attr.type === LABEL); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param {string} [name] - label name to filter | ||||
|      * @returns {Promise<Attribute[]>} all note's label definitions, including inherited ones | ||||
|      */ | ||||
|     async getLabelDefinitions(name) { | ||||
|         return (await this.getAttributes(name)).filter(attr => attr.type === LABEL_DEFINITION); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param {string} [name] - relation name to filter | ||||
|      * @returns {Promise<Attribute[]>} all note's relations (attributes with type relation), including inherited ones | ||||
|      */ | ||||
|     async getRelations(name) { | ||||
|         return (await this.getAttributes(name)).filter(attr => attr.type === RELATION); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param {string} [name] - relation name to filter | ||||
|      * @returns {Promise<Attribute[]>} all note's relation definitions including inherited ones | ||||
|      */ | ||||
|     async getRelationDefinitions(name) { | ||||
|         return (await this.getAttributes(name)).filter(attr => attr.type === RELATION_DEFINITION); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param {string} type - attribute type (label, relation, etc.) | ||||
|      * @param {string} name - attribute name | ||||
|      * @returns {Promise<boolean>} true if note has an attribute with given type and name (including inherited) | ||||
|      */ | ||||
|     async hasAttribute(type, name) { | ||||
|         return !!await this.getAttribute(type, name); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param {string} type - attribute type (label, relation, etc.) | ||||
|      * @param {string} name - attribute name | ||||
|      * @returns {Promise<Attribute>} attribute of given type and name. If there's more such attributes, first is  returned. Returns null if there's no such attribute belonging to this note. | ||||
|      */ | ||||
|     async getAttribute(type, name) { | ||||
|         const attributes = await this.getAttributes(); | ||||
|  | ||||
|         return attributes.find(attr => attr.type === type && attr.name === name); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param {string} type - attribute type (label, relation, etc.) | ||||
|      * @param {string} name - attribute name | ||||
|      * @returns {Promise<string>} attribute value of given type and name or null if no such attribute exists. | ||||
|      */ | ||||
|     async getAttributeValue(type, name) { | ||||
|         const attr = await this.getAttribute(type, name); | ||||
|  | ||||
|         return attr ? attr.value : null; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param {string} name - label name | ||||
|      * @returns {Promise<boolean>} true if label exists (including inherited) | ||||
|      */ | ||||
|     async hasLabel(name) { return await this.hasAttribute(LABEL, name); } | ||||
|  | ||||
|     /** | ||||
|      * @param {string} name - relation name | ||||
|      * @returns {Promise<boolean>} true if relation exists (including inherited) | ||||
|      */ | ||||
|     async hasRelation(name) { return await this.hasAttribute(RELATION, name); } | ||||
|  | ||||
|     /** | ||||
|      * @param {string} name - label name | ||||
|      * @returns {Promise<Attribute>} label if it exists, null otherwise | ||||
|      */ | ||||
|     async getLabel(name) { return await this.getAttribute(LABEL, name); } | ||||
|  | ||||
|     /** | ||||
|      * @param {string} name - relation name | ||||
|      * @returns {Promise<Attribute>} relation if it exists, null otherwise | ||||
|      */ | ||||
|     async getRelation(name) { return await this.getAttribute(RELATION, name); } | ||||
|  | ||||
|     /** | ||||
|      * @param {string} name - label name | ||||
|      * @returns {Promise<string>} label value if label exists, null otherwise | ||||
|      */ | ||||
|     async getLabelValue(name) { return await this.getAttributeValue(LABEL, name); } | ||||
|  | ||||
|     /** | ||||
|      * @param {string} name - relation name | ||||
|      * @returns {Promise<string>} relation value if relation exists, null otherwise | ||||
|      */ | ||||
|     async getRelationValue(name) { return await this.getAttributeValue(RELATION, name); } | ||||
|  | ||||
|     /** | ||||
|      * @param {string} name | ||||
|      * @returns {Promise<Note>|null} target note of the relation or null (if target is empty or note was not found) | ||||
|      */ | ||||
|     async getRelationTarget(name) { | ||||
|         const relation = await this.getRelation(name); | ||||
|  | ||||
|         return relation ? await repository.getNote(relation.value) : null; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * Clear note's attributes cache to force fresh reload for next attribute request. | ||||
|      * Cache is note instance scoped. | ||||
|      */ | ||||
|     invalidateAttributeCache() { | ||||
|         this.attributeCache = null; | ||||
|     } | ||||
|  | ||||
|     get toString() { | ||||
|         return `Note(noteId=${this.noteId}, title=${this.title})`; | ||||
|     } | ||||
| @@ -107,6 +248,7 @@ class NoteShort { | ||||
|         const dto = Object.assign({}, this); | ||||
|         delete dto.treeCache; | ||||
|         delete dto.archived; | ||||
|         delete dto.attributeCache; | ||||
|  | ||||
|         return dto; | ||||
|     } | ||||
|   | ||||
| @@ -303,7 +303,7 @@ | ||||
|      | ||||
|     <dt class="tag-source">Source:</dt> | ||||
|     <dd class="tag-source"><ul class="dummy"><li> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line47">line 47</a> | ||||
|         <a href="services_frontend_script_api.js.html">services/frontend_script_api.js</a>, <a href="services_frontend_script_api.js.html#line48">line 48</a> | ||||
|     </li></ul></dd> | ||||
|      | ||||
|  | ||||
|   | ||||
| @@ -34,6 +34,7 @@ import linkService from './link.js'; | ||||
| import treeCache from './tree_cache.js'; | ||||
| import noteDetailService from './note_detail.js'; | ||||
| import noteTypeService from './note_type.js'; | ||||
| import noteTooltipService from './note_tooltip.js'; | ||||
|  | ||||
| /** | ||||
|  * This is the main frontend API interface for scripts. It's published in the local "api" object. | ||||
| @@ -253,6 +254,12 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null) { | ||||
|      * @param {array} types - list of mime types to be used | ||||
|      */ | ||||
|     this.setCodeMimeTypes = noteTypeService.setCodeMimeTypes; | ||||
|  | ||||
|     /** | ||||
|      * @method | ||||
|      * @param {object} $el - jquery object on which to setup the tooltip | ||||
|      */ | ||||
|     this.setupElementTooltip = noteTooltipService.setupElementTooltip | ||||
| } | ||||
|  | ||||
| export default FrontendScriptApi;</code></pre> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user