fix: AcceptSuggestionWith uses flat fields to avoid Wails marshalling issues; human-readable event labels
- AcceptSuggestionWith now accepts nodeID, summary, minutes, date, eventIDs as separate args instead of the entire Suggestion struct (Wails v2 skips nested struct fields during JS→Go marshalling) - Error handling: event link failures now return an error instead of silent ignore - Event type labels in suggestion detail and journal row detail now use eventLabel() which maps snake_case types to human-readable i18n labels (e.g. note_updated → 'Заметка изменена') - Added missing event labels: note_deleted, node_deleted, folder_moved, action_created, action_done, worklog_added
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user