mirror of
https://github.com/zadam/trilium.git
synced 2025-11-13 09:59:02 +01:00
feat(board/promoted_attributes): format time
This commit is contained in:
parent
d79a23bc9e
commit
00874840b7
@ -61,11 +61,15 @@ function formatLabelValue(attr: AttributeWithDefinitions): ComponentChildren {
|
|||||||
}
|
}
|
||||||
return <><strong>{attr.friendlyName}:</strong> {formattedValue}</>;
|
return <><strong>{attr.friendlyName}:</strong> {formattedValue}</>;
|
||||||
case "date":
|
case "date":
|
||||||
case "datetime":
|
case "datetime": {
|
||||||
const date = new Date(value);
|
const date = new Date(value);
|
||||||
if (isNaN(date.getTime())) return value;
|
const timeFormat = attr.def.labelType !== "date" ? "short" : "none";
|
||||||
const timeFormat = attr.def.labelType === "datetime" ? "short" : "none";
|
|
||||||
return <><strong>{attr.friendlyName}:</strong> {formatDateTime(date, "short", timeFormat)}</>;
|
return <><strong>{attr.friendlyName}:</strong> {formatDateTime(date, "short", timeFormat)}</>;
|
||||||
|
}
|
||||||
|
case "time": {
|
||||||
|
const date = new Date(`1970-01-01T${value}Z`);
|
||||||
|
return <><strong>{attr.friendlyName}:</strong> {formatDateTime(date, "none", "short")}</>;
|
||||||
|
}
|
||||||
case "boolean":
|
case "boolean":
|
||||||
return <><Icon icon={value === "true" ? "bx bx-check-square" : "bx bx-square"} /> <strong>{attr.friendlyName}</strong></>;
|
return <><Icon icon={value === "true" ? "bx bx-check-square" : "bx bx-square"} /> <strong>{attr.friendlyName}</strong></>;
|
||||||
case "text":
|
case "text":
|
||||||
@ -81,7 +85,7 @@ function getAttributesWithDefinitions(note: FNote, attributesToIgnore: string[]
|
|||||||
const def = attr.getDefinition();
|
const def = attr.getDefinition();
|
||||||
const [ type, name ] = attr.name.split(":", 2);
|
const [ type, name ] = attr.name.split(":", 2);
|
||||||
const value = note.getLabelValue(name);
|
const value = note.getLabelValue(name);
|
||||||
const friendlyName = def?.promotedAlias ?? name;
|
const friendlyName = def?.promotedAlias || name;
|
||||||
if (!value) continue;
|
if (!value) continue;
|
||||||
if (attributesToIgnore.includes(name)) continue;
|
if (attributesToIgnore.includes(name)) continue;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user