Add project re-assignment
This commit is contained in:
parent
7b0626cdf0
commit
cae499f3ee
3 changed files with 154 additions and 0 deletions
53
src/ui.rs
53
src/ui.rs
|
|
@ -20,6 +20,7 @@ pub fn render(frame: &mut Frame, app: &App) {
|
|||
Screen::Help => render_help(frame, app),
|
||||
Screen::ConfigHelp => render_config_help(frame, app),
|
||||
Screen::NewEntry => render_new_entry(frame, app),
|
||||
Screen::ReassignProject => render_reassign_project(frame, app),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -209,6 +210,7 @@ fn render_bottom_bar(frame: &mut Frame, area: Rect, app: &App) {
|
|||
let commands = vec![
|
||||
("c", "config"),
|
||||
("n", "new"),
|
||||
("p", "project"),
|
||||
("d", "delete"),
|
||||
("q", "quit"),
|
||||
];
|
||||
|
|
@ -311,6 +313,7 @@ fn render_help(frame: &mut Frame, _app: &App) {
|
|||
"h/l, arrows - Switch panes",
|
||||
"Enter - Start/stop timer",
|
||||
"d - Delete task",
|
||||
"p - Reassign project",
|
||||
"Ctrl+e - Edit tasks config",
|
||||
"c - Edit app config",
|
||||
"n - New task",
|
||||
|
|
@ -450,3 +453,53 @@ fn centered_rect(width: u16, height: u16, r: Rect) -> Rect {
|
|||
height: height.min(r.height),
|
||||
}
|
||||
}
|
||||
|
||||
fn render_reassign_project(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 item to show in title
|
||||
let items = match app.state.current_pane {
|
||||
0 => &app.state.permanent_items,
|
||||
1 => &app.state.recurring_items,
|
||||
2 => &app.state.recent_items,
|
||||
_ => &app.state.permanent_items,
|
||||
};
|
||||
|
||||
let current_item_name = items
|
||||
.get(app.state.selected_indices[app.state.current_pane])
|
||||
.map(|item| item.name.as_str())
|
||||
.unwrap_or("");
|
||||
|
||||
// Project input
|
||||
let project_block = Block::default()
|
||||
.title(format!("Reassign Project for: {}", current_item_name))
|
||||
.borders(Borders::ALL)
|
||||
.style(Style::default().fg(ACTIVE_COLOR));
|
||||
|
||||
let project_text = if !app.config.projects.is_empty() {
|
||||
format!(
|
||||
"{} (available: {})",
|
||||
app.reassign_project_buffer,
|
||||
app.config.projects.join(", ")
|
||||
)
|
||||
} else {
|
||||
app.reassign_project_buffer.clone()
|
||||
};
|
||||
|
||||
let project_paragraph = Paragraph::new(project_text).block(project_block);
|
||||
|
||||
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")
|
||||
.style(Style::default().fg(Color::DarkGray))
|
||||
.alignment(Alignment::Center);
|
||||
|
||||
frame.render_widget(help_text, chunks[1]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue