View filtering, task name refactor
Weird issues where projects were mapping to tags. Also group everything by project in view with 'g'
This commit is contained in:
parent
4f57c01693
commit
353d422730
3 changed files with 123 additions and 44 deletions
46
src/ui.rs
46
src/ui.rs
|
|
@ -7,7 +7,7 @@ use ratatui::{
|
|||
};
|
||||
|
||||
use crate::{
|
||||
app::{App, LogViewPeriod, NewEntryMode, Screen},
|
||||
app::{App, LogViewGrouping, LogViewPeriod, NewEntryMode, Screen},
|
||||
state::{AppState, TimeItem},
|
||||
};
|
||||
|
||||
|
|
@ -121,9 +121,9 @@ fn render_new_entry(frame: &mut Frame, app: &App) {
|
|||
.constraints([Constraint::Length(3), Constraint::Length(3)])
|
||||
.split(area);
|
||||
|
||||
// Task name input
|
||||
let task_block = Block::default()
|
||||
.title("Task Name")
|
||||
// Tag input (first)
|
||||
let tag_block = Block::default()
|
||||
.title("Tag")
|
||||
.borders(Borders::ALL)
|
||||
.style(
|
||||
Style::default().fg(if matches!(app.new_entry_mode, NewEntryMode::Task) {
|
||||
|
|
@ -133,13 +133,13 @@ fn render_new_entry(frame: &mut Frame, app: &App) {
|
|||
}),
|
||||
);
|
||||
|
||||
let task_text = Paragraph::new(app.new_entry_buffer.as_str()).block(task_block);
|
||||
let tag_text = Paragraph::new(app.new_entry_project.as_str()).block(tag_block);
|
||||
|
||||
frame.render_widget(task_text, chunks[0]);
|
||||
frame.render_widget(tag_text, chunks[0]);
|
||||
|
||||
// Project input
|
||||
// Project input (second)
|
||||
let project_block = Block::default()
|
||||
.title("Project (optional)")
|
||||
.title("Project")
|
||||
.borders(Borders::ALL)
|
||||
.style(
|
||||
Style::default().fg(if matches!(app.new_entry_mode, NewEntryMode::Project) {
|
||||
|
|
@ -149,17 +149,7 @@ fn render_new_entry(frame: &mut Frame, app: &App) {
|
|||
}),
|
||||
);
|
||||
|
||||
let project_text = if !app.config.projects.is_empty() {
|
||||
format!(
|
||||
"{} (available: {})",
|
||||
app.new_entry_project,
|
||||
app.config.projects.join(", ")
|
||||
)
|
||||
} else {
|
||||
app.new_entry_project.clone()
|
||||
};
|
||||
|
||||
let project_text = Paragraph::new(project_text).block(project_block);
|
||||
let project_text = Paragraph::new(app.new_entry_buffer.as_str()).block(project_block);
|
||||
|
||||
frame.render_widget(project_text, chunks[1]);
|
||||
|
||||
|
|
@ -167,8 +157,8 @@ fn render_new_entry(frame: &mut Frame, app: &App) {
|
|||
let bar_area = Rect::new(0, frame.size().height - 1, frame.size().width, 1);
|
||||
|
||||
let command_text = match app.new_entry_mode {
|
||||
NewEntryMode::Task => "Enter task name, press Enter to continue",
|
||||
NewEntryMode::Project => "Enter project name (optional), press Enter to save",
|
||||
NewEntryMode::Task => "Enter tag, press Enter to continue",
|
||||
NewEntryMode::Project => "Enter project, press Enter to save",
|
||||
};
|
||||
|
||||
let command_bar = Paragraph::new(command_text)
|
||||
|
|
@ -316,7 +306,7 @@ fn render_help(frame: &mut Frame, _app: &App) {
|
|||
"Enter - Start/stop timer",
|
||||
"d - Delete task",
|
||||
"p - Reassign project",
|
||||
"v - View Watson log (e to edit entries, x to delete, c to copy)",
|
||||
"v - View Watson log (g to group, e to edit, x to delete, c to copy)",
|
||||
"Ctrl+e - Edit tasks config",
|
||||
"c - Edit app config",
|
||||
"n - New task",
|
||||
|
|
@ -481,7 +471,7 @@ fn render_reassign_project(frame: &mut Frame, app: &App) {
|
|||
|
||||
// Project input
|
||||
let project_block = Block::default()
|
||||
.title(format!("Reassign Project for: {}", current_item_name))
|
||||
.title(format!("Reassign Tag for: {}", current_item_name))
|
||||
.borders(Borders::ALL)
|
||||
.style(Style::default().fg(ACTIVE_COLOR));
|
||||
|
||||
|
|
@ -500,7 +490,7 @@ fn render_reassign_project(frame: &mut Frame, app: &App) {
|
|||
frame.render_widget(project_paragraph, chunks[0]);
|
||||
|
||||
// Help text
|
||||
let help_text = Paragraph::new("Enter new project (leave empty to remove), press Enter to save, Esc to cancel")
|
||||
let help_text = Paragraph::new("Enter new tag (leave empty to remove), press Enter to save, Esc to cancel")
|
||||
.style(Style::default().fg(Color::DarkGray))
|
||||
.alignment(Alignment::Center);
|
||||
|
||||
|
|
@ -522,7 +512,12 @@ fn render_log_view(frame: &mut Frame, app: &App) {
|
|||
LogViewPeriod::Month => "Month",
|
||||
};
|
||||
|
||||
let title = format!("Watson Log - {} View", period_str);
|
||||
let grouping_str = match app.log_view_grouping {
|
||||
LogViewGrouping::ByDate => "by Date",
|
||||
LogViewGrouping::ByProject => "by Project",
|
||||
};
|
||||
|
||||
let title = format!("Watson Log - {} View ({})", period_str, grouping_str);
|
||||
|
||||
let block = Block::default()
|
||||
.title(title)
|
||||
|
|
@ -568,6 +563,7 @@ fn render_log_view(frame: &mut Frame, app: &App) {
|
|||
("d", "day"),
|
||||
("w", "week"),
|
||||
("m", "month"),
|
||||
("g", "group"),
|
||||
("j/k", "select"),
|
||||
("e", "edit"),
|
||||
("x", "delete"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue