Merge pull request 'Ticketliste im Spalten-Modal: neuestes Ticket zuerst' (#103) from fds2610-bot/monitor:main into main

Reviewed-on: https://codeberg.org/fds2610/monitor/pulls/103
This commit is contained in:
fds2610 2026-10-01 07:55:53 +02:00
commit ed0652ddd5
2 changed files with 32 additions and 10 deletions

View file

@ -227,6 +227,11 @@ export function truncateDescriptionLines(text, maxLines = TICKET_DESCRIPTION_MAX
* traegt jedes Ticket sein Quell-Repo ("owner/name") selbst in ticket.repo; opts dient nur
* noch als Fallback fuer aeltere Tickets ohne dieses Feld.
*
* Issue #102: Die Liste im Modal zeigt das neueste Ticket zuerst, absteigend nach Alter.
* tickets kommt (ueber groupTicketsByColumn()) aeltestes zuerst herein, weil das Board selbst
* diese Reihenfolge fuer die "aelteste 4 + Stapel"-Regel (F3, buildBoardColumnLayout())
* braucht - hier wird deshalb nur fuer die Modal-Ausgabe umgedreht.
*
* @param {string} columnKey
* @param {Array<object>} tickets
* @param {{codebergOwner?: string, codebergRepo?: string}} [opts]
@ -234,10 +239,11 @@ export function truncateDescriptionLines(text, maxLines = TICKET_DESCRIPTION_MAX
export function buildTicketModalContent(columnKey, tickets = [], opts = {}) {
const { codebergOwner = "fds2610", codebergRepo = "monitor" } = opts;
const column = BOARD_COLUMNS.find((c) => c.key === columnKey);
const newestFirst = [...tickets].reverse();
return {
title: column ? column.label : columnKey,
items: tickets.map((ticket) => ({
items: newestFirst.map((ticket) => ({
id: ticket.id,
title: ticket.title,
description: truncateDescriptionLines(ticket.description),

View file

@ -268,8 +268,9 @@ test("buildTicketModalContent traegt Titel/Spaltenlabel und baut Codeberg-Links
{ id: 2, title: "B", description: "", source: "api", external_ref: null },
]);
assert.equal(content.title, "Bereit");
assert.equal(content.items[0].link, "https://codeberg.org/fds2610/monitor/issues/42");
assert.equal(content.items[1].link, null);
// Issue #102: Modal zeigt neuestes Ticket zuerst, also id 2 (zuletzt in der Eingabe) vor id 1.
assert.equal(content.items[0].link, null);
assert.equal(content.items[1].link, "https://codeberg.org/fds2610/monitor/issues/42");
});
test("buildTicketModalContent respektiert benutzerdefinierten owner/repo", () => {
@ -286,8 +287,21 @@ test("buildTicketModalContent baut den Link aus dem repo-Feld des Tickets, nicht
{ id: 1, title: "A", source: "codeberg", external_ref: "3", repo: "fds2610/Steuerkram", color: "#28a745" },
{ id: 2, title: "B", source: "codeberg", external_ref: "9", repo: "fds2610/nc-gantt", color: "#0366d6" },
]);
assert.equal(content.items[0].link, "https://codeberg.org/fds2610/Steuerkram/issues/3");
assert.equal(content.items[1].link, "https://codeberg.org/fds2610/nc-gantt/issues/9");
// Issue #102: Modal zeigt neuestes Ticket zuerst, also id 2 (zuletzt in der Eingabe) vor id 1.
assert.equal(content.items[0].link, "https://codeberg.org/fds2610/nc-gantt/issues/9");
assert.equal(content.items[1].link, "https://codeberg.org/fds2610/Steuerkram/issues/3");
});
test("buildTicketModalContent zeigt das neueste Ticket zuerst, absteigend nach Alter (Issue #102)", () => {
const content = buildTicketModalContent("backlog", [
{ id: 1, title: "aeltestes" },
{ id: 2, title: "mittel" },
{ id: 3, title: "neuestes" },
]);
assert.deepEqual(
content.items.map((item) => item.id),
[3, 2, 1]
);
});
// ---------------------------------------------------------------------------------------
@ -949,15 +963,17 @@ test("buildTicketModalContent liefert Repo und Ticket-Nummer fuer die Ueberschri
{ id: 1, title: "A", source: "codeberg", external_ref: "3", repo: "fds2610/Steuerkram" },
{ id: 2, title: "B", source: "api", external_ref: null },
]);
assert.equal(content.items[0].repo, "fds2610/Steuerkram");
assert.equal(content.items[0].number, "3");
assert.equal(content.items[1].repo, null);
assert.equal(content.items[1].number, null);
// Issue #102: Modal zeigt neuestes Ticket zuerst, also id 2 (zuletzt in der Eingabe) vor id 1.
assert.equal(content.items[0].repo, null);
assert.equal(content.items[0].number, null);
assert.equal(content.items[1].repo, "fds2610/Steuerkram");
assert.equal(content.items[1].number, "3");
});
test("buildTicketModalContent kuerzt Beschreibungen auf 10 Zeilen mit '...' (Issue #88)", () => {
const lines = Array.from({ length: 12 }, (_, i) => `Zeile ${i + 1}`);
const [long, exact] = buildTicketModalContent("backlog", [
// Issue #102: Modal zeigt neuestes Ticket zuerst, also kommt "exact" (id 2) vor "long" (id 1).
const [exact, long] = buildTicketModalContent("backlog", [
{ id: 1, title: "A", description: lines.join("\n") },
{ id: 2, title: "B", description: lines.slice(0, 10).join("\n") },
]).items;