forked from jappel/leistungsbilanz-ts
Support decimal commas and cell units
This commit is contained in:
parent
734a2bcfc4
commit
5fb81bab04
4 changed files with 36 additions and 10 deletions
|
|
@ -351,6 +351,24 @@ export function formatValue(value: GridValue, key?: CellKey): string {
|
|||
return String(value);
|
||||
}
|
||||
|
||||
export function formatCellValue(value: GridValue, key: CellKey): string {
|
||||
const formatted = formatValue(value, key);
|
||||
if (formatted === "-" || typeof value !== "number") {
|
||||
return formatted;
|
||||
}
|
||||
if (key === "quantity") {
|
||||
return `${formatted} St.`;
|
||||
}
|
||||
if (
|
||||
key === "powerPerUnit" ||
|
||||
key === "rowTotalPower" ||
|
||||
key === "circuitTotalPower"
|
||||
) {
|
||||
return `${formatted} kW`;
|
||||
}
|
||||
return formatted;
|
||||
}
|
||||
|
||||
export function formatPhaseTypeLabel(value: string): string {
|
||||
if (value === "single_phase") {
|
||||
return "1-phasig";
|
||||
|
|
@ -378,7 +396,7 @@ export function parseNumeric(cellKey: CellKey, draft: string): number | undefine
|
|||
if (trimmed === "") {
|
||||
return undefined;
|
||||
}
|
||||
const parsed = Number(trimmed);
|
||||
const parsed = Number(trimmed.replace(",", "."));
|
||||
if (Number.isNaN(parsed)) {
|
||||
throw new Error(`Ungültiger Zahlenwert in ${cellKey}`);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue