mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
individual panes of attribute list are now opened correctly
This commit is contained in:
parent
2217c5a3e0
commit
b19589033d
@ -81,7 +81,7 @@
|
|||||||
"electron-packager": "15.0.0",
|
"electron-packager": "15.0.0",
|
||||||
"electron-rebuild": "1.11.0",
|
"electron-rebuild": "1.11.0",
|
||||||
"esm": "3.2.25",
|
"esm": "3.2.25",
|
||||||
"jasmine": "3.6.0",
|
"jasmine": "3.6.1",
|
||||||
"jsdoc": "3.6.5",
|
"jsdoc": "3.6.5",
|
||||||
"lorem-ipsum": "2.0.3",
|
"lorem-ipsum": "2.0.3",
|
||||||
"webpack": "5.0.0-beta.22",
|
"webpack": "5.0.0-beta.22",
|
||||||
|
@ -41,14 +41,14 @@ class Attribute extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Promise<Note|null>}
|
* @returns {Note|null}
|
||||||
*/
|
*/
|
||||||
getNote() {
|
getNote() {
|
||||||
return this.repository.getNote(this.noteId);
|
return this.repository.getNote(this.noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Promise<Note|null>}
|
* @returns {Note|null}
|
||||||
*/
|
*/
|
||||||
getTargetNote() {
|
getTargetNote() {
|
||||||
if (this.type !== 'relation') {
|
if (this.type !== 'relation') {
|
||||||
|
@ -27,12 +27,12 @@ class Branch extends Entity {
|
|||||||
// notePosition is not part of hash because it would produce a lot of updates in case of reordering
|
// notePosition is not part of hash because it would produce a lot of updates in case of reordering
|
||||||
static get hashedProperties() { return ["branchId", "noteId", "parentNoteId", "isDeleted", "deleteId", "prefix"]; }
|
static get hashedProperties() { return ["branchId", "noteId", "parentNoteId", "isDeleted", "deleteId", "prefix"]; }
|
||||||
|
|
||||||
/** @returns {Promise<Note|null>} */
|
/** @returns {Note|null} */
|
||||||
getNote() {
|
getNote() {
|
||||||
return this.repository.getNote(this.noteId);
|
return this.repository.getNote(this.noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {Promise<Note|null>} */
|
/** @returns {Note|null} */
|
||||||
getParentNote() {
|
getParentNote() {
|
||||||
return this.repository.getNote(this.parentNoteId);
|
return this.repository.getNote(this.parentNoteId);
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ class Note extends Entity {
|
|||||||
* - but to the user note content and title changes are one and the same - single dateModified (so all changes must go through Note and content is not a separate entity)
|
* - but to the user note content and title changes are one and the same - single dateModified (so all changes must go through Note and content is not a separate entity)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @returns {Promise<*>} */
|
/** @returns {*} */
|
||||||
getContent(silentNotFoundError = false) {
|
getContent(silentNotFoundError = false) {
|
||||||
if (this.content === undefined) {
|
if (this.content === undefined) {
|
||||||
const res = sql.getRow(`SELECT content, hash FROM note_contents WHERE noteId = ?`, [this.noteId]);
|
const res = sql.getRow(`SELECT content, hash FROM note_contents WHERE noteId = ?`, [this.noteId]);
|
||||||
@ -106,7 +106,7 @@ class Note extends Entity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {Promise<*>} */
|
/** @returns {*} */
|
||||||
getJsonContent() {
|
getJsonContent() {
|
||||||
const content = this.getContent();
|
const content = this.getContent();
|
||||||
|
|
||||||
@ -157,7 +157,6 @@ class Note extends Entity {
|
|||||||
syncTableService.addNoteContentSync(this.noteId);
|
syncTableService.addNoteContentSync(this.noteId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {Promise} */
|
|
||||||
setJsonContent(content) {
|
setJsonContent(content) {
|
||||||
this.setContent(JSON.stringify(content, null, '\t'));
|
this.setContent(JSON.stringify(content, null, '\t'));
|
||||||
}
|
}
|
||||||
@ -218,7 +217,7 @@ class Note extends Entity {
|
|||||||
*
|
*
|
||||||
* @param {string} [type] - (optional) attribute type to filter
|
* @param {string} [type] - (optional) attribute type to filter
|
||||||
* @param {string} [name] - (optional) attribute name to filter
|
* @param {string} [name] - (optional) attribute name to filter
|
||||||
* @returns {Promise<Attribute[]>} note's "owned" attributes - excluding inherited ones
|
* @returns {Attribute[]} note's "owned" attributes - excluding inherited ones
|
||||||
*/
|
*/
|
||||||
getOwnedAttributes(type, name) {
|
getOwnedAttributes(type, name) {
|
||||||
if (!this.__ownedAttributeCache) {
|
if (!this.__ownedAttributeCache) {
|
||||||
@ -240,7 +239,7 @@ class Note extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Promise<Attribute>} attribute belonging to this specific note (excludes inherited attributes)
|
* @returns {Attribute} attribute belonging to this specific note (excludes inherited attributes)
|
||||||
*
|
*
|
||||||
* This method can be significantly faster than the getAttribute()
|
* This method can be significantly faster than the getAttribute()
|
||||||
*/
|
*/
|
||||||
@ -251,7 +250,7 @@ class Note extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Promise<Attribute[]>} relations targetting this specific note
|
* @returns {Attribute[]} relations targetting this specific note
|
||||||
*/
|
*/
|
||||||
getTargetRelations() {
|
getTargetRelations() {
|
||||||
return this.repository.getEntities("SELECT * FROM attributes WHERE type = 'relation' AND isDeleted = 0 AND value = ?", [this.noteId]);
|
return this.repository.getEntities("SELECT * FROM attributes WHERE type = 'relation' AND isDeleted = 0 AND value = ?", [this.noteId]);
|
||||||
@ -260,7 +259,7 @@ class Note extends Entity {
|
|||||||
/**
|
/**
|
||||||
* @param {string} [type] - (optional) attribute type to filter
|
* @param {string} [type] - (optional) attribute type to filter
|
||||||
* @param {string} [name] - (optional) attribute name to filter
|
* @param {string} [name] - (optional) attribute name to filter
|
||||||
* @returns {Promise<Attribute[]>} all note's attributes, including inherited ones
|
* @returns {Attribute[]} all note's attributes, including inherited ones
|
||||||
*/
|
*/
|
||||||
getAttributes(type, name) {
|
getAttributes(type, name) {
|
||||||
if (!this.__attributeCache) {
|
if (!this.__attributeCache) {
|
||||||
@ -283,7 +282,7 @@ class Note extends Entity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} [name] - label name to filter
|
* @param {string} [name] - label name to filter
|
||||||
* @returns {Promise<Attribute[]>} all note's labels (attributes with type label), including inherited ones
|
* @returns {Attribute[]} all note's labels (attributes with type label), including inherited ones
|
||||||
*/
|
*/
|
||||||
getLabels(name) {
|
getLabels(name) {
|
||||||
return this.getAttributes(LABEL, name);
|
return this.getAttributes(LABEL, name);
|
||||||
@ -291,7 +290,7 @@ class Note extends Entity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} [name] - label name to filter
|
* @param {string} [name] - label name to filter
|
||||||
* @returns {Promise<Attribute[]>} all note's labels (attributes with type label), excluding inherited ones
|
* @returns {Attribute[]} all note's labels (attributes with type label), excluding inherited ones
|
||||||
*/
|
*/
|
||||||
getOwnedLabels(name) {
|
getOwnedLabels(name) {
|
||||||
return this.getOwnedAttributes(LABEL, name);
|
return this.getOwnedAttributes(LABEL, name);
|
||||||
@ -299,7 +298,7 @@ class Note extends Entity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} [name] - label name to filter
|
* @param {string} [name] - label name to filter
|
||||||
* @returns {Promise<Attribute[]>} all note's label definitions, including inherited ones
|
* @returns {Attribute[]} all note's label definitions, including inherited ones
|
||||||
*/
|
*/
|
||||||
getLabelDefinitions(name) {
|
getLabelDefinitions(name) {
|
||||||
return this.getAttributes(LABEL_DEFINITION, name);
|
return this.getAttributes(LABEL_DEFINITION, name);
|
||||||
@ -307,7 +306,7 @@ class Note extends Entity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} [name] - relation name to filter
|
* @param {string} [name] - relation name to filter
|
||||||
* @returns {Promise<Attribute[]>} all note's relations (attributes with type relation), including inherited ones
|
* @returns {Attribute[]} all note's relations (attributes with type relation), including inherited ones
|
||||||
*/
|
*/
|
||||||
getRelations(name) {
|
getRelations(name) {
|
||||||
return this.getAttributes(RELATION, name);
|
return this.getAttributes(RELATION, name);
|
||||||
@ -315,7 +314,7 @@ class Note extends Entity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} [name] - relation name to filter
|
* @param {string} [name] - relation name to filter
|
||||||
* @returns {Promise<Attribute[]>} all note's relations (attributes with type relation), excluding inherited ones
|
* @returns {Attribute[]} all note's relations (attributes with type relation), excluding inherited ones
|
||||||
*/
|
*/
|
||||||
getOwnedRelations(name) {
|
getOwnedRelations(name) {
|
||||||
return this.getOwnedAttributes(RELATION, name);
|
return this.getOwnedAttributes(RELATION, name);
|
||||||
@ -323,7 +322,7 @@ class Note extends Entity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} [name] - relation name to filter
|
* @param {string} [name] - relation name to filter
|
||||||
* @returns {Promise<Note[]>}
|
* @returns {Note[]}
|
||||||
*/
|
*/
|
||||||
getRelationTargets(name) {
|
getRelationTargets(name) {
|
||||||
const relations = this.getRelations(name);
|
const relations = this.getRelations(name);
|
||||||
@ -338,7 +337,7 @@ class Note extends Entity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} [name] - relation name to filter
|
* @param {string} [name] - relation name to filter
|
||||||
* @returns {Promise<Attribute[]>} all note's relation definitions including inherited ones
|
* @returns {Attribute[]} all note's relation definitions including inherited ones
|
||||||
*/
|
*/
|
||||||
getRelationDefinitions(name) {
|
getRelationDefinitions(name) {
|
||||||
return this.getAttributes(RELATION_DEFINITION, name);
|
return this.getAttributes(RELATION_DEFINITION, name);
|
||||||
@ -353,7 +352,6 @@ class Note extends Entity {
|
|||||||
this.__ownedAttributeCache = null;
|
this.__ownedAttributeCache = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {Promise<void>} */
|
|
||||||
loadAttributesToCache() {
|
loadAttributesToCache() {
|
||||||
const attributes = this.repository.getEntities(`
|
const attributes = this.repository.getEntities(`
|
||||||
WITH RECURSIVE
|
WITH RECURSIVE
|
||||||
@ -420,7 +418,7 @@ class Note extends Entity {
|
|||||||
/**
|
/**
|
||||||
* @param {string} type - attribute type (label, relation, etc.)
|
* @param {string} type - attribute type (label, relation, etc.)
|
||||||
* @param {string} name - attribute name
|
* @param {string} name - attribute name
|
||||||
* @returns {Promise<boolean>} true if note has an attribute with given type and name (including inherited)
|
* @returns {boolean} true if note has an attribute with given type and name (including inherited)
|
||||||
*/
|
*/
|
||||||
hasAttribute(type, name) {
|
hasAttribute(type, name) {
|
||||||
return !!this.getAttribute(type, name);
|
return !!this.getAttribute(type, name);
|
||||||
@ -429,7 +427,7 @@ class Note extends Entity {
|
|||||||
/**
|
/**
|
||||||
* @param {string} type - attribute type (label, relation, etc.)
|
* @param {string} type - attribute type (label, relation, etc.)
|
||||||
* @param {string} name - attribute name
|
* @param {string} name - attribute name
|
||||||
* @returns {Promise<boolean>} true if note has an attribute with given type and name (excluding inherited)
|
* @returns {boolean} true if note has an attribute with given type and name (excluding inherited)
|
||||||
*/
|
*/
|
||||||
hasOwnedAttribute(type, name) {
|
hasOwnedAttribute(type, name) {
|
||||||
return !!this.getOwnedAttribute(type, name);
|
return !!this.getOwnedAttribute(type, name);
|
||||||
@ -438,7 +436,7 @@ class Note extends Entity {
|
|||||||
/**
|
/**
|
||||||
* @param {string} type - attribute type (label, relation, etc.)
|
* @param {string} type - attribute type (label, relation, etc.)
|
||||||
* @param {string} name - attribute name
|
* @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.
|
* @returns {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.
|
||||||
*/
|
*/
|
||||||
getAttribute(type, name) {
|
getAttribute(type, name) {
|
||||||
const attributes = this.getAttributes();
|
const attributes = this.getAttributes();
|
||||||
@ -449,7 +447,7 @@ class Note extends Entity {
|
|||||||
/**
|
/**
|
||||||
* @param {string} type - attribute type (label, relation, etc.)
|
* @param {string} type - attribute type (label, relation, etc.)
|
||||||
* @param {string} name - attribute name
|
* @param {string} name - attribute name
|
||||||
* @returns {Promise<string|null>} attribute value of given type and name or null if no such attribute exists.
|
* @returns {string|null} attribute value of given type and name or null if no such attribute exists.
|
||||||
*/
|
*/
|
||||||
getAttributeValue(type, name) {
|
getAttributeValue(type, name) {
|
||||||
const attr = this.getAttribute(type, name);
|
const attr = this.getAttribute(type, name);
|
||||||
@ -460,7 +458,7 @@ class Note extends Entity {
|
|||||||
/**
|
/**
|
||||||
* @param {string} type - attribute type (label, relation, etc.)
|
* @param {string} type - attribute type (label, relation, etc.)
|
||||||
* @param {string} name - attribute name
|
* @param {string} name - attribute name
|
||||||
* @returns {Promise<string|null>} attribute value of given type and name or null if no such attribute exists.
|
* @returns {string|null} attribute value of given type and name or null if no such attribute exists.
|
||||||
*/
|
*/
|
||||||
getOwnedAttributeValue(type, name) {
|
getOwnedAttributeValue(type, name) {
|
||||||
const attr = this.getOwnedAttribute(type, name);
|
const attr = this.getOwnedAttribute(type, name);
|
||||||
@ -475,7 +473,6 @@ class Note extends Entity {
|
|||||||
* @param {boolean} enabled - toggle On or Off
|
* @param {boolean} enabled - toggle On or Off
|
||||||
* @param {string} name - attribute name
|
* @param {string} name - attribute name
|
||||||
* @param {string} [value] - attribute value (optional)
|
* @param {string} [value] - attribute value (optional)
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
*/
|
||||||
toggleAttribute(type, enabled, name, value) {
|
toggleAttribute(type, enabled, name, value) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
@ -492,7 +489,6 @@ class Note extends Entity {
|
|||||||
* @param {string} type - attribute type (label, relation, etc.)
|
* @param {string} type - attribute type (label, relation, etc.)
|
||||||
* @param {string} name - attribute name
|
* @param {string} name - attribute name
|
||||||
* @param {string} [value] - attribute value (optional)
|
* @param {string} [value] - attribute value (optional)
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
*/
|
||||||
setAttribute(type, name, value) {
|
setAttribute(type, name, value) {
|
||||||
const attributes = this.loadOwnedAttributesToCache();
|
const attributes = this.loadOwnedAttributesToCache();
|
||||||
@ -526,7 +522,6 @@ class Note extends Entity {
|
|||||||
* @param {string} type - attribute type (label, relation, etc.)
|
* @param {string} type - attribute type (label, relation, etc.)
|
||||||
* @param {string} name - attribute name
|
* @param {string} name - attribute name
|
||||||
* @param {string} [value] - attribute value (optional)
|
* @param {string} [value] - attribute value (optional)
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
*/
|
||||||
removeAttribute(type, name, value) {
|
removeAttribute(type, name, value) {
|
||||||
const attributes = this.loadOwnedAttributesToCache();
|
const attributes = this.loadOwnedAttributesToCache();
|
||||||
@ -542,7 +537,7 @@ class Note extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {Promise<Attribute>}
|
* @return {Attribute}
|
||||||
*/
|
*/
|
||||||
addAttribute(type, name, value = "", isInheritable = false, position = 1000) {
|
addAttribute(type, name, value = "", isInheritable = false, position = 1000) {
|
||||||
const attr = new Attribute({
|
const attr = new Attribute({
|
||||||
@ -571,79 +566,79 @@ class Note extends Entity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} name - label name
|
* @param {string} name - label name
|
||||||
* @returns {Promise<boolean>} true if label exists (including inherited)
|
* @returns {boolean} true if label exists (including inherited)
|
||||||
*/
|
*/
|
||||||
hasLabel(name) { return this.hasAttribute(LABEL, name); }
|
hasLabel(name) { return this.hasAttribute(LABEL, name); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} name - label name
|
* @param {string} name - label name
|
||||||
* @returns {Promise<boolean>} true if label exists (excluding inherited)
|
* @returns {boolean} true if label exists (excluding inherited)
|
||||||
*/
|
*/
|
||||||
hasOwnedLabel(name) { return this.hasOwnedAttribute(LABEL, name); }
|
hasOwnedLabel(name) { return this.hasOwnedAttribute(LABEL, name); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} name - relation name
|
* @param {string} name - relation name
|
||||||
* @returns {Promise<boolean>} true if relation exists (including inherited)
|
* @returns {boolean} true if relation exists (including inherited)
|
||||||
*/
|
*/
|
||||||
hasRelation(name) { return this.hasAttribute(RELATION, name); }
|
hasRelation(name) { return this.hasAttribute(RELATION, name); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} name - relation name
|
* @param {string} name - relation name
|
||||||
* @returns {Promise<boolean>} true if relation exists (excluding inherited)
|
* @returns {boolean} true if relation exists (excluding inherited)
|
||||||
*/
|
*/
|
||||||
hasOwnedRelation(name) { return this.hasOwnedAttribute(RELATION, name); }
|
hasOwnedRelation(name) { return this.hasOwnedAttribute(RELATION, name); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} name - label name
|
* @param {string} name - label name
|
||||||
* @returns {Promise<Attribute|null>} label if it exists, null otherwise
|
* @returns {Attribute|null} label if it exists, null otherwise
|
||||||
*/
|
*/
|
||||||
getLabel(name) { return this.getAttribute(LABEL, name); }
|
getLabel(name) { return this.getAttribute(LABEL, name); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} name - label name
|
* @param {string} name - label name
|
||||||
* @returns {Promise<Attribute|null>} label if it exists, null otherwise
|
* @returns {Attribute|null} label if it exists, null otherwise
|
||||||
*/
|
*/
|
||||||
getOwnedLabel(name) { return this.getOwnedAttribute(LABEL, name); }
|
getOwnedLabel(name) { return this.getOwnedAttribute(LABEL, name); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} name - relation name
|
* @param {string} name - relation name
|
||||||
* @returns {Promise<Attribute|null>} relation if it exists, null otherwise
|
* @returns {Attribute|null} relation if it exists, null otherwise
|
||||||
*/
|
*/
|
||||||
getRelation(name) { return this.getAttribute(RELATION, name); }
|
getRelation(name) { return this.getAttribute(RELATION, name); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} name - relation name
|
* @param {string} name - relation name
|
||||||
* @returns {Promise<Attribute|null>} relation if it exists, null otherwise
|
* @returns {Attribute|null} relation if it exists, null otherwise
|
||||||
*/
|
*/
|
||||||
getOwnedRelation(name) { return this.getOwnedAttribute(RELATION, name); }
|
getOwnedRelation(name) { return this.getOwnedAttribute(RELATION, name); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} name - label name
|
* @param {string} name - label name
|
||||||
* @returns {Promise<string|null>} label value if label exists, null otherwise
|
* @returns {string|null} label value if label exists, null otherwise
|
||||||
*/
|
*/
|
||||||
getLabelValue(name) { return this.getAttributeValue(LABEL, name); }
|
getLabelValue(name) { return this.getAttributeValue(LABEL, name); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} name - label name
|
* @param {string} name - label name
|
||||||
* @returns {Promise<string|null>} label value if label exists, null otherwise
|
* @returns {string|null} label value if label exists, null otherwise
|
||||||
*/
|
*/
|
||||||
getOwnedLabelValue(name) { return this.getOwnedAttributeValue(LABEL, name); }
|
getOwnedLabelValue(name) { return this.getOwnedAttributeValue(LABEL, name); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} name - relation name
|
* @param {string} name - relation name
|
||||||
* @returns {Promise<string|null>} relation value if relation exists, null otherwise
|
* @returns {string|null} relation value if relation exists, null otherwise
|
||||||
*/
|
*/
|
||||||
getRelationValue(name) { return this.getAttributeValue(RELATION, name); }
|
getRelationValue(name) { return this.getAttributeValue(RELATION, name); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} name - relation name
|
* @param {string} name - relation name
|
||||||
* @returns {Promise<string|null>} relation value if relation exists, null otherwise
|
* @returns {string|null} relation value if relation exists, null otherwise
|
||||||
*/
|
*/
|
||||||
getOwnedRelationValue(name) { return this.getOwnedAttributeValue(RELATION, name); }
|
getOwnedRelationValue(name) { return this.getOwnedAttributeValue(RELATION, name); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} name
|
* @param {string} name
|
||||||
* @returns {Promise<Note>|null} target note of the relation or null (if target is empty or note was not found)
|
* @returns {Note|null} target note of the relation or null (if target is empty or note was not found)
|
||||||
*/
|
*/
|
||||||
getRelationTarget(name) {
|
getRelationTarget(name) {
|
||||||
const relation = this.getRelation(name);
|
const relation = this.getRelation(name);
|
||||||
@ -653,7 +648,7 @@ class Note extends Entity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {string} name
|
* @param {string} name
|
||||||
* @returns {Promise<Note>|null} target note of the relation or null (if target is empty or note was not found)
|
* @returns {Note|null} target note of the relation or null (if target is empty or note was not found)
|
||||||
*/
|
*/
|
||||||
getOwnedRelationTarget(name) {
|
getOwnedRelationTarget(name) {
|
||||||
const relation = this.getOwnedRelation(name);
|
const relation = this.getOwnedRelation(name);
|
||||||
@ -667,7 +662,6 @@ class Note extends Entity {
|
|||||||
* @param {boolean} enabled - toggle On or Off
|
* @param {boolean} enabled - toggle On or Off
|
||||||
* @param {string} name - label name
|
* @param {string} name - label name
|
||||||
* @param {string} [value] - label value (optional)
|
* @param {string} [value] - label value (optional)
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
*/
|
||||||
toggleLabel(enabled, name, value) { return this.toggleAttribute(LABEL, enabled, name, value); }
|
toggleLabel(enabled, name, value) { return this.toggleAttribute(LABEL, enabled, name, value); }
|
||||||
|
|
||||||
@ -677,7 +671,6 @@ class Note extends Entity {
|
|||||||
* @param {boolean} enabled - toggle On or Off
|
* @param {boolean} enabled - toggle On or Off
|
||||||
* @param {string} name - relation name
|
* @param {string} name - relation name
|
||||||
* @param {string} [value] - relation value (noteId)
|
* @param {string} [value] - relation value (noteId)
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
*/
|
||||||
toggleRelation(enabled, name, value) { return this.toggleAttribute(RELATION, enabled, name, value); }
|
toggleRelation(enabled, name, value) { return this.toggleAttribute(RELATION, enabled, name, value); }
|
||||||
|
|
||||||
@ -686,7 +679,6 @@ class Note extends Entity {
|
|||||||
*
|
*
|
||||||
* @param {string} name - label name
|
* @param {string} name - label name
|
||||||
* @param {string} [value] - label value
|
* @param {string} [value] - label value
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
*/
|
||||||
setLabel(name, value) { return this.setAttribute(LABEL, name, value); }
|
setLabel(name, value) { return this.setAttribute(LABEL, name, value); }
|
||||||
|
|
||||||
@ -695,7 +687,6 @@ class Note extends Entity {
|
|||||||
*
|
*
|
||||||
* @param {string} name - relation name
|
* @param {string} name - relation name
|
||||||
* @param {string} [value] - relation value (noteId)
|
* @param {string} [value] - relation value (noteId)
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
*/
|
||||||
setRelation(name, value) { return this.setAttribute(RELATION, name, value); }
|
setRelation(name, value) { return this.setAttribute(RELATION, name, value); }
|
||||||
|
|
||||||
@ -704,7 +695,6 @@ class Note extends Entity {
|
|||||||
*
|
*
|
||||||
* @param {string} name - label name
|
* @param {string} name - label name
|
||||||
* @param {string} [value] - label value
|
* @param {string} [value] - label value
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
*/
|
||||||
removeLabel(name, value) { return this.removeAttribute(LABEL, name, value); }
|
removeLabel(name, value) { return this.removeAttribute(LABEL, name, value); }
|
||||||
|
|
||||||
@ -713,12 +703,11 @@ class Note extends Entity {
|
|||||||
*
|
*
|
||||||
* @param {string} name - relation name
|
* @param {string} name - relation name
|
||||||
* @param {string} [value] - relation value (noteId)
|
* @param {string} [value] - relation value (noteId)
|
||||||
* @returns {Promise<void>}
|
|
||||||
*/
|
*/
|
||||||
removeRelation(name, value) { return this.removeAttribute(RELATION, name, value); }
|
removeRelation(name, value) { return this.removeAttribute(RELATION, name, value); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @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
|
* @return {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
|
||||||
*/
|
*/
|
||||||
getDescendantNoteIds() {
|
getDescendantNoteIds() {
|
||||||
return sql.getColumn(`
|
return sql.getColumn(`
|
||||||
@ -741,7 +730,7 @@ class Note extends Entity {
|
|||||||
* @param {string} type - attribute type (label, relation, etc.)
|
* @param {string} type - attribute type (label, relation, etc.)
|
||||||
* @param {string} name - attribute name
|
* @param {string} name - attribute name
|
||||||
* @param {string} [value] - attribute value
|
* @param {string} [value] - attribute value
|
||||||
* @returns {Promise<Note[]>}
|
* @returns {Note[]}
|
||||||
*/
|
*/
|
||||||
getDescendantNotesWithAttribute(type, name, value) {
|
getDescendantNotesWithAttribute(type, name, value) {
|
||||||
const params = [this.noteId, name];
|
const params = [this.noteId, name];
|
||||||
@ -779,7 +768,7 @@ class Note extends Entity {
|
|||||||
*
|
*
|
||||||
* @param {string} name - label name
|
* @param {string} name - label name
|
||||||
* @param {string} [value] - label value
|
* @param {string} [value] - label value
|
||||||
* @returns {Promise<Note[]>}
|
* @returns {Note[]}
|
||||||
*/
|
*/
|
||||||
getDescendantNotesWithLabel(name, value) { return this.getDescendantNotesWithAttribute(LABEL, name, value); }
|
getDescendantNotesWithLabel(name, value) { return this.getDescendantNotesWithAttribute(LABEL, name, value); }
|
||||||
|
|
||||||
@ -788,14 +777,14 @@ class Note extends Entity {
|
|||||||
*
|
*
|
||||||
* @param {string} name - relation name
|
* @param {string} name - relation name
|
||||||
* @param {string} [value] - relation value
|
* @param {string} [value] - relation value
|
||||||
* @returns {Promise<Note[]>}
|
* @returns {Note[]}
|
||||||
*/
|
*/
|
||||||
getDescendantNotesWithRelation(name, value) { return this.getDescendantNotesWithAttribute(RELATION, name, value); }
|
getDescendantNotesWithRelation(name, value) { return this.getDescendantNotesWithAttribute(RELATION, name, value); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns note revisions of this note.
|
* Returns note revisions of this note.
|
||||||
*
|
*
|
||||||
* @returns {Promise<NoteRevision[]>}
|
* @returns {NoteRevision[]}
|
||||||
*/
|
*/
|
||||||
getRevisions() {
|
getRevisions() {
|
||||||
return this.repository.getEntities("SELECT * FROM note_revisions WHERE noteId = ?", [this.noteId]);
|
return this.repository.getEntities("SELECT * FROM note_revisions WHERE noteId = ?", [this.noteId]);
|
||||||
@ -805,7 +794,7 @@ class Note extends Entity {
|
|||||||
* Get list of links coming out of this note.
|
* Get list of links coming out of this note.
|
||||||
*
|
*
|
||||||
* @deprecated - not intended for general use
|
* @deprecated - not intended for general use
|
||||||
* @returns {Promise<Attribute[]>}
|
* @returns {Attribute[]}
|
||||||
*/
|
*/
|
||||||
getLinks() {
|
getLinks() {
|
||||||
return this.repository.getEntities(`
|
return this.repository.getEntities(`
|
||||||
@ -818,7 +807,7 @@ class Note extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Promise<Branch[]>}
|
* @returns {Branch[]}
|
||||||
*/
|
*/
|
||||||
getBranches() {
|
getBranches() {
|
||||||
return this.repository.getEntities("SELECT * FROM branches WHERE isDeleted = 0 AND noteId = ?", [this.noteId]);
|
return this.repository.getEntities("SELECT * FROM branches WHERE isDeleted = 0 AND noteId = ?", [this.noteId]);
|
||||||
@ -832,7 +821,7 @@ class Note extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Promise<Note[]>} child notes of this note
|
* @returns {Note[]} child notes of this note
|
||||||
*/
|
*/
|
||||||
getChildNotes() {
|
getChildNotes() {
|
||||||
return this.repository.getEntities(`
|
return this.repository.getEntities(`
|
||||||
@ -846,7 +835,7 @@ class Note extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Promise<Branch[]>} child branches of this note
|
* @returns {Branch[]} child branches of this note
|
||||||
*/
|
*/
|
||||||
getChildBranches() {
|
getChildBranches() {
|
||||||
return this.repository.getEntities(`
|
return this.repository.getEntities(`
|
||||||
@ -858,7 +847,7 @@ class Note extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @returns {Promise<Note[]>} parent notes of this note (note can have multiple parents because of cloning)
|
* @returns {Note[]} parent notes of this note (note can have multiple parents because of cloning)
|
||||||
*/
|
*/
|
||||||
getParentNotes() {
|
getParentNotes() {
|
||||||
return this.repository.getEntities(`
|
return this.repository.getEntities(`
|
||||||
@ -872,7 +861,7 @@ class Note extends Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return {Promise<string[][]>} - array of notePaths (each represented by array of noteIds constituting the particular note path)
|
* @return {string[][]} - array of notePaths (each represented by array of noteIds constituting the particular note path)
|
||||||
*/
|
*/
|
||||||
getAllNotePaths() {
|
getAllNotePaths() {
|
||||||
if (this.noteId === 'root') {
|
if (this.noteId === 'root') {
|
||||||
@ -893,7 +882,7 @@ class Note extends Entity {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ancestorNoteId
|
* @param ancestorNoteId
|
||||||
* @return {Promise<boolean>} - true if ancestorNoteId occurs in at least one of the note's paths
|
* @return {boolean} - true if ancestorNoteId occurs in at least one of the note's paths
|
||||||
*/
|
*/
|
||||||
isDescendantOfNote(ancestorNoteId) {
|
isDescendantOfNote(ancestorNoteId) {
|
||||||
const notePaths = this.getAllNotePaths();
|
const notePaths = this.getAllNotePaths();
|
||||||
|
@ -64,7 +64,7 @@ class NoteRevision extends Entity {
|
|||||||
* This is the same approach as is used for Note's content.
|
* This is the same approach as is used for Note's content.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @returns {Promise<*>} */
|
/** @returns {*} */
|
||||||
getContent(silentNotFoundError = false) {
|
getContent(silentNotFoundError = false) {
|
||||||
if (this.content === undefined) {
|
if (this.content === undefined) {
|
||||||
const res = sql.getRow(`SELECT content, hash FROM note_revision_contents WHERE noteRevisionId = ?`, [this.noteRevisionId]);
|
const res = sql.getRow(`SELECT content, hash FROM note_revision_contents WHERE noteRevisionId = ?`, [this.noteRevisionId]);
|
||||||
|
@ -96,7 +96,7 @@ const TPL = `
|
|||||||
<hr class="w-100">
|
<hr class="w-100">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="inherited-attributes"></div>
|
<div class="inherited-attributes-wrapper"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -128,7 +128,6 @@ export default class AttributeListWidget extends TabAwareWidget {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.$ownedAndInheritedWrapper = this.$widget.find('.owned-and-inherited-wrapper');
|
this.$ownedAndInheritedWrapper = this.$widget.find('.owned-and-inherited-wrapper');
|
||||||
this.$ownedAndInheritedWrapper.toggle(options.is('attributeListExpanded'));
|
|
||||||
|
|
||||||
this.$ownedExpander = this.$widget.find('.attr-owned-and-inherited-expander');
|
this.$ownedExpander = this.$widget.find('.attr-owned-and-inherited-expander');
|
||||||
this.$ownedExpander.on('click', async () => {
|
this.$ownedExpander.on('click', async () => {
|
||||||
@ -141,15 +140,15 @@ export default class AttributeListWidget extends TabAwareWidget {
|
|||||||
|
|
||||||
this.$ownedExpanderText = this.$ownedExpander.find('.attr-expander-text');
|
this.$ownedExpanderText = this.$ownedExpander.find('.attr-expander-text');
|
||||||
|
|
||||||
this.$inheritedAttributes = this.$widget.find('.inherited-attributes');
|
this.$inheritedAttributesWrapper = this.$widget.find('.inherited-attributes-wrapper');
|
||||||
|
|
||||||
this.$inheritedExpander = this.$widget.find('.attr-inherited-expander');
|
this.$inheritedExpander = this.$widget.find('.attr-inherited-expander');
|
||||||
this.$inheritedExpander.on('click', () => {
|
this.$inheritedExpander.on('click', () => {
|
||||||
if (this.$inheritedAttributes.is(":visible")) {
|
if (this.$inheritedAttributesWrapper.is(":visible")) {
|
||||||
this.$inheritedAttributes.slideUp(200);
|
this.$inheritedAttributesWrapper.slideUp(200);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.$inheritedAttributes.slideDown(200);
|
this.$inheritedAttributesWrapper.slideDown(200);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -163,6 +162,18 @@ export default class AttributeListWidget extends TabAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async refreshWithNote(note) {
|
async refreshWithNote(note) {
|
||||||
|
const hasPromotedAttrs = this.promotedAttributesWidget.getPromotedAttributes().length > 0;
|
||||||
|
|
||||||
|
if (hasPromotedAttrs) {
|
||||||
|
this.$allAttrWrapper.show();
|
||||||
|
this.$ownedAndInheritedWrapper.hide();
|
||||||
|
this.$inheritedAttributesWrapper.hide();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.$promotedExpander.hide();
|
||||||
|
this.$ownedAndInheritedWrapper.toggle(options.is('attributeListExpanded'));
|
||||||
|
}
|
||||||
|
|
||||||
const ownedAttributes = note.getOwnedAttributes().filter(attr => !attr.isAutoLink);
|
const ownedAttributes = note.getOwnedAttributes().filter(attr => !attr.isAutoLink);
|
||||||
|
|
||||||
this.$ownedExpanderText.text(ownedAttributes.length + ' owned ' + this.attrPlural(ownedAttributes.length));
|
this.$ownedExpanderText.text(ownedAttributes.length + ' owned ' + this.attrPlural(ownedAttributes.length));
|
||||||
@ -180,9 +191,9 @@ export default class AttributeListWidget extends TabAwareWidget {
|
|||||||
|
|
||||||
this.$inheritedExpanderText.text(inheritedAttributes.length + ' inherited ' + this.attrPlural(inheritedAttributes.length));
|
this.$inheritedExpanderText.text(inheritedAttributes.length + ' inherited ' + this.attrPlural(inheritedAttributes.length));
|
||||||
|
|
||||||
this.$inheritedAttributes.empty();
|
this.$inheritedAttributesWrapper.empty();
|
||||||
|
|
||||||
await this.renderInheritedAttributes(inheritedAttributes, this.$inheritedAttributes);
|
await this.renderInheritedAttributes(inheritedAttributes, this.$inheritedAttributesWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
attrPlural(number) {
|
attrPlural(number) {
|
||||||
|
@ -43,55 +43,60 @@ export default class PromotedAttributesWidget extends TabAwareWidget {
|
|||||||
async refreshWithNote(note) {
|
async refreshWithNote(note) {
|
||||||
this.$container.empty();
|
this.$container.empty();
|
||||||
|
|
||||||
const attributes = note.getAttributes();
|
const promotedAttributes = this.getPromotedAttributes();
|
||||||
|
const attributes = note.getAttributes();console.log(this.note.getAttributes());
|
||||||
|
|
||||||
const promoted = attributes
|
const cells = [];
|
||||||
|
|
||||||
|
if (promotedAttributes.length === 0) {
|
||||||
|
this.toggleInt(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const definitionAttr of promotedAttributes) {
|
||||||
|
const definitionType = definitionAttr.name.startsWith('label:') ? 'label' : 'relation';
|
||||||
|
const valueName = definitionAttr.name.substr(definitionType.length + 1);
|
||||||
|
|
||||||
|
let valueAttrs = attributes.filter(el => el.name === valueName && el.type === definitionType);
|
||||||
|
|
||||||
|
if (valueAttrs.length === 0) {
|
||||||
|
valueAttrs.push({
|
||||||
|
attributeId: "",
|
||||||
|
type: definitionType,
|
||||||
|
name: valueName,
|
||||||
|
value: ""
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (definitionAttr.value.multiplicity === 'single') {
|
||||||
|
valueAttrs = valueAttrs.slice(0, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const valueAttr of valueAttrs) {
|
||||||
|
const $cell = await this.createPromotedAttributeCell(definitionAttr, valueAttr, valueName);
|
||||||
|
|
||||||
|
cells.push($cell);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// we replace the whole content in one step so there can't be any race conditions
|
||||||
|
// (previously we saw promoted attributes doubling)
|
||||||
|
this.$container.empty().append(...cells);
|
||||||
|
this.toggleInt(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
getPromotedAttributes() {
|
||||||
|
if (this.note.hasLabel('hidePromotedAttributes')) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.note.getAttributes()
|
||||||
.filter(attr => attr.isDefinition())
|
.filter(attr => attr.isDefinition())
|
||||||
.filter(attr => {
|
.filter(attr => {
|
||||||
const def = attr.getDefinition();
|
const def = attr.getDefinition();
|
||||||
|
|
||||||
return def && def.isPromoted;
|
return def && def.isPromoted;
|
||||||
});
|
});
|
||||||
|
|
||||||
const cells = [];
|
|
||||||
|
|
||||||
if (promoted.length > 0 && !note.hasLabel('hidePromotedAttributes')) {
|
|
||||||
for (const definitionAttr of promoted) {
|
|
||||||
const definitionType = definitionAttr.name.startsWith('label:') ? 'label' : 'relation';
|
|
||||||
const valueName = definitionAttr.name.substr(definitionType.length + 1);
|
|
||||||
|
|
||||||
let valueAttrs = attributes.filter(el => el.name === valueName && el.type === 'label');
|
|
||||||
|
|
||||||
if (valueAttrs.length === 0) {
|
|
||||||
valueAttrs.push({
|
|
||||||
attributeId: "",
|
|
||||||
type: definitionType,
|
|
||||||
name: valueName,
|
|
||||||
value: ""
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (definitionAttr.value.multiplicity === 'single') {
|
|
||||||
valueAttrs = valueAttrs.slice(0, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const valueAttr of valueAttrs) {
|
|
||||||
const $cell = await this.createPromotedAttributeCell(definitionAttr, valueAttr, valueName);
|
|
||||||
|
|
||||||
cells.push($cell);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// we replace the whole content in one step so there can't be any race conditions
|
|
||||||
// (previously we saw promoted attributes doubling)
|
|
||||||
this.$container.empty().append(...cells);
|
|
||||||
this.toggleInt(true);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.toggleInt(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return attributes;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async createPromotedAttributeCell(definitionAttr, valueAttr, valueName) {
|
async createPromotedAttributeCell(definitionAttr, valueAttr, valueName) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user