This commit is contained in:
michael committed 2026-09-15 10:49:33 +00:00
1 parent c01d747352
commit 235c19e51b
10 files changed
+175 -31

No files matched your search

+11 -11
View File
@@ -394,7 +394,7 @@ function stableSort<T>(items: T[], compare: (left: T, right: T) => number) {
function createNote(title: string): DashboardNote {
return {
id: typeof crypto !== "undefined" && "randomUUID" in crypto ? crypto.randomUUID() : `note-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
id: typeof crypto !== "undefined" && typeof crypto.randomUUID === "function" ? crypto.randomUUID() : `note-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,
title,
content: ""
};
@@ -1746,10 +1746,10 @@ function ProjectBudgetWidget({ widget, editing, projects, stats, onNavigate, onU
{ value: "critical90", label: "Ab 90%" },
{ value: "overBudget", label: "Ab 100%" },
{ value: "withoutBudget", label: "Ohne Kontingent" },
{ value: "open", label: "Offene Projekte" },
{ value: "closed", label: "Geschlossene Projekte" },
...zammadStateFilterOptions.filter((option) => option.value !== "all").map((option) => ({ value: `zammadState:${option.value}`, label: `Status: ${option.label}` })),
...zammadPriorityFilterOptions.filter((option) => option.value !== "all").map((option) => ({ value: `zammadPriority:${option.value}`, label: `Prio: ${option.label}` })),
{ value: "open", label: "TT Offen" },
{ value: "closed", label: "TT Geschl." },
...zammadStateFilterOptions.filter((option) => option.value !== "all").map((option) => ({ value: `zammadState:${option.value}`, label: `ZA ${option.label}` })),
...zammadPriorityFilterOptions.filter((option) => option.value !== "all").map((option) => ({ value: `zammadPriority:${option.value}`, label: `ZA Prio ${option.label}` })),
{ value: "openTodos", label: "Mit offenen ToDos" },
{ value: "overdueTodos", label: "Mit überfälligen ToDos" },
{ value: "fixedBilling", label: "Fixe Abrechnungen" },
@@ -1766,8 +1766,8 @@ function ProjectBudgetWidget({ widget, editing, projects, stats, onNavigate, onU
{ value: "title", label: "Titel" },
{ value: "ticket", label: "Ticket" },
{ value: "organization", label: "Organisation" },
{ value: "zammadStatus", label: "Zammad-Status" },
{ value: "zammadPriority", label: "Zammad-Prio" }
{ value: "zammadStatus", label: "ZA Status" },
{ value: "zammadPriority", label: "ZA Prio" }
]}
onChange={onUpdateConfig}
/>
@@ -2357,8 +2357,8 @@ function FavoritesWidget({
{ value: "projects", label: "Nur Projekte" },
{ value: "openTodos", label: "Mit offenen ToDos" },
{ value: "overdueTodos", label: "Mit überfälligen ToDos" },
...zammadStateFilterOptions.filter((option) => option.value !== "all").map((option) => ({ value: `zammadState:${option.value}`, label: `Status: ${option.label}` })),
...zammadPriorityFilterOptions.filter((option) => option.value !== "all").map((option) => ({ value: `zammadPriority:${option.value}`, label: `Prio: ${option.label}` })),
...zammadStateFilterOptions.filter((option) => option.value !== "all").map((option) => ({ value: `zammadState:${option.value}`, label: `ZA ${option.label}` })),
...zammadPriorityFilterOptions.filter((option) => option.value !== "all").map((option) => ({ value: `zammadPriority:${option.value}`, label: `ZA Prio ${option.label}` })),
{ value: "missingMeta", label: "Nicht gefunden" },
{ value: "fixedBilling", label: "Fixe Abrechnungen" },
{ value: "manualBilling", label: "Ohne fixe Abrechnung" }
@@ -2370,8 +2370,8 @@ function FavoritesWidget({
{ value: "ticket", label: "Ticket" },
{ value: "title", label: "Titel" },
{ value: "recent", label: "Neu" },
{ value: "zammadStatus", label: "Zammad-Status" },
{ value: "zammadPriority", label: "Zammad-Prio" }
{ value: "zammadStatus", label: "ZA Status" },
{ value: "zammadPriority", label: "ZA Prio" }
]}
onChange={onUpdateConfig}
/>
+1 -1
View File
@@ -119,7 +119,7 @@ const projectSortOptions: Array<{ value: ProjectSortBy; label: string }> = [
];
function projectEntryId() {
if (typeof crypto !== "undefined" && "randomUUID" in crypto) {
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
return crypto.randomUUID();
}
+1 -1
View File
@@ -98,7 +98,7 @@ function emptyTicketSessionForm(): TicketSessionFormState {
}
function projectEntryId() {
if (typeof crypto !== "undefined" && "randomUUID" in crypto) {
if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
return crypto.randomUUID();
}
+2 -2
View File
@@ -13,7 +13,7 @@ import { OrganizationSelect } from "@/components/OrganizationSelect";
import { createSession, getRecurringBillings, lookupTicket } from "../api";
import { formatTimer } from "../format";
import { isRecurringBillingTicketNumber, ticketHasRecurringBilling } from "../recurring-billings";
import { activeElapsedMs, pauseEntry, resumeEntry, ticketPattern, type TimerEntry } from "../timers";
import { activeElapsedMs, createClientId, pauseEntry, resumeEntry, ticketPattern, type TimerEntry } from "../timers";
import type { RecurringBilling, TicketMeta, WorkType } from "../types";
type ManualSessionFormState = {
@@ -234,7 +234,7 @@ export function TimerPage({ timers, setTimers, selectedTimerId, setSelectedTimer
const now = Date.now();
const newTimer: TimerEntry = {
id: crypto.randomUUID(),
id: createClientId("timer"),
ticketNumber: normalizedTicketNumber,
organizationName: ticketResult.ticket?.organization_name ?? ticketResult.ticket?.customer_name ?? null,
workType: ticketResult.ticket?.work_type ?? null,
+36 -3
View File
@@ -34,7 +34,8 @@ const defaultFields: ZammadSyncExistingFields = {
type: true,
projectName: true,
budget: true,
overrideBudget: false
overrideBudget: false,
pendingTodo: false
};
const fieldOptions: Array<{ key: Exclude<keyof ZammadSyncExistingFields, "overrideBudget">; label: string; description: string }> = [
@@ -42,7 +43,8 @@ const fieldOptions: Array<{ key: Exclude<keyof ZammadSyncExistingFields, "overri
{ key: "organization", label: "Organisation", description: "Lokale Organisation anhand der Zammad-ID setzen." },
{ key: "type", label: "Typ", description: "Support/Consulting übernehmen, Projekte anlegen oder entfernen." },
{ key: "projectName", label: "Projektbezeichnung", description: "Teamspace-Projekt bei Consulting überschreiben." },
{ key: "budget", label: "Budget", description: "Teamspace-Stundenkontingent überschreiben." }
{ key: "budget", label: "Budget", description: "Teamspace-Stundenkontingent überschreiben." },
{ key: "pendingTodo", label: "Termin-ToDo", description: "Aus Wartend/Abschluss mit Datum ein ToDo erzeugen." }
];
type ZammadSyncPageState = {
@@ -264,6 +266,10 @@ function changeAllowedByFields(item: ZammadSyncItem, change: ZammadSyncChange, f
return fields.budget && consultingProjectCanBeTouched;
}
if (change.field === "ToDo") {
return fields.pendingTodo;
}
if (change.field === "TS/TT-Prüfung") {
return consultingProjectCanBeTouched;
}
@@ -294,7 +300,28 @@ function formatTeamspaceProjectList(value: unknown) {
}
function splitTeamspaceProjects(value: unknown) {
return typeof value === "string" ? value.split("+").map((entry) => entry.trim()).filter(Boolean) : [];
return typeof value === "string" ? value.match(/[^\s+]+/g) ?? [] : [];
}
function zammadPendingTodoPreview(zammad: Record<string, unknown>) {
const stateId = numericValue(cachedValue(zammad, "stateId"));
const pendingTime = cachedValue(zammad, "pendingTime");
if ((stateId !== 3 && stateId !== 7) || typeof pendingTime !== "string") {
return null;
}
const date = new Date(pendingTime);
if (Number.isNaN(date.getTime())) {
return null;
}
const kind = stateId === 7 ? "Abschluss" : "Erinnerung";
const ticketNumber = cachedValue(zammad, "ticketNumber");
const ticketLabel = typeof ticketNumber === "string" ? ticketNumber.replace(/^Ticket#?/i, "").replace(/^#/, "") : "";
return `${kind} ${ticketLabel ? `Ticket#${ticketLabel}` : "Ticket"} (${date.toISOString().slice(0, 10)})`;
}
function comparablePreviewValue(value: unknown) {
@@ -370,6 +397,11 @@ function changesFromExistingPreviewCache(item: ZammadSyncItem, fields: ZammadSyn
addCachedChange(changes, "Zammad-Priorität", cachedValue(local, "zammadPriorityId"), cachedValue(zammad, "priorityId"));
addCachedChange(changes, "Zammad-Status", cachedValue(local, "zammadStateId"), cachedValue(zammad, "stateId"));
const pendingTodo = zammadPendingTodoPreview(zammad);
if (fields.pendingTodo && pendingTodo) {
changes.push({ field: "ToDo", from: null, to: pendingTodo });
}
if (zammadWorkType === "support" && zammadStateId === 4) {
return changes;
}
@@ -532,6 +564,7 @@ function zammadDetails(item: ZammadSyncItem) {
`Typ ${formatWorkType(zammad.workType)}`,
`Status ${formatZammadState(zammad.stateId)}`,
`Priorität ${formatZammadPriority(zammad.priorityId)}`,
`Warten ${formatValue(zammad.pendingTime)}`,
`Owner ${formatValue(zammad.ownerId)}`,
`Org ${formatValue(zammad.organizationId)}`,
`Titel ${formatValue(zammad.title)}`,