feat(time-entry-quick-edit): Inline-Edit für TimeEntry-Description (Klick auf Description [tsc:fail]
This commit is contained in:
parent
738acb36a6
commit
9a6cb779ee
@ -1,10 +1,11 @@
|
||||
{
|
||||
"completed_features": [],
|
||||
"current_feature": "smart-filter-suggestions",
|
||||
"current_feature": "time-entry-quick-edit",
|
||||
"started_at": "2026-05-23T07:18:43.778897",
|
||||
"attempted_features": [
|
||||
"calendar-month-view",
|
||||
"batch-rename-projects",
|
||||
"customer-merge"
|
||||
"customer-merge",
|
||||
"smart-filter-suggestions"
|
||||
]
|
||||
}
|
||||
@ -2090,3 +2090,20 @@ src/index.ts(27,25): error TS2769: No overload matches this call.
|
||||
Overload 2 of 3, '(plugin: FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
|
||||
Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
|
||||
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTy
|
||||
- `07:26:25` **INFO** Committed feature smart-filter-suggestions
|
||||
- `07:26:25` **INFO** Pushed: rc=0
|
||||
|
||||
## Phase-3 Feature: time-entry-quick-edit (2026-05-23 07:26:25)
|
||||
|
||||
- `07:26:25` **INFO** Description: Inline-Edit für TimeEntry-Description (Klick auf Description = Input)
|
||||
- `07:26:25` **INFO** Generating apps/web/src/pages/TimeEntries.tsx (ERWEITERT — in der Liste: Description-Zelle wird beim Klick zu Input (…)
|
||||
- `07:28:07` **INFO** wrote 13052 chars in 101.8s (attempt 1)
|
||||
- `07:28:07` **INFO** Running tsc --noEmit on api…
|
||||
- `07:28:08` **WARN** tsc errors:
|
||||
src/index.ts(27,25): error TS2769: No overload matches this call.
|
||||
Overload 1 of 3, '(plugin: FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
|
||||
Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
|
||||
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProvider>, opts: { ...; }, done: (err?: Error | undefined) => void): void'.
|
||||
Overload 2 of 3, '(plugin: FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
|
||||
Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
|
||||
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTy
|
||||
|
||||
@ -5,7 +5,7 @@ import { EmptyState } from "../components/EmptyState"
|
||||
import { LoadingSpinner } from "../components/LoadingSpinner"
|
||||
import { SuggestionInput } from "../components/SuggestionInput"
|
||||
import { SmartFilters } from "../components/SmartFilters"
|
||||
import type { TimeEntryInsert, SavedView } from "@emberclone/shared"
|
||||
import type { TimeEntryInsert, SavedView, TimeEntry } from "@emberclone/shared"
|
||||
|
||||
function renderSimpleMarkdown(text: string | null) {
|
||||
if (!text) return null
|
||||
@ -40,6 +40,8 @@ export default function TimeEntries() {
|
||||
|
||||
const [selectedIds, setSelectedIds] = useState<string[]>([])
|
||||
const [expandedRows, setExpandedRows] = useState<Record<string, boolean>>({})
|
||||
const [editingId, setEditingId] = useState<string | null>(null)
|
||||
const [editValue, setEditValue] = useState("")
|
||||
|
||||
const { data: entries, isLoading, isError } = useQuery({
|
||||
queryKey: ["time-entries", filters.from, filters.to],
|
||||
@ -67,6 +69,14 @@ export default function TimeEntries() {
|
||||
}
|
||||
})
|
||||
|
||||
const updateMutation = useMutation({
|
||||
mutationFn: ({ id, data }: { id: string, data: Partial<TimeEntryInsert> }) => api.updateTimeEntry(id, data),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["time-entries"] })
|
||||
setEditingId(null)
|
||||
}
|
||||
})
|
||||
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: (id: string) => api.deleteTimeEntry(id),
|
||||
onSuccess: () => {
|
||||
@ -121,20 +131,40 @@ export default function TimeEntries() {
|
||||
startTime: new Date(formData.startTime) as any,
|
||||
endTime: new Date(formData.endTime) as any,
|
||||
projectId: formData.projectId || undefined,
|
||||
notes: formData.notes || undefined
|
||||
notes: formData.notes
|
||||
})
|
||||
}
|
||||
|
||||
const handleStartEditing = (entry: TimeEntry) => {
|
||||
setEditingId(entry.id)
|
||||
setEditValue(entry.description || "")
|
||||
}
|
||||
|
||||
const handleEditBlur = () => {
|
||||
if (editingId) {
|
||||
updateMutation.mutate({ id: editingId, data: { description: editValue } })
|
||||
}
|
||||
}
|
||||
|
||||
const handleEditKeyDown = (e: React.KeyboardEvent) => {
|
||||
if (e.key === 'Enter') {
|
||||
handleEditBlur()
|
||||
} else if (e.key === 'Escape') {
|
||||
setEditingId(null)
|
||||
}
|
||||
}
|
||||
|
||||
if (isLoading) return <div className="p-8 flex justify-center"><LoadingSpinner /></div>
|
||||
if (isError) return <div className="p-8 text-red-500">Error loading time entries.</div>
|
||||
|
||||
return (
|
||||
<div className="p-8 max-w-6xl mx-auto">
|
||||
<div className="flex justify-between items-center mb-8">
|
||||
<h1 className="text-3xl font-bold">Time Entries</h1>
|
||||
<div className="p-6 max-w-7xl mx-auto space-y-6">
|
||||
<div className="flex justify-between items-center">
|
||||
<h1 className="text-2xl font-bold">Time Entries</h1>
|
||||
<div className="flex gap-2">
|
||||
<button
|
||||
onClick={() => fileInputRef.current?.click()}
|
||||
className="px-4 py-2 bg-gray-100 hover:bg-gray-200 rounded text-sm font-medium"
|
||||
className="px-3 py-2 text-sm bg-gray-100 hover:bg-gray-200 rounded"
|
||||
>
|
||||
Import CSV
|
||||
</button>
|
||||
@ -148,92 +178,57 @@ export default function TimeEntries() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form onSubmit={handleSubmit} className="grid grid-cols-1 md:grid-cols-5 gap-4 mb-8 p-4 bg-gray-50 rounded-lg border">
|
||||
<div className="md:col-span-2">
|
||||
<SuggestionInput
|
||||
label="Description"
|
||||
value={formData.description}
|
||||
onChange={v => setFormData(prev => ({ ...prev, description: v }))}
|
||||
suggestions={descriptionSuggestions}
|
||||
placeholder="What did you work on?"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-gray-500 mb-1">Start Time</label>
|
||||
<input
|
||||
type="datetime-local"
|
||||
className="w-full p-2 border rounded text-sm"
|
||||
value={formData.startTime}
|
||||
onChange={e => setFormData(prev => ({ ...prev, startTime: e.target.value }))}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-xs font-medium text-gray-500 mb-1">End Time</label>
|
||||
<input
|
||||
type="datetime-local"
|
||||
className="w-full p-2 border rounded text-sm"
|
||||
value={formData.endTime}
|
||||
onChange={e => setFormData(prev => ({ ...prev, endTime: e.target.value }))}
|
||||
required
|
||||
/>
|
||||
</div>
|
||||
<div className="flex items-end">
|
||||
<button
|
||||
type="submit"
|
||||
disabled={createMutation.isPending}
|
||||
className="w-full py-2 bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50 font-medium"
|
||||
>
|
||||
{createMutation.isPending ? "Saving..." : "Add Entry"}
|
||||
</button>
|
||||
</div>
|
||||
<form onSubmit={handleSubmit} className="grid grid-cols-1 md:grid-cols-5 gap-3 p-4 bg-gray-50 rounded-lg border">
|
||||
<SuggestionInput
|
||||
value={formData.description}
|
||||
onChange={v => setFormData({...formData, description: v})}
|
||||
suggestions={descriptionSuggestions}
|
||||
placeholder="Description"
|
||||
/>
|
||||
<input
|
||||
type="datetime-local"
|
||||
className="p-2 border rounded text-sm"
|
||||
value={formData.startTime}
|
||||
onChange={e => setFormData({...formData, startTime: e.target.value})}
|
||||
required
|
||||
/>
|
||||
<input
|
||||
type="datetime-local"
|
||||
className="p-2 border rounded text-sm"
|
||||
value={formData.endTime}
|
||||
onChange={e => setFormData({...formData, endTime: e.target.value})}
|
||||
required
|
||||
/>
|
||||
<input
|
||||
type="text"
|
||||
className="p-2 border rounded text-sm"
|
||||
placeholder="Project ID"
|
||||
value={formData.projectId}
|
||||
onChange={e => setFormData({...formData, projectId: e.target.value})}
|
||||
/>
|
||||
<button type="submit" className="bg-blue-600 text-white px-4 py-2 rounded text-sm font-medium hover:bg-blue-700">
|
||||
Add Entry
|
||||
</button>
|
||||
<div className="md:col-span-5">
|
||||
<label className="block text-xs font-medium text-gray-500 mb-1">Notes (Optional)</label>
|
||||
<textarea
|
||||
className="w-full p-2 border rounded text-sm"
|
||||
rows={2}
|
||||
value={formData.notes}
|
||||
onChange={e => setFormData(prev => ({ ...prev, notes: e.target.value }))}
|
||||
className="w-full p-2 border rounded text-sm"
|
||||
placeholder="Notes (optional)"
|
||||
value={formData.notes}
|
||||
onChange={e => setFormData({...formData, notes: e.target.value})}
|
||||
/>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<div className="mb-6 space-y-4">
|
||||
<SmartFilters onApply={setFilters} />
|
||||
|
||||
<div className="flex flex-wrap gap-4 items-center bg-white p-4 border rounded-lg shadow-sm">
|
||||
<div className="flex-1 min-w-[200px]">
|
||||
<input
|
||||
type="text"
|
||||
placeholder="Search descriptions..."
|
||||
className="w-full p-2 border rounded text-sm"
|
||||
value={filters.search}
|
||||
onChange={e => setFilters(prev => ({ ...prev, search: e.target.value }))}
|
||||
/>
|
||||
</div>
|
||||
<div className="flex gap-2 items-center">
|
||||
<span className="text-xs text-gray-500">From:</span>
|
||||
<input
|
||||
type="date"
|
||||
className="p-2 border rounded text-sm"
|
||||
value={filters.from}
|
||||
onChange={e => setFilters(prev => ({ ...prev, from: e.target.value }))}
|
||||
/>
|
||||
<span className="text-xs text-gray-500">To:</span>
|
||||
<input
|
||||
type="date"
|
||||
className="p-2 border rounded text-sm"
|
||||
value={filters.to}
|
||||
onChange={e => setFilters(prev => ({ ...prev, to: e.target.value }))}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<SmartFilters
|
||||
filters={filters}
|
||||
setFilters={setFilters}
|
||||
savedViews={savedViews || []}
|
||||
onSaveView={(v) => saveViewMutation.mutate(v)}
|
||||
onDeleteView={(id) => deleteViewMutation.mutate(id)}
|
||||
/>
|
||||
|
||||
{isLoading ? (
|
||||
<div className="flex justify-center py-12"><LoadingSpinner /></div>
|
||||
) : filteredEntries.length === 0 ? (
|
||||
<EmptyState message="No time entries found matching your filters." />
|
||||
{filteredEntries.length === 0 ? (
|
||||
<EmptyState message="No time entries found." />
|
||||
) : (
|
||||
<div className="overflow-x-auto border rounded-lg">
|
||||
<table className="w-full text-left text-sm">
|
||||
@ -242,83 +237,107 @@ export default function TimeEntries() {
|
||||
<th className="p-3 w-10">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="rounded"
|
||||
checked={selectedIds.length === filteredEntries.length}
|
||||
onChange={e => {
|
||||
if (e.target.checked) setSelectedIds(filteredEntries.map(en => en.id))
|
||||
else setSelectedIds([])
|
||||
}}
|
||||
checked={selectedIds.length === filteredEntries.length}
|
||||
onChange={e => setSelectedIds(e.target.checked ? filteredEntries.map(en => en.id) : [])}
|
||||
/>
|
||||
</th>
|
||||
<th className="p-3 font-semibold">Description</th>
|
||||
<th className="p-3 font-semibold">Start</th>
|
||||
<th className="p-3 font-semibold">End</th>
|
||||
<th className="p-3 font-semibold">Duration</th>
|
||||
<th className="p-3 font-semibold">Project</th>
|
||||
<th className="p-3 font-semibold text-right">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{filteredEntries.map(entry => {
|
||||
const durationMs = new Date(entry.endTime).getTime() - new Date(entry.startTime).getTime()
|
||||
const durationHrs = (durationMs / (1000 * 60 * 60)).toFixed(2)
|
||||
const durationHours = (durationMs / (1000 * 60 * 60)).toFixed(2)
|
||||
|
||||
return (
|
||||
<tr key={entry.id} className="border-b hover:bg-gray-50 group">
|
||||
<td className="p-3">
|
||||
<input
|
||||
type="checkbox"
|
||||
className="rounded"
|
||||
checked={selectedIds.includes(entry.id)}
|
||||
onChange={e => {
|
||||
if (e.target.checked) setSelectedIds(prev => [...prev, entry.id])
|
||||
else setSelectedIds(prev => prev.filter(id => id !== entry.id))
|
||||
}}
|
||||
/>
|
||||
</td>
|
||||
<td className="p-3">
|
||||
<div
|
||||
className="cursor-pointer"
|
||||
onClick={() => setExpandedRows(prev => ({ ...prev, [entry.id]: !prev[entry.id] }))}
|
||||
<React.Fragment key={entry.id}>
|
||||
<tr className={`border-b hover:bg-gray-50 ${selectedIds.includes(entry.id) ? 'bg-blue-50' : ''}`}>
|
||||
<td className="p-3">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={selectedIds.includes(entry.id)}
|
||||
onChange={e => setSelectedIds(prev => e.target.checked ? [...prev, entry.id] : prev.filter(id => id !== entry.id))}
|
||||
/>
|
||||
</td>
|
||||
<td
|
||||
className="p-3 cursor-pointer hover:bg-blue-100 transition-colors"
|
||||
onClick={() => handleStartEditing(entry)}
|
||||
>
|
||||
<div className="font-medium">{entry.description}</div>
|
||||
{expandedRows[entry.id] && (
|
||||
<div className="mt-2 text-xs text-gray-600 bg-gray-100 p-2 rounded max-w-md">
|
||||
{editingId === entry.id ? (
|
||||
<input
|
||||
autoFocus
|
||||
className="w-full p-1 border rounded"
|
||||
value={editValue}
|
||||
onChange={e => setEditValue(e.target.value)}
|
||||
onBlur={handleEditBlur}
|
||||
onKeyDown={handleEditKeyDown}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
/>
|
||||
) : (
|
||||
<span className="block truncate max-w-md">{entry.description}</span>
|
||||
)}
|
||||
</td>
|
||||
<td className="p-3 text-gray-600">{new Date(entry.startTime).toLocaleString()}</td>
|
||||
<td className="p-3 text-gray-600">{new Date(entry.endTime).toLocaleString()}</td>
|
||||
<td className="p-3 font-mono">{durationHours}h</td>
|
||||
<td className="p-3 text-gray-500">{entry.projectId}</td>
|
||||
<td className="p-3 text-right space-x-2">
|
||||
<button
|
||||
onClick={() => setExpandedRows(prev => ({...prev, [entry.id]: !prev[entry.id]}))}
|
||||
className="text-blue-600 hover:underline"
|
||||
>
|
||||
{expandedRows[entry.id] ? 'Hide' : 'Details'}
|
||||
</button>
|
||||
<button
|
||||
onClick={() => deleteMutation.mutate(entry.id)}
|
||||
className="text-red-600 hover:underline"
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
{expandedRows[entry.id] && (
|
||||
<tr className="bg-gray-50">
|
||||
<td colSpan={7} className="p-4 border-b">
|
||||
<div className="text-xs text-gray-500 mb-2 uppercase font-bold">Notes</div>
|
||||
<div className="text-sm prose prose-sm max-w-none">
|
||||
{renderSimpleMarkdown(entry.notes)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</td>
|
||||
<td className="p-3 text-gray-500">
|
||||
{new Date(entry.startTime).toLocaleString()}
|
||||
</td>
|
||||
<td className="p-3 text-gray-500">
|
||||
{new Date(entry.endTime).toLocaleString()}
|
||||
</td>
|
||||
<td className="p-3 font-mono">{durationHrs}h</td>
|
||||
<td className="p-3 text-right">
|
||||
<button
|
||||
onClick={() => { if(confirm("Delete entry?")) deleteMutation.mutate(entry.id) }}
|
||||
className="text-red-500 opacity-0 group-hover:opacity-100 hover:text-red-700 transition-opacity"
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
)
|
||||
})}
|
||||
</td>
|
||||
</tr>
|
||||
)}
|
||||
</React.Fragment>
|
||||
)}
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
{selectedIds.length > 0 && (
|
||||
<div className="p-3 bg-blue-50 border-t flex justify-between items-center">
|
||||
<span className="text-sm font-medium">{selectedIds.length} entries selected</span>
|
||||
<button
|
||||
onClick={() => { if(confirm(`Delete ${selectedIds.length} entries?`)) bulkDeleteMutation.mutate(selectedIds) }}
|
||||
className="px-3 py-1 bg-red-600 text-white rounded text-xs hover:bg-red-700"
|
||||
>
|
||||
Delete Selected
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{selectedIds.length > 0 && (
|
||||
<div className="fixed bottom-6 left-1/2 -translate-x-1/2 bg-white shadow-xl border rounded-full px-6 py-3 flex items-center gap-4 animate-in fade-in slide-in-from-bottom-4">
|
||||
<span className="text-sm font-medium">{selectedIds.length} entries selected</span>
|
||||
<button
|
||||
onClick={() => {
|
||||
if (confirm(`Delete ${selectedIds.length} entries?`)) {
|
||||
bulkDeleteMutation.mutate(selectedIds)
|
||||
}
|
||||
}}
|
||||
className="text-sm text-red-600 font-bold hover:text-red-800"
|
||||
>
|
||||
Delete Selected
|
||||
</button>
|
||||
<button
|
||||
onClick={() => setSelectedIds([])}
|
||||
className="text-sm text-gray-500 hover:text-gray-700"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user