Fixed timeline height

Moved export and fixed data output
Added project budget amount widget to project listing
This commit is contained in:
2026-09-28 11:55:52 +02:00
parent 891801c73d
commit 242a4c6fbb
4 changed files with 134 additions and 30 deletions
@@ -4,7 +4,8 @@ import autoTable from 'jspdf-autotable';
export interface ExportColumn<T = any> {
header: string;
key: keyof T | string;
key?: keyof T | string;
accessor?: (row: T) => any;
format?: (value: any, row: T) => string | number;
}
@@ -138,8 +139,15 @@ export function exportToSpreadsheet<T>(options: ExportOptions<T>): void {
const rows = data.map((item) => {
const rowObj: Record<string, any> = {};
columns.forEach((col) => {
const rawVal = (item as any)[col.key];
const formatted = col.format ? col.format(rawVal, item) : (rawVal ?? '');
const rawVal = col.key ? (item as any)[col.key] : undefined;
let formatted: any = '';
if (col.format) {
formatted = col.format(rawVal, item);
} else if (col.accessor) {
formatted = col.accessor(item);
} else {
formatted = rawVal ?? '';
}
rowObj[col.header] = formatted;
});
return rowObj;
@@ -151,8 +159,15 @@ export function exportToSpreadsheet<T>(options: ExportOptions<T>): void {
const colWidths = columns.map((col) => {
const headerLen = col.header.length;
const maxDataLen = data.reduce((max, item) => {
const rawVal = (item as any)[col.key];
const formatted = col.format ? String(col.format(rawVal, item)) : String(rawVal ?? '');
const rawVal = col.key ? (item as any)[col.key] : undefined;
let formatted = '';
if (col.format) {
formatted = String(col.format(rawVal, item));
} else if (col.accessor) {
formatted = String(col.accessor(item) ?? '');
} else {
formatted = String(rawVal ?? '');
}
return Math.max(max, formatted.length);
}, headerLen);
return { wch: Math.min(Math.max(maxDataLen + 4, 12), 50) };
@@ -191,8 +206,14 @@ export function exportToPdf<T>(options: ExportOptions<T>): void {
const headers = [columns.map((c) => c.header)];
const body = data.map((item) => {
return columns.map((col) => {
const rawVal = (item as any)[col.key];
return col.format ? String(col.format(rawVal, item)) : String(rawVal ?? '');
const rawVal = col.key ? (item as any)[col.key] : undefined;
if (col.format) {
return String(col.format(rawVal, item));
}
if (col.accessor) {
return String(col.accessor(item) ?? '');
}
return String(rawVal ?? '');
});
});