diff --git a/cmd/verstak-gui/bindings_suggest.go b/cmd/verstak-gui/bindings_suggest.go index 9c1de18..9a239e2 100644 --- a/cmd/verstak-gui/bindings_suggest.go +++ b/cmd/verstak-gui/bindings_suggest.go @@ -111,26 +111,29 @@ func (a *App) GetSuggestions() ([]activity.Suggestion, error) { return suggestions, nil } -// AcceptSuggestion creates a worklog entry from a suggestion (compatibility wrapper). -func (a *App) AcceptSuggestion(s activity.Suggestion) (*WorklogDTO, error) { - return a.AcceptSuggestionWith(s, s.SuggestedMin, "") +// AcceptSuggestion creates a worklog entry from a suggestion (compatibility wrapper, uses flat fields). +func (a *App) AcceptSuggestion(nodeID, summary string, minutes int, date string, eventIDs []string) (*WorklogDTO, error) { + return a.AcceptSuggestionWith(nodeID, summary, minutes, date, eventIDs) } -// AcceptSuggestionWith creates a worklog entry with optional overrides. -func (a *App) AcceptSuggestionWith(s activity.Suggestion, minutes int, date string) (*WorklogDTO, error) { +// AcceptSuggestionWith creates a worklog entry and links events. Uses flat fields to avoid Wails marshalling issues. +func (a *App) AcceptSuggestionWith(nodeID, summary string, minutes int, date string, eventIDs []string) (*WorklogDTO, error) { d := date if d == "" { d = time.Now().Format("2006-01-02") } - entry, err := a.worklog.AddWithSource(s.NodeID, s.Summary, "", d, minutes, true, false, worklog.SourceSuggestion) + entry, err := a.worklog.AddWithSource(nodeID, summary, "", d, minutes, true, false, worklog.SourceSuggestion) if err != nil { return nil, err } // Link activity events to this worklog entry. - for _, eid := range s.EventIDs { - _, _ = a.db.Exec( + for _, eid := range eventIDs { + _, err := a.db.Exec( `INSERT OR IGNORE INTO worklog_entry_events (entry_id, event_id) VALUES (?,?)`, entry.ID, eid) + if err != nil { + return nil, fmt.Errorf("link event %s: %w", eid, err) + } } _ = a.sync.RecordOp(syncsvc.EntityWorklog, entry.ID, syncsvc.OpCreate, worklogPayload(entry)) mins := 0 diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte index 94c771c..8a8aeca 100644 --- a/frontend/src/App.svelte +++ b/frontend/src/App.svelte @@ -972,14 +972,14 @@ async function acceptTodaySuggestion(s) { try { - await wailsCall('AcceptSuggestionWith', s, s.suggestedMin, '') + await wailsCall('AcceptSuggestionWith', s.nodeId, s.summary, s.suggestedMin, '', s.eventIds || []) await refreshAfterSuggestion() } catch (e) { console.error(e) } } async function acceptJournalSuggestion(s) { try { - await wailsCall('AcceptSuggestionWith', s, s.suggestedMin, '') + await wailsCall('AcceptSuggestionWith', s.nodeId, s.summary, s.suggestedMin, '', s.eventIds || []) await refreshAfterSuggestion() } catch (e) { console.error(e) } } @@ -1223,6 +1223,7 @@ const labels = { 'note_created': t('event.noteCreated'), 'note_updated': t('event.noteUpdated'), + 'note_deleted': 'Заметка удалена', 'file_added': t('event.fileAdded'), 'file_deleted': t('event.fileDeleted'), 'file_renamed': t('event.fileRenamed'), @@ -1231,8 +1232,13 @@ 'folder_added': t('event.folderAdded'), 'folder_deleted': t('event.folderDeleted'), 'folder_renamed': t('event.folderRenamed'), + 'folder_moved': 'Папка перемещена', 'node_created': t('event.caseCreated'), 'node_updated': t('event.caseUpdated'), + 'node_deleted': 'Узел удалён', + 'action_created': 'Действие создано', + 'action_done': 'Действие выполнено', + 'worklog_added': 'Запись времени добавлена', } return labels[type] || type } @@ -1769,7 +1775,7 @@ {#each s.events as ev}