mirror of
https://github.com/zadam/trilium.git
synced 2025-01-16 20:21:43 +08:00
implemented "targetRelationCount" and exposed more of them in order by widget, fixes #1658
This commit is contained in:
parent
2cfd093cae
commit
4160da70be
5 changed files with 49 additions and 0 deletions
|
@ -16,6 +16,11 @@ const TPL = `
|
|||
<option value="contentSize">Note content size</option>
|
||||
<option value="noteSize">Note content size including revisions</option>
|
||||
<option value="revisionCount">Number of revisions</option>
|
||||
<option value="childrenCount">Number of children notes</option>
|
||||
<option value="parentCount">Number of clones</option>
|
||||
<option value="ownedLabelCount">Number of labels</option>
|
||||
<option value="ownedRelationCount">Number of relations</option>
|
||||
<option value="targetRelationCount">Number of relations targeting the note</option>
|
||||
</select>
|
||||
|
||||
<select name="orderDirection" class="form-control w-auto d-inline">
|
||||
|
|
|
@ -46,6 +46,10 @@ class Attribute {
|
|||
|| (this.type === 'relation' && this.name === 'template');
|
||||
}
|
||||
|
||||
isAutoLink() {
|
||||
return this.type === 'relation' && ['internalLink', 'imageLink', 'relationMapLink', 'includeNoteLink'].includes(this.name);
|
||||
}
|
||||
|
||||
get note() {
|
||||
return this.noteCache.notes[this.noteId];
|
||||
}
|
||||
|
|
|
@ -319,14 +319,42 @@ class Note {
|
|||
return this.attributes.filter(attr => attr.type === 'label').length;
|
||||
}
|
||||
|
||||
get ownedLabelCount() {
|
||||
return this.ownedAttributes.filter(attr => attr.type === 'label').length;
|
||||
}
|
||||
|
||||
get relationCount() {
|
||||
return this.attributes.filter(attr => attr.type === 'relation' && !attr.isAutoLink()).length;
|
||||
}
|
||||
|
||||
get relationCountIncludingLinks() {
|
||||
return this.attributes.filter(attr => attr.type === 'relation').length;
|
||||
}
|
||||
|
||||
get ownedRelationCount() {
|
||||
return this.ownedAttributes.filter(attr => attr.type === 'relation' && !attr.isAutoLink()).length;
|
||||
}
|
||||
|
||||
get ownedRelationCountIncludingLinks() {
|
||||
return this.ownedAttributes.filter(attr => attr.type === 'relation').length;
|
||||
}
|
||||
|
||||
get targetRelationCount() {
|
||||
return this.targetRelations.filter(attr => !attr.isAutoLink()).length;
|
||||
}
|
||||
|
||||
get targetRelationCountIncludingLinks() {
|
||||
return this.targetRelations.length;
|
||||
}
|
||||
|
||||
get attributeCount() {
|
||||
return this.attributes.length;
|
||||
}
|
||||
|
||||
get ownedAttributeCount() {
|
||||
return this.attributes.length;
|
||||
}
|
||||
|
||||
get ancestors() {
|
||||
if (!this.ancestorCache) {
|
||||
const noteIds = new Set();
|
||||
|
|
|
@ -23,7 +23,13 @@ const PROP_MAPPING = {
|
|||
"childrencount": "childrenCount",
|
||||
"attributecount": "attributeCount",
|
||||
"labelcount": "labelCount",
|
||||
"ownedlabelcount": "ownedLabelCount",
|
||||
"relationcount": "relationCount",
|
||||
"ownedrelationcount": "ownedRelationCount",
|
||||
"relationcountincludinglinks": "relationCountIncludingLinks",
|
||||
"ownedrelationcountincludinglinks": "ownedRelationCountIncludingLinks",
|
||||
"targetrelationcount": "targetRelationCount",
|
||||
"targetrelationcountincludinglinks": "targetRelationCountIncludingLinks",
|
||||
"contentsize": "contentSize",
|
||||
"notesize": "noteSize",
|
||||
"revisioncount": "revisionCount"
|
||||
|
|
|
@ -19,7 +19,13 @@ const PROP_MAPPING = {
|
|||
"childrencount": "childrenCount",
|
||||
"attributecount": "attributeCount",
|
||||
"labelcount": "labelCount",
|
||||
"ownedlabelcount": "ownedLabelCount",
|
||||
"relationcount": "relationCount",
|
||||
"ownedrelationcount": "ownedRelationCount",
|
||||
"relationcountincludinglinks": "relationCountIncludingLinks",
|
||||
"ownedrelationcountincludinglinks": "ownedRelationCountIncludingLinks",
|
||||
"targetrelationcount": "targetRelationCount",
|
||||
"targetrelationcountincludinglinks": "targetRelationCountIncludingLinks",
|
||||
"contentsize": "contentSize",
|
||||
"notesize": "noteSize",
|
||||
"revisioncount": "revisionCount"
|
||||
|
|
Loading…
Reference in a new issue