Update project display and assignment dialog
This commit is contained in:
parent
e661ad8ba1
commit
f9459edf09
2 changed files with 26 additions and 22 deletions
17
src/app.rs
17
src/app.rs
|
|
@ -1213,8 +1213,8 @@ impl App {
|
||||||
fn start_reassign_project(&mut self) {
|
fn start_reassign_project(&mut self) {
|
||||||
if let Some(item) = self.get_current_item() {
|
if let Some(item) = self.get_current_item() {
|
||||||
self.current_screen = Screen::ReassignProject;
|
self.current_screen = Screen::ReassignProject;
|
||||||
// Pre-fill with current project if it exists
|
// Pre-fill with current project (the name field)
|
||||||
self.reassign_project_buffer = item.tags.first().cloned().unwrap_or_default();
|
self.reassign_project_buffer = item.name.clone();
|
||||||
self.reassign_project_cursor = self.reassign_project_buffer.len();
|
self.reassign_project_cursor = self.reassign_project_buffer.len();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1280,24 +1280,21 @@ impl App {
|
||||||
let index = self.state.selected_indices[self.state.current_pane];
|
let index = self.state.selected_indices[self.state.current_pane];
|
||||||
|
|
||||||
let needs_restart = if let Some(item) = items.get_mut(index) {
|
let needs_restart = if let Some(item) = items.get_mut(index) {
|
||||||
// Update the tags
|
// Update the project name (item.name field)
|
||||||
if self.reassign_project_buffer.is_empty() {
|
let old_name = item.name.clone();
|
||||||
item.tags.clear();
|
item.name = self.reassign_project_buffer.clone();
|
||||||
} else {
|
|
||||||
item.tags = vec![self.reassign_project_buffer.clone()];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if this is the active timer
|
// Check if this is the active timer
|
||||||
self.state
|
self.state
|
||||||
.active_timer
|
.active_timer
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|(active, _)| active.name == item.name)
|
.map(|(active, _)| active.name == old_name)
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
};
|
};
|
||||||
|
|
||||||
// If this was the active timer, restart it with new tags
|
// If this was the active timer, restart it with new project name
|
||||||
if needs_restart {
|
if needs_restart {
|
||||||
let item = items[index].clone();
|
let item = items[index].clone();
|
||||||
self.state.stop_timer()?;
|
self.state.stop_timer()?;
|
||||||
|
|
|
||||||
31
src/ui.rs
31
src/ui.rs
|
|
@ -240,7 +240,7 @@ fn render_help(frame: &mut Frame, app: &App) {
|
||||||
"Main Commands:",
|
"Main Commands:",
|
||||||
"Enter - Start/stop timer",
|
"Enter - Start/stop timer",
|
||||||
"d - Delete task from list",
|
"d - Delete task from list",
|
||||||
"p - Reassign project/tag",
|
"p - Reassign project name",
|
||||||
"v - View Watson log",
|
"v - View Watson log",
|
||||||
"Ctrl+e - Edit tasks config file",
|
"Ctrl+e - Edit tasks config file",
|
||||||
"c - Edit app config file",
|
"c - Edit app config file",
|
||||||
|
|
@ -378,12 +378,13 @@ fn render_section(
|
||||||
Style::default()
|
Style::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut line = item.name.clone();
|
let line = if !item.tags.is_empty() {
|
||||||
if !item.tags.is_empty() {
|
// Display as: tag [project]
|
||||||
line.push_str(" [");
|
format!("{} [{}]", item.tags.join(", "), item.name)
|
||||||
line.push_str(&item.tags.join(", "));
|
} else {
|
||||||
line.push(']');
|
// No tags, just show project
|
||||||
}
|
item.name.clone()
|
||||||
|
};
|
||||||
|
|
||||||
ListItem::new(Line::from(vec![Span::styled(line, style)]))
|
ListItem::new(Line::from(vec![Span::styled(line, style)]))
|
||||||
})
|
})
|
||||||
|
|
@ -422,14 +423,20 @@ fn render_reassign_project(frame: &mut Frame, app: &App) {
|
||||||
_ => &app.state.permanent_items,
|
_ => &app.state.permanent_items,
|
||||||
};
|
};
|
||||||
|
|
||||||
let current_item_name = items
|
let current_item_display = items
|
||||||
.get(app.state.selected_indices[app.state.current_pane])
|
.get(app.state.selected_indices[app.state.current_pane])
|
||||||
.map(|item| item.name.as_str())
|
.map(|item| {
|
||||||
.unwrap_or("");
|
if !item.tags.is_empty() {
|
||||||
|
format!("{} [{}]", item.tags.join(", "), item.name)
|
||||||
|
} else {
|
||||||
|
item.name.clone()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.unwrap_or_default();
|
||||||
|
|
||||||
// Project input
|
// Project input
|
||||||
let project_block = Block::default()
|
let project_block = Block::default()
|
||||||
.title(format!("Reassign Tag for: {}", current_item_name))
|
.title(format!("Reassign Project for: {}", current_item_display))
|
||||||
.borders(Borders::ALL)
|
.borders(Borders::ALL)
|
||||||
.style(Style::default().fg(ACTIVE_COLOR));
|
.style(Style::default().fg(ACTIVE_COLOR));
|
||||||
|
|
||||||
|
|
@ -448,7 +455,7 @@ fn render_reassign_project(frame: &mut Frame, app: &App) {
|
||||||
frame.render_widget(project_paragraph, chunks[0]);
|
frame.render_widget(project_paragraph, chunks[0]);
|
||||||
|
|
||||||
// Help text
|
// Help text
|
||||||
let help_text = Paragraph::new("Enter new tag (leave empty to remove), press Enter to save, Esc to cancel")
|
let help_text = Paragraph::new("Enter new project name, press Enter to save, Esc to cancel")
|
||||||
.style(Style::default().fg(Color::DarkGray))
|
.style(Style::default().fg(Color::DarkGray))
|
||||||
.alignment(Alignment::Center);
|
.alignment(Alignment::Center);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue