feat: tags property column
This commit is contained in:
parent
ce7e015b02
commit
fd94de7149
10
src/task.rs
10
src/task.rs
|
@ -8,14 +8,14 @@ pub(crate) struct Task {
|
||||||
pub(crate) children: HashSet<EventId>,
|
pub(crate) children: HashSet<EventId>,
|
||||||
pub(crate) props: BTreeSet<Event>,
|
pub(crate) props: BTreeSet<Event>,
|
||||||
/// Cached sorted tags of the event
|
/// Cached sorted tags of the event
|
||||||
pub(crate) tags: BTreeSet<Tag>,
|
pub(crate) tags: Option<BTreeSet<Tag>>,
|
||||||
}
|
}
|
||||||
impl Task {
|
impl Task {
|
||||||
pub(crate) fn new(event: Event) -> Task {
|
pub(crate) fn new(event: Event) -> Task {
|
||||||
Task {
|
Task {
|
||||||
children: Default::default(),
|
children: Default::default(),
|
||||||
props: Default::default(),
|
props: Default::default(),
|
||||||
tags: event.tags.iter().cloned().collect(),
|
tags: if event.tags.is_empty() { None } else { Some(event.tags.iter().cloned().collect()) },
|
||||||
event,
|
event,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,6 +103,12 @@ impl Task {
|
||||||
"state" => self.state().map(|s| s.to_string()),
|
"state" => self.state().map(|s| s.to_string()),
|
||||||
"name" => Some(self.event.content.clone()),
|
"name" => Some(self.event.content.clone()),
|
||||||
"time" => Some(self.time_tracked().to_string()), // TODO: format properly
|
"time" => Some(self.time_tracked().to_string()), // TODO: format properly
|
||||||
|
"tags" => self.tags.as_ref().map(|tags| {
|
||||||
|
tags.iter()
|
||||||
|
.map(|t| format!("{}", t.content().unwrap()))
|
||||||
|
.collect::<Vec<String>>()
|
||||||
|
.join(" ")
|
||||||
|
}),
|
||||||
"props" => Some(format!(
|
"props" => Some(format!(
|
||||||
"{:?}",
|
"{:?}",
|
||||||
self.props
|
self.props
|
||||||
|
|
|
@ -172,8 +172,10 @@ impl Tasks {
|
||||||
tasks
|
tasks
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|t| {
|
.filter(|t| {
|
||||||
let mut iter = t.tags.iter();
|
t.tags.as_ref().map_or(false, |tags| {
|
||||||
self.tags.iter().all(|tag| iter.any(|t| t == tag))
|
let mut iter = tags.iter();
|
||||||
|
self.tags.iter().all(|tag| iter.any(|t| t == tag))
|
||||||
|
})
|
||||||
})
|
})
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue