mirror of
https://github.com/kdheepak/taskwarrior-tui.git
synced 2025-08-25 08:47:18 +02:00
Merge pull request #90 from kdheepak/kd/add-depends-column
Add depends column
This commit is contained in:
commit
69682227c9
1 changed files with 17 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
|||
use chrono::{Datelike, Local, NaiveDate, NaiveDateTime, TimeZone};
|
||||
use itertools::join;
|
||||
use std::error::Error;
|
||||
use std::process::Command;
|
||||
use task_hookrs::task::Task;
|
||||
|
@ -127,7 +128,7 @@ impl TaskReportTable {
|
|||
}
|
||||
let mut item = vec![];
|
||||
for name in &self.columns {
|
||||
let s = self.get_string_attribute(name, &task);
|
||||
let s = self.get_string_attribute(name, &task, tasks);
|
||||
item.push(s);
|
||||
}
|
||||
self.tasks.push(item)
|
||||
|
@ -175,7 +176,7 @@ impl TaskReportTable {
|
|||
(tasks, headers)
|
||||
}
|
||||
|
||||
pub fn get_string_attribute(&self, attribute: &str, task: &Task) -> String {
|
||||
pub fn get_string_attribute(&self, attribute: &str, task: &Task, tasks: &[Task]) -> String {
|
||||
match attribute {
|
||||
"id" => task.id().unwrap_or_default().to_string(),
|
||||
"due.relative" => match task.due() {
|
||||
|
@ -210,6 +211,20 @@ impl TaskReportTable {
|
|||
}
|
||||
None => "".to_string(),
|
||||
},
|
||||
"depends" => match task.depends() {
|
||||
Some(v) => {
|
||||
if v.is_empty() {
|
||||
"".to_string()
|
||||
} else {
|
||||
let mut dt = vec![];
|
||||
for u in v {
|
||||
dt.push(tasks.iter().find(|t| t.uuid() == u).unwrap().id().unwrap());
|
||||
}
|
||||
join(dt.iter().map(|i| i.to_string()), " ")
|
||||
}
|
||||
}
|
||||
None => "".to_string(),
|
||||
},
|
||||
"tags.count" => match task.tags() {
|
||||
Some(v) => {
|
||||
let t = v.iter().filter(|t| !self.virtual_tags.contains(t)).cloned().count();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue