Compare commits

...

7 Commits

Author SHA1 Message Date
Romain DEP.
aa1780c027
Merge a1c03143342078c68301cc7bc51a68ce4840c5dc into 67d2175ce93939e05709856a624004168ff66daf 2025-12-03 08:46:19 +00:00
Elian Doran
67d2175ce9
Translations update from Hosted Weblate (#7924)
Some checks are pending
Checks / main (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Dev / Test development (push) Waiting to run
Dev / Build Docker image (push) Blocked by required conditions
Dev / Check Docker build (Dockerfile) (push) Blocked by required conditions
Dev / Check Docker build (Dockerfile.alpine) (push) Blocked by required conditions
/ Check Docker build (Dockerfile) (push) Waiting to run
/ Check Docker build (Dockerfile.alpine) (push) Waiting to run
/ Build Docker images (Dockerfile, ubuntu-24.04-arm, linux/arm64) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.alpine, ubuntu-latest, linux/amd64) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v7) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v8) (push) Blocked by required conditions
/ Merge manifest lists (push) Blocked by required conditions
playwright / E2E tests on linux-arm64 (push) Waiting to run
playwright / E2E tests on linux-x64 (push) Waiting to run
2025-12-03 08:46:09 +00:00
Elian Doran
8a3283f1ea
Update apps/client/src/translations/it/translation.json
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-12-03 08:45:42 +00:00
green
2fb47fc186
Translated using Weblate (Japanese)
Currently translated at 100.0% (1636 of 1636 strings)

Translation: Trilium Notes/Client
Translate-URL: https://hosted.weblate.org/projects/trilium/client/ja/
2025-12-03 09:18:16 +01:00
Giovi
4530c9a40c
Translated using Weblate (Italian)
Currently translated at 100.0% (1636 of 1636 strings)

Translation: Trilium Notes/Client
Translate-URL: https://hosted.weblate.org/projects/trilium/client/it/
2025-12-03 09:18:15 +01:00
Romain DEP.
a1c0314334 chore(sorting): add test cases for previous commit and increase test coverage 2025-11-28 23:28:14 +01:00
Romain DEP.
3ecdcd9ea0 fix(sorting): BC! give precedence to #top notes over #sortFolderFirst 2025-11-28 23:22:20 +01:00
4 changed files with 99 additions and 33 deletions

View File

@ -1306,8 +1306,8 @@
"zpetne_odkazy": {
"relation": "relazione",
"backlink_one": "{{count}} Backlink",
"backlink_many": "",
"backlink_other": "{{count}} Backlink"
"backlink_many": "{{count}} Backlinks",
"backlink_other": "{{count}} Backlinks"
},
"mobile_detail_menu": {
"insert_child_note": "Inserisci nota secondaria",
@ -1801,8 +1801,8 @@
"relation-map": "Mappa delle relazioni",
"note-map": "Nota Mappa",
"render-note": "Nota di rendering",
"book": "Collezione",
"mermaid-diagram": "Diagramma della sirena",
"book": "Raccolta",
"mermaid-diagram": "Diagramma Mermaid",
"canvas": "Tela",
"web-view": "Visualizzazione Web",
"mind-map": "Mappa mentale",
@ -1967,7 +1967,8 @@
"open_note_in_new_tab": "Apri la nota in una nuova scheda",
"open_note_in_new_split": "Apri nota in una nuova divisione",
"open_note_in_new_window": "Apri la nota in una nuova finestra",
"open_note_in_popup": "Modifica rapida"
"open_note_in_popup": "Modifica rapida",
"open_note_in_other_split": "Apri nota nell'altra divisione"
},
"help-button": {
"title": "Apri la pagina di aiuto pertinente"

View File

@ -1158,7 +1158,8 @@
"open_note_in_popup": "クイック編集",
"open_note_in_new_tab": "新しいタブでノートを開く",
"open_note_in_new_split": "新しく分割してノートを開く",
"open_note_in_new_window": "新しいウィンドウでノートを開く"
"open_note_in_new_window": "新しいウィンドウでノートを開く",
"open_note_in_other_split": "他の分割画面でノートを開く"
},
"note_tooltip": {
"quick-edit": "クイック編集",

View File

@ -1,11 +1,11 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { note, NoteBuilder } from "../test/becca_mocking.js";
import {beforeEach, describe, expect, it, vi} from "vitest";
import {note, NoteBuilder} from "../test/becca_mocking.js";
import becca from "../becca/becca.js";
import BBranch from "../becca/entities/bbranch.js";
import BNote from "../becca/entities/bnote.js";
import tree from "./tree.js";
import cls from "./cls.js";
import { buildNote } from "../test/becca_easy_mocking.js";
import {buildNote} from "../test/becca_easy_mocking.js";
describe("Tree", () => {
let rootNote!: NoteBuilder;
@ -48,6 +48,23 @@ describe("Tree", () => {
};
});
});
it("sorts notes by title (base case)", () => {
const note = buildNote({
children: [
{title: "1"},
{title: "2"},
{title: "3"},
],
"#sorted": "",
});
cls.init(() => {
tree.sortNotesIfNeeded(note.noteId);
});
const orderedTitles = note.children.map((child) => child.title);
expect(orderedTitles).toStrictEqual(["1", "2", "3"]);
}
)
it("custom sort order is idempotent", () => {
rootNote.label("sorted", "order");
@ -56,13 +73,15 @@ describe("Tree", () => {
for (let i = 0; i <= 5; i++) {
rootNote.child(note(String(i)).label("order", String(i)));
}
rootNote.child(note("top").label("top"));
rootNote.child(note("bottom").label("bottom"));
// Add a few values which have no defined order.
for (let i = 6; i < 10; i++) {
rootNote.child(note(String(i)));
}
const expectedOrder = [ "0", "1", "2", "3", "4", "5", "6", "7", "8", "9" ];
const expectedOrder = ["top", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "bottom"];
// Sort a few times to ensure that the resulting order is the same.
for (let i = 0; i < 5; i++) {
@ -78,12 +97,12 @@ describe("Tree", () => {
it("pins to the top and bottom", () => {
const note = buildNote({
children: [
{ title: "bottom", "#bottom": "" },
{ title: "5" },
{ title: "3" },
{ title: "2" },
{ title: "1" },
{ title: "top", "#top": "" }
{title: "bottom", "#bottom": ""},
{title: "5"},
{title: "3"},
{title: "2"},
{title: "1"},
{title: "top", "#top": ""}
],
"#sorted": ""
});
@ -91,18 +110,18 @@ describe("Tree", () => {
tree.sortNotesIfNeeded(note.noteId);
});
const orderedTitles = note.children.map((child) => child.title);
expect(orderedTitles).toStrictEqual([ "top", "1", "2", "3", "5", "bottom" ]);
expect(orderedTitles).toStrictEqual(["top", "1", "2", "3", "5", "bottom"]);
});
it("pins to the top and bottom in reverse order", () => {
const note = buildNote({
children: [
{ title: "bottom", "#bottom": "" },
{ title: "1" },
{ title: "2" },
{ title: "3" },
{ title: "5" },
{ title: "top", "#top": "" }
{title: "bottom", "#bottom": ""},
{title: "1"},
{title: "2"},
{title: "3"},
{title: "5"},
{title: "top", "#top": ""}
],
"#sorted": "",
"#sortDirection": "desc"
@ -111,6 +130,50 @@ describe("Tree", () => {
tree.sortNotesIfNeeded(note.noteId);
});
const orderedTitles = note.children.map((child) => child.title);
expect(orderedTitles).toStrictEqual([ "top", "5", "3", "2", "1", "bottom" ]);
expect(orderedTitles).toStrictEqual(["top", "5", "3", "2", "1", "bottom"]);
});
it("keeps folder notes on top when #sortFolderFirst is set, but not above #top", () => {
const note = buildNote({
children: [
{title: "bottom", "#bottom": ""},
{title: "1"},
{title: "2"},
{title: "p1", children: [{title: "1.1"}, {title: "1.2"}]},
{title: "p2", children: [{title: "2.1"}, {title: "2.2"}]},
{title: "3"},
{title: "5"},
{title: "top", "#top": ""}
],
"#sorted": "",
"#sortFoldersFirst": ""
});
cls.init(() => {
tree.sortNotesIfNeeded(note.noteId);
});
const orderedTitles = note.children.map((child) => child.title);
expect(orderedTitles).toStrictEqual(["top", "p1", "p2", "1", "2", "3", "5", "bottom"]);
});
it("sorts notes accordingly when #sortNatural is set", () => {
const note = buildNote({
children: [
{title: "bottom", "#bottom": ""},
{title: "1"},
{title: "2"},
{title: "10"},
{title: "20"},
{title: "3"},
{title: "top", "#top": ""}
],
"#sorted": "",
"#sortNatural": ""
});
cls.init(() => {
tree.sortNotesIfNeeded(note.noteId);
});
const orderedTitles = note.children.map((child) => child.title);
expect(orderedTitles).toStrictEqual(["top", "1", "2", "3", "10", "20", "bottom"]);
}
)
});

View File

@ -98,15 +98,6 @@ function sortNotes(parentNoteId: string, customSortBy: string = "title", reverse
}
notes.sort((a, b) => {
if (foldersFirst) {
const aHasChildren = a.hasChildren();
const bHasChildren = b.hasChildren();
if ((aHasChildren && !bHasChildren) || (!aHasChildren && bHasChildren)) {
// exactly one note of the two is a directory, so the sorting will be done based on this status
return aHasChildren ? -1 : 1;
}
}
function fetchValue(note: BNote, key: string) {
let rawValue: string | null;
@ -154,6 +145,16 @@ function sortNotes(parentNoteId: string, customSortBy: string = "title", reverse
return compare(bottomBEl, bottomAEl) * (reverse ? -1 : 1);
}
if (foldersFirst) {
const aHasChildren = a.hasChildren();
const bHasChildren = b.hasChildren();
if ((aHasChildren && !bHasChildren) || (!aHasChildren && bHasChildren)) {
// exactly one note of the two is a directory, so the sorting will be done based on this status
return aHasChildren ? -1 : 1;
}
}
const customAEl = fetchValue(a, customSortBy) ?? fetchValue(a, "title") as string;
const customBEl = fetchValue(b, customSortBy) ?? fetchValue(b, "title") as string;