Move readonly item property display values to server

This commit is contained in:
Jage9
2026-02-27 01:32:25 -05:00
parent ad50fc9afb
commit 4840aa454b
7 changed files with 62 additions and 15 deletions

View File

@@ -1,5 +1,5 @@
// Maintainer-controlled web client version.
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
window.CHGRID_WEB_VERSION = "2026.02.25 R275";
window.CHGRID_WEB_VERSION = "2026.02.25 R276";
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
window.CHGRID_TIME_ZONE = "America/Detroit";

View File

@@ -34,17 +34,7 @@ export function createItemPropertyPresentation(deps: PresentationDeps): {
const getItemPropertyValue = (item: WorldItem, key: string): string => {
if (key === 'title') return item.title;
if (key === 'type') return item.type;
if (key === 'x') return String(item.x);
if (key === 'y') return String(item.y);
if (key === 'carrierId') return item.carrierId ?? 'none';
if (key === 'version') return String(item.version);
if (key === 'createdBy') return item.createdBy;
if (key === 'createdAt') return deps.formatTimestampMs(item.createdAt);
if (key === 'updatedAt') return deps.formatTimestampMs(item.updatedAt);
if (key === 'capabilities') return item.capabilities.join(', ') || 'none';
if (key === 'useSound') return toSoundDisplayName(item.params.useSound ?? item.useSound);
if (key === 'emitSound') return toSoundDisplayName(item.params.emitSound ?? item.emitSound);
if (item.display && typeof item.display[key] === 'string') return item.display[key];
const metadata = getItemPropertyMetadata(item.type, key);
const globalValue = getItemTypeGlobalProperties(item.type)?.[key];
const paramValue = item.params[key];
@@ -69,6 +59,17 @@ export function createItemPropertyPresentation(deps: PresentationDeps): {
if (metadata?.valueType === 'list' || metadata?.valueType === 'text') {
return rawValue === undefined || rawValue === null ? '' : String(rawValue);
}
if (key === 'type') return item.type;
if (key === 'x') return String(item.x);
if (key === 'y') return String(item.y);
if (key === 'carrierId') return item.carrierId ?? 'none';
if (key === 'version') return String(item.version);
if (key === 'createdBy') return item.createdBy;
if (key === 'createdAt') return deps.formatTimestampMs(item.createdAt);
if (key === 'updatedAt') return deps.formatTimestampMs(item.updatedAt);
if (key === 'capabilities') return item.capabilities.join(', ') || 'none';
if (key === 'useSound') return toSoundDisplayName(item.params.useSound ?? item.useSound);
if (key === 'emitSound') return toSoundDisplayName(item.params.emitSound ?? item.emitSound);
if (paramValue !== undefined) return String(paramValue);
if (globalValue !== undefined) return String(globalValue);
return '';

View File

@@ -15,6 +15,7 @@ export const itemSchema = z.object({
emitSound: z.string().optional(),
params: z.record(z.string(), z.unknown()),
carrierId: z.string().nullable().optional(),
display: z.record(z.string(), z.string()).optional(),
});
export const welcomeMessageSchema = z.object({

View File

@@ -19,6 +19,7 @@ export type WorldItem = {
emitSound?: string;
params: Record<string, unknown>;
carrierId?: string | null;
display?: Record<string, string>;
};
export type SelectionContext = 'pickup' | 'drop' | 'delete' | 'edit' | 'use' | 'secondaryUse' | 'inspect' | null;