feat(app): search, sort, count and date on the official sheet list
Boards 28 and 29 A: name search with clear button and Escape, « Trier par » (last modification by default, or name), a polite count line, « Modifiée le … » on each row in a <time>, and the search no-result block. The detail line moves to labels.ts as sheetDetails. R-24: no existing assertion removed or rewritten; six tests added.
This commit is contained in:
1 parent
a950e403c2
commit
423125c18f
6 files changed
+534
-133
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import type {
|
||||
CatalogSpecies,
|
||||
OfficialSheetAdminSummary,
|
||||
SheetAdminPerson,
|
||||
SheetAdminRound,
|
||||
SheetFailureKind,
|
||||
@@ -125,6 +126,49 @@ export function formatShortParisDateTime(iso: string, locale: Locale): string {
|
||||
return SHORT_DATE_TIME[locale].format(new Date(iso))
|
||||
}
|
||||
|
||||
type SheetSummary = OfficialSheetAdminSummary
|
||||
|
||||
/** « version publiée 3 » or « aucune version publiée », then « brouillon version 4 » if any. */
|
||||
function versionParts(t: Translate, sheet: SheetSummary): string[] {
|
||||
const number = (key: string, value: number) =>
|
||||
t(key).replace('{number}', String(value))
|
||||
const current = sheet.current_version
|
||||
? number(
|
||||
'admin.sheets.current_version',
|
||||
sheet.current_version.version_number,
|
||||
)
|
||||
: t('admin.sheets.no_published')
|
||||
const draft = sheet.draft_version
|
||||
? [number('admin.sheets.draft', sheet.draft_version.version_number)]
|
||||
: []
|
||||
return [current, ...draft]
|
||||
}
|
||||
|
||||
/** « revue n° 2 : À relire » when the sheet has a round. */
|
||||
function roundPart(t: Translate, sheet: SheetSummary): string[] {
|
||||
if (!sheet.latest_round) return []
|
||||
return [
|
||||
t('admin.sheets.latest_round')
|
||||
.replace('{round}', String(sheet.latest_round.round))
|
||||
.replace('{status}', roundLabel(t, sheet.latest_round).title),
|
||||
]
|
||||
}
|
||||
|
||||
/** The detail line of a sheet row: « Cheval · Active · version publiée 3 · … » (board 28). */
|
||||
export function sheetDetails(
|
||||
t: Translate,
|
||||
sheet: SheetSummary,
|
||||
species: readonly CatalogSpecies[],
|
||||
locale: Locale,
|
||||
): string {
|
||||
return [
|
||||
speciesLabel(sheet.species_id, species, locale),
|
||||
t(`admin.sheet_status.${sheet.status}`),
|
||||
...versionParts(t, sheet),
|
||||
...roundPart(t, sheet),
|
||||
].join(' · ')
|
||||
}
|
||||
|
||||
/**
|
||||
* The round's state (§3). A failed verification names its cause only when
|
||||
* the server recorded one (`failure_outcome`, BDR-095): the title of that
|
||||
|
||||
Reference in new issue
Block a user