rename inheritableAttributeCache to __inheritableAttributeCache for consistency

This commit is contained in:
zadam 2023-05-31 23:21:06 +02:00
parent c802bf7d8b
commit b5cfc28912
4 changed files with 17 additions and 81 deletions

View File

@ -108,7 +108,7 @@ class BNote extends AbstractBeccaEntity {
this.__attributeCache = null;
/** @type {BAttribute[]|null}
* @private */
this.inheritableAttributeCache = null;
this.__inheritableAttributeCache = null;
/** @type {BAttribute[]}
* @private */
@ -454,11 +454,11 @@ class BNote extends AbstractBeccaEntity {
}
}
this.inheritableAttributeCache = [];
this.__inheritableAttributeCache = [];
for (const attr of this.__attributeCache) {
if (attr.isInheritable) {
this.inheritableAttributeCache.push(attr);
this.__inheritableAttributeCache.push(attr);
}
}
}
@ -475,11 +475,11 @@ class BNote extends AbstractBeccaEntity {
return [];
}
if (!this.inheritableAttributeCache) {
this.__getAttributes(path); // will refresh also this.inheritableAttributeCache
if (!this.__inheritableAttributeCache) {
this.__getAttributes(path); // will refresh also this.__inheritableAttributeCache
}
return this.inheritableAttributeCache;
return this.__inheritableAttributeCache;
}
__validateTypeName(type, name) {
@ -845,7 +845,7 @@ class BNote extends AbstractBeccaEntity {
this.flatTextCache = null;
this.__attributeCache = null;
this.inheritableAttributeCache = null;
this.__inheritableAttributeCache = null;
this.ancestorCache = null;
}

View File

@ -1,3 +1,4 @@
/** @param {BNote} note */
function mapNoteToPojo(note) {
return {
noteId: note.noteId,
@ -17,6 +18,7 @@ function mapNoteToPojo(note) {
};
}
/** @param {BBranch} branch */
function mapBranchToPojo(branch) {
return {
branchId: branch.branchId,
@ -29,6 +31,7 @@ function mapBranchToPojo(branch) {
};
}
/** @param {BAttribute} attr */
function mapAttributeToPojo(attr) {
return {
attributeId: attr.attributeId,
@ -46,4 +49,4 @@ module.exports = {
mapNoteToPojo,
mapBranchToPojo,
mapAttributeToPojo
};
};

View File

@ -40,7 +40,7 @@ class SNote extends AbstractShacaEntity {
/** @param {SAttribute[]|null} */
this.__attributeCache = null;
/** @param {SAttribute[]|null} */
this.inheritableAttributeCache = null;
this.__inheritableAttributeCache = null;
/** @param {SAttribute[]} */
this.targetRelations = [];
@ -190,11 +190,11 @@ class SNote extends AbstractShacaEntity {
}
}
this.inheritableAttributeCache = [];
this.__inheritableAttributeCache = [];
for (const attr of this.__attributeCache) {
if (attr.isInheritable) {
this.inheritableAttributeCache.push(attr);
this.__inheritableAttributeCache.push(attr);
}
}
}
@ -208,11 +208,11 @@ class SNote extends AbstractShacaEntity {
return [];
}
if (!this.inheritableAttributeCache) {
this.__getAttributes(path); // will refresh also this.inheritableAttributeCache
if (!this.__inheritableAttributeCache) {
this.__getAttributes(path); // will refresh also this.__inheritableAttributeCache
}
return this.inheritableAttributeCache;
return this.__inheritableAttributeCache;
}
/** @returns {boolean} */

View File

@ -1,67 +0,0 @@
POST {{triliumHost}}/etapi/attributes
Authorization: {{authToken}}
Content-Type: application/json
{
"noteId": "root",
"type": "label",
"name": "mylabel",
"value": "val",
"isInheritable": true
}
> {% client.global.set("createdInheritedAttributeId", response.body.attributeId); %}
###
POST {{triliumHost}}/etapi/create-note
Authorization: {{authToken}}
Content-Type: application/json
{
"parentNoteId": "root",
"title": "Hello",
"type": "text",
"content": "Hi there!"
}
> {%
client.global.set("createdNoteId", response.body.note.noteId);
client.global.set("createdBranchId", response.body.branch.branchId);
%}
###
POST {{triliumHost}}/etapi/attributes
Authorization: {{authToken}}
Content-Type: application/json
{
"noteId": "{{createdNoteId}}",
"type": "label",
"name": "mylabel",
"value": "val",
"isInheritable": false
}
> {% client.global.set("createdOwnedAttributeId", response.body.attributeId); %}
###
DELETE {{triliumHost}}/etapi/attributes/{{createdOwnedAttributeId}}
Authorization: {{authToken}}
> {% client.assert(response.status === 204); %}
###
GET {{triliumHost}}/etapi/notes/{{createdNoteId}}
Authorization: {{authToken}}
> {%
client.assert(response.status === 200);
client.assert(response.body.noteId == client.global.get("createdNoteId"));
client.assert(response.body.attributes.length == 1);
client.assert(response.body.attributes[0].attributeId ==
client.global.get("createdInheritedAttributeId"));
%}