Add annotations

This commit is contained in:
Ian Keane 2025-11-25 20:25:29 -05:00
parent 89d1c02690
commit 599cc22463
2 changed files with 173 additions and 0 deletions

View file

@ -24,6 +24,7 @@ pub fn render(frame: &mut Frame, app: &App) {
Screen::ReassignProject => render_reassign_project(frame, app),
Screen::LogView => render_log_view(frame, app),
Screen::LogViewHelp => render_log_view_help(frame, app),
Screen::AddAnnotation => render_add_annotation(frame, app),
}
}
@ -957,6 +958,7 @@ fn render_log_view_help(frame: &mut Frame, app: &App) {
"",
"Actions:",
"- e: Edit the selected entry (Entry level only)",
"- a: Add annotation tag to the selected entry (Entry level only)",
"- x: Delete the selected entry (Entry level only)",
"- b: Backfill - set entry start time to previous entry's end time",
" (Entry level, By Date view only)",
@ -1005,3 +1007,51 @@ fn render_log_view_help(frame: &mut Frame, app: &App) {
frame.render_widget(command_bar, bar_area);
}
fn render_add_annotation(frame: &mut Frame, app: &App) {
let area = centered_rect(60, 5, frame.size());
frame.render_widget(Clear, area);
let chunks = Layout::default()
.direction(Direction::Vertical)
.constraints([Constraint::Length(3), Constraint::Length(2)])
.split(area);
// Get current entry to show in title
let current_entry = if app.log_view_selected < app.log_view_frame_indices.len() {
let frame_idx = app.log_view_frame_indices[app.log_view_selected];
app.log_view_frames.get(frame_idx).map(|frame| {
if frame.tags.is_empty() {
frame.project.clone()
} else {
format!("{} [{}]", frame.tags.join(", "), frame.project)
}
})
} else {
None
};
let title = if let Some(entry) = current_entry {
format!("Add Annotation to: {}", entry)
} else {
"Add Annotation".to_string()
};
// Annotation input
let annotation_block = Block::default()
.title(title)
.borders(Borders::ALL)
.style(Style::default().fg(ACTIVE_COLOR));
let annotation_text = Paragraph::new(app.annotation_buffer.as_str())
.block(annotation_block);
frame.render_widget(annotation_text, chunks[0]);
// Help text
let help_text = Paragraph::new("Enter annotation text, press Enter to save, Esc to cancel")
.style(Style::default().fg(Color::DarkGray))
.alignment(Alignment::Center);
frame.render_widget(help_text, chunks[1]);
}