mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-30 16:33:16 +00:00
fix(settings): let every date follow a date format of the user's choice
Every date in TREK was written in the interface language's format, and English is en-US, so an English interface always showed and read mm/dd/yyyy with no way to change it. A few native date inputs followed the browser instead, so one screen could mix two formats. date_format is now a user setting with an admin default, next to the time format: automatic (the language's format, as before), YYYY-MM-DD, YYYY/MM/DD, DD.MM.YYYY, DD/MM/YYYY or MM/DD/YYYY. The date picker shows, pre-fills, hints and reads typed dates in it, and every date written in numbers across the app (lists, cards, admin panels, CSV and PDF exports) goes through one formatter. Dates written with a month name keep the language's wording. The remaining native date inputs are the shared picker now. The display settings MCP tool reads and writes the key. Closes #2971
This commit is contained in:
@@ -156,6 +156,7 @@ export const MANAGED_CUSTOMER_KEYS = [
|
||||
'temperature_unit',
|
||||
'time_format',
|
||||
'week_start',
|
||||
'date_format',
|
||||
] as const;
|
||||
|
||||
const LOCKED = new Set<string>(MANAGED_LOCKED_SETTING_KEYS);
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
SUPPORTED_LANGUAGE_CODES,
|
||||
settingsBulkRequestSchema,
|
||||
weekStartSchema,
|
||||
dateFormatSchema,
|
||||
} from '@trek/shared';
|
||||
|
||||
import { z } from 'zod';
|
||||
@@ -67,6 +68,7 @@ const DISPLAY_PREFERENCES = {
|
||||
distance_unit: z.enum(['metric', 'imperial']),
|
||||
time_format: z.enum(['12h', '24h']),
|
||||
week_start: weekStartSchema,
|
||||
date_format: dateFormatSchema,
|
||||
// Booleans are the pre-'auto' form and still sit in older rows, so they stay
|
||||
// writable: this is exactly the VALID_VALUES.dark_mode set the admin-defaults
|
||||
// path accepts, and refusing them here would make a value TREK itself wrote
|
||||
@@ -132,7 +134,7 @@ export class SettingsMcp {
|
||||
|
||||
@Tool({
|
||||
name: 'get_display_settings',
|
||||
description: `Read the current user's display preferences: ${KEY_LIST}. Call this before rendering a temperature, a distance, a time of day or an amount, so the answer matches what the person sees inside TREK instead of being guessed, and call it before update_display_settings whenever the request is relative ("switch me back", "use the other unit"). Only keys that are actually set are returned; TREK's own fallbacks for the rest are celsius, metric, 24h, week_start monday, language en, start_page dashboard, start_trip_tab plan, and no personal default currency, which means amounts fall back to the currency of the trip they belong to. Stored credentials (map tokens, LLM API keys, webhook URLs, SMTP) are deliberately not part of this surface and never appear in the result.`,
|
||||
description: `Read the current user's display preferences: ${KEY_LIST}. Call this before rendering a temperature, a distance, a time of day or an amount, so the answer matches what the person sees inside TREK instead of being guessed, and call it before update_display_settings whenever the request is relative ("switch me back", "use the other unit"). Only keys that are actually set are returned; TREK's own fallbacks for the rest are celsius, metric, 24h, week_start monday, date_format auto (the interface language's own format), language en, start_page dashboard, start_trip_tab plan, and no personal default currency, which means amounts fall back to the currency of the trip they belong to. Stored credentials (map tokens, LLM API keys, webhook URLs, SMTP) are deliberately not part of this surface and never appear in the result.`,
|
||||
inputSchema: {},
|
||||
annotations: TOOL_ANNOTATIONS_READONLY,
|
||||
access: { group: 'settings', mode: 'read' },
|
||||
@@ -143,7 +145,7 @@ export class SettingsMcp {
|
||||
|
||||
@Tool({
|
||||
name: 'update_display_settings',
|
||||
description: `Change one or more of the current user's display preferences. Pass a settings object holding only the keys to change; anything left out keeps its current value. Writable keys: ${KEY_LIST}. start_page is dashboard or active_trip, start_trip_tab is one of plan, transports, buchungen, listen, finanzplan, dateien, collab (the ids are the planner's internal German ones) or plugin:<id> for a plugin tab, default_currency is a three-letter ISO code or "" to fall back to each trip's own currency, dark_mode is light, dark or auto, week_start is monday, sunday or saturday and sets the first column of every date picker in TREK. Every other key is refused, including API keys, map tokens, LLM endpoint settings and SMTP: those belong to the account owner or to whoever operates the instance and are set in TREK itself, not here. Prefer get_display_settings when you only need to read a value.`,
|
||||
description: `Change one or more of the current user's display preferences. Pass a settings object holding only the keys to change; anything left out keeps its current value. Writable keys: ${KEY_LIST}. start_page is dashboard or active_trip, start_trip_tab is one of plan, transports, buchungen, listen, finanzplan, dateien, collab (the ids are the planner's internal German ones) or plugin:<id> for a plugin tab, default_currency is a three-letter ISO code or "" to fall back to each trip's own currency, dark_mode is light, dark or auto, week_start is monday, sunday or saturday and sets the first column of every date picker in TREK, date_format is auto (the interface language's format), YYYY-MM-DD, YYYY/MM/DD, DD.MM.YYYY, DD/MM/YYYY or MM/DD/YYYY and sets how every date field and numeric date in TREK is written. Every other key is refused, including API keys, map tokens, LLM endpoint settings and SMTP: those belong to the account owner or to whoever operates the instance and are set in TREK itself, not here. Prefer get_display_settings when you only need to read a value.`,
|
||||
inputSchema: {
|
||||
settings: settingsBulkRequestSchema.shape.settings.describe(
|
||||
`Object of preference key to new value, e.g. {"temperature_unit": "fahrenheit", "distance_unit": "imperial"}. At least one key, and every key must be one of: ${KEY_LIST}.`,
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
MASKED_SETTING_VALUE,
|
||||
PLANNER_TRIP_VIEWS_KEY,
|
||||
WEEK_START_VALUES,
|
||||
DATE_FORMAT_VALUES,
|
||||
compactPlannerTripViews,
|
||||
normalizeAppearance,
|
||||
plannerTripViewsSchema,
|
||||
@@ -43,6 +44,8 @@ export const DEFAULTABLE_USER_SETTING_KEYS = [
|
||||
'time_format',
|
||||
// First day of the week in every date picker (#2029).
|
||||
'week_start',
|
||||
// How dates are written in numbers, in every date field and list (#2971).
|
||||
'date_format',
|
||||
// Instance-wide default currency for Costs (new users inherit it until they
|
||||
// pick their own). Free-form ISO code, validated on the client.
|
||||
'default_currency',
|
||||
@@ -110,6 +113,7 @@ const VALID_VALUES: Partial<Record<DefaultableKey, unknown[]>> = {
|
||||
distance_unit: ['metric', 'imperial'],
|
||||
time_format: ['12h', '24h'],
|
||||
week_start: [...WEEK_START_VALUES],
|
||||
date_format: [...DATE_FORMAT_VALUES],
|
||||
dark_mode: [true, false, 'light', 'dark', 'auto'],
|
||||
map_provider: ['leaflet', 'mapbox-gl', 'maplibre-gl'],
|
||||
llm_provider: ['local', 'openai', 'anthropic'],
|
||||
|
||||
Reference in New Issue
Block a user