docs update

This commit is contained in:
zadam
2022-12-14 23:51:56 +01:00
parent 239c68a33c
commit 8c01a77a7a
7 changed files with 426 additions and 99 deletions

View File

@@ -39,7 +39,6 @@ const NoteRevision = require("./note_revision");
const TaskContext = require("../../services/task_context");
const dayjs = require("dayjs");
const utc = require('dayjs/plugin/utc');
const searchService = require("../../services/search/services/search.js");
dayjs.extend(utc)
const LABEL = 'label';
@@ -101,6 +100,8 @@ class Note extends AbstractEntity {
this.utcDateCreated = utcDateCreated || dateUtils.utcNowDateTime();
/** @type {string} */
this.utcDateModified = utcDateModified;
/** @type {boolean} - set during the deletion operation, before it is completed (removed from becca completely) */
this.isBeingDeleted = false;
// ------ Derived attributes ------
@@ -183,6 +184,15 @@ class Note extends AbstractEntity {
return this.parentBranches;
}
/**
* Returns <i>strong</i> (as opposed to <i>weak</i>) parent branches. See isWeak for details.
*
* @returns {Branch[]}
*/
getStrongParentBranches() {
return this.getParentBranches().filter(branch => !branch.isWeak);
}
/**
* @returns {Branch[]}
* @deprecated use getParentBranches() instead
@@ -402,7 +412,8 @@ class Note extends AbstractEntity {
return this.__attributeCache.filter(attr => attr.name === name);
}
else {
return this.__attributeCache.slice();
// a bit unsafe to return the original array, but defensive copy would be costly
return this.__attributeCache;
}
}
@@ -484,7 +495,7 @@ class Note extends AbstractEntity {
* @param [value]
* @returns {boolean}
*/
hasAttribute(type, name, value) {
hasAttribute(type, name, value = null) {
return !!this.getAttributes().find(attr =>
attr.type === type
&& attr.name === name
@@ -676,12 +687,12 @@ class Note extends AbstractEntity {
}
/**
* @param {string} [type] - (optional) attribute type to filter
* @param {string} [name] - (optional) attribute name to filter
* @param {string} [value] - (optional) attribute value to filter
* @param {string|null} [type] - (optional) attribute type to filter
* @param {string|null} [name] - (optional) attribute name to filter
* @param {string|null} [value] - (optional) attribute value to filter
* @returns {Attribute[]} note's "owned" attributes - excluding inherited ones
*/
getOwnedAttributes(type, name, value) {
getOwnedAttributes(type = null, name = null, value = null) {
// it's a common mistake to include # or ~ into attribute name
if (name && ["#", "~"].includes(name[0])) {
name = name.substr(1);
@@ -709,7 +720,7 @@ class Note extends AbstractEntity {
*
* This method can be significantly faster than the getAttribute()
*/
getOwnedAttribute(type, name, value) {
getOwnedAttribute(type, name, value = null) {
const attrs = this.getOwnedAttributes(type, name, value);
return attrs.length > 0 ? attrs[0] : null;
@@ -1346,8 +1357,16 @@ class Note extends AbstractEntity {
}
}
isLaunchBarConfig() {
return this.type === 'launcher' || ['lbRoot', 'lbAvailableLaunchers', 'lbVisibleLaunchers'].includes(this.noteId);
}
isOptions() {
return this.noteId.startsWith("options");
}
get isDeleted() {
return !(this.noteId in this.becca.notes);
return !(this.noteId in this.becca.notes) || this.isBeingDeleted;
}
/**