mirror of
https://github.com/zadam/trilium.git
synced 2025-01-18 04:59:56 +08:00
improved note list pager for many pages
This commit is contained in:
parent
5098dda376
commit
60e2026850
6 changed files with 29 additions and 18 deletions
|
@ -239,18 +239,29 @@ class NoteListRenderer {
|
||||||
|
|
||||||
$pager.toggle(pageCount > 1);
|
$pager.toggle(pageCount > 1);
|
||||||
|
|
||||||
|
let lastPrinted;
|
||||||
|
|
||||||
for (let i = 1; i <= pageCount; i++) {
|
for (let i = 1; i <= pageCount; i++) {
|
||||||
$pager.append(
|
if (pageCount < 20 || i <= 5 || pageCount - i <= 5 || Math.abs(this.page - i) <= 2) {
|
||||||
i === this.page
|
lastPrinted = true;
|
||||||
? $('<span>').text(i).css('text-decoration', 'underline').css('font-weight', "bold")
|
|
||||||
: $('<a href="javascript:">')
|
$pager.append(
|
||||||
.text(i)
|
i === this.page
|
||||||
.on('click', () => {
|
? $('<span>').text(i).css('text-decoration', 'underline').css('font-weight', "bold")
|
||||||
this.page = i;
|
: $('<a href="javascript:">')
|
||||||
this.renderList();
|
.text(i)
|
||||||
}),
|
.on('click', () => {
|
||||||
" "
|
this.page = i;
|
||||||
);
|
this.renderList();
|
||||||
|
}),
|
||||||
|
" "
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if (lastPrinted) {
|
||||||
|
$pager.append("... ");
|
||||||
|
|
||||||
|
lastPrinted = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,9 +97,6 @@ function getNotesAndBranchesAndAttributes(noteIds) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
branches.sort((a, b) => a.notePosition - b.notePosition < 0 ? -1 : 1);
|
|
||||||
attributes.sort((a, b) => a.position - b.position < 0 ? -1 : 1);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
branches,
|
branches,
|
||||||
notes,
|
notes,
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Attribute {
|
||||||
/** @param {string} */
|
/** @param {string} */
|
||||||
this.type = row.type;
|
this.type = row.type;
|
||||||
/** @param {string} */
|
/** @param {string} */
|
||||||
this.name = row.name.toLowerCase();
|
this.name = row.name;
|
||||||
/** @param {int} */
|
/** @param {int} */
|
||||||
this.position = row.position;
|
this.position = row.position;
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ class Branch {
|
||||||
/** @param {int} */
|
/** @param {int} */
|
||||||
this.notePosition = row.notePosition;
|
this.notePosition = row.notePosition;
|
||||||
/** @param {boolean} */
|
/** @param {boolean} */
|
||||||
this.isExpanded = row.isExpanded;
|
this.isExpanded = !!row.isExpanded;
|
||||||
|
|
||||||
if (this.branchId === 'root') {
|
if (this.branchId === 'root') {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -14,7 +14,7 @@ class NoteCache {
|
||||||
this.childParentToBranch = {};
|
this.childParentToBranch = {};
|
||||||
/** @type {Object.<String, Attribute>} */
|
/** @type {Object.<String, Attribute>} */
|
||||||
this.attributes = [];
|
this.attributes = [];
|
||||||
/** @type {Object.<String, Attribute[]>} Points from attribute type-name to list of attributes them */
|
/** @type {Object.<String, Attribute[]>} Points from attribute type-name to list of attributes */
|
||||||
this.attributeIndex = {};
|
this.attributeIndex = {};
|
||||||
|
|
||||||
this.loaded = false;
|
this.loaded = false;
|
||||||
|
@ -22,7 +22,7 @@ class NoteCache {
|
||||||
|
|
||||||
/** @return {Attribute[]} */
|
/** @return {Attribute[]} */
|
||||||
findAttributes(type, name) {
|
findAttributes(type, name) {
|
||||||
return this.attributeIndex[`${type}-${name}`] || [];
|
return this.attributeIndex[`${type}-${name.toLowerCase()}`] || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {Attribute[]} */
|
/** @return {Attribute[]} */
|
||||||
|
|
|
@ -14,6 +14,7 @@ sqlInit.dbReady.then(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
function load() {
|
function load() {
|
||||||
|
const start = Date.now();
|
||||||
noteCache.reset();
|
noteCache.reset();
|
||||||
|
|
||||||
for (const row of sql.iterateRows(`SELECT noteId, title, type, mime, isProtected, dateCreated, dateModified, utcDateCreated, utcDateModified FROM notes WHERE isDeleted = 0`, [])) {
|
for (const row of sql.iterateRows(`SELECT noteId, title, type, mime, isProtected, dateCreated, dateModified, utcDateCreated, utcDateModified FROM notes WHERE isDeleted = 0`, [])) {
|
||||||
|
@ -29,6 +30,8 @@ function load() {
|
||||||
}
|
}
|
||||||
|
|
||||||
noteCache.loaded = true;
|
noteCache.loaded = true;
|
||||||
|
|
||||||
|
log.info(`Note cache load took ${Date.now() - start}ms`);
|
||||||
}
|
}
|
||||||
|
|
||||||
eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED, eventService.ENTITY_SYNCED], ({entityName, entity}) => {
|
eventService.subscribe([eventService.ENTITY_CHANGED, eventService.ENTITY_DELETED, eventService.ENTITY_SYNCED], ({entityName, entity}) => {
|
||||||
|
|
Loading…
Reference in a new issue