mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-24 23:46:41 +02:00
Add task_by_uuid and task_by_index
This commit is contained in:
parent
738bce9a21
commit
d00dd90043
3 changed files with 21 additions and 0 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -767,6 +767,7 @@ dependencies = [
|
||||||
"task-hookrs",
|
"task-hookrs",
|
||||||
"tui",
|
"tui",
|
||||||
"unicode-width",
|
"unicode-width",
|
||||||
|
"uuid",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|
|
@ -30,3 +30,4 @@ unicode-width = "0.1"
|
||||||
tui = { version = "0.10", optional = true, default-features = false }
|
tui = { version = "0.10", optional = true, default-features = false }
|
||||||
crossterm = { version = "0.17", optional = true, default-features = false }
|
crossterm = { version = "0.17", optional = true, default-features = false }
|
||||||
rustyline = "6.3.0"
|
rustyline = "6.3.0"
|
||||||
|
uuid = { version = "0.8.1", features = ["serde", "v4"] }
|
||||||
|
|
19
src/app.rs
19
src/app.rs
|
@ -10,6 +10,7 @@ use task_hookrs::import::import;
|
||||||
use task_hookrs::status::TaskStatus;
|
use task_hookrs::status::TaskStatus;
|
||||||
use task_hookrs::task::Task;
|
use task_hookrs::task::Task;
|
||||||
use task_hookrs::uda::UDAValue;
|
use task_hookrs::uda::UDAValue;
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
use chrono::{Local, NaiveDateTime, TimeZone};
|
use chrono::{Local, NaiveDateTime, TimeZone};
|
||||||
|
|
||||||
|
@ -741,6 +742,24 @@ impl TTApp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn task_by_index(&self, i: usize) -> Option<Task> {
|
||||||
|
let tasks = &self.tasks.lock().unwrap();
|
||||||
|
if i > tasks.len() {
|
||||||
|
None
|
||||||
|
} else {
|
||||||
|
Some(tasks[i].clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn task_by_uuid(&self, uuid: Uuid) -> Option<Task> {
|
||||||
|
let tasks = &self.tasks.lock().unwrap();
|
||||||
|
let m = tasks.iter().find(|t| *t.uuid() == uuid);
|
||||||
|
match m {
|
||||||
|
Some(v) => Some(v.clone()),
|
||||||
|
None => None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn draw_task_report(&mut self, f: &mut Frame<impl Backend>, rect: Rect) {
|
fn draw_task_report(&mut self, f: &mut Frame<impl Backend>, rect: Rect) {
|
||||||
let (tasks, headers, widths) = self.task_report();
|
let (tasks, headers, widths) = self.task_report();
|
||||||
if tasks.is_empty() {
|
if tasks.is_empty() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue