Allow tasks to be canceled
This commit is contained in:
parent
e0cb1c8f23
commit
0e4ef7fef3
13 changed files with 107 additions and 14 deletions
|
|
@ -3,7 +3,7 @@ use std::collections::HashMap;
|
|||
use chrono::{Duration, NaiveDate};
|
||||
|
||||
use crate::files::commands::{
|
||||
self, BirthdaySpec, Command, Done, DoneDate, Note, Spec, Statement, Task,
|
||||
self, BirthdaySpec, Command, Done, DoneDate, DoneKind, Note, Spec, Statement, Task,
|
||||
};
|
||||
use crate::files::primitives::{Span, Spanned, Time};
|
||||
use crate::files::SourcedCommand;
|
||||
|
|
@ -296,10 +296,12 @@ impl<'a> CommandState<'a> {
|
|||
}
|
||||
|
||||
fn eval_done(&mut self, done: &Done) -> Result<()> {
|
||||
self.add_forced(self.entry_with_remind(
|
||||
EntryKind::TaskDone(done.done_at),
|
||||
done.date.map(|date| date.into()),
|
||||
)?);
|
||||
let kind = match done.kind {
|
||||
DoneKind::Done => EntryKind::TaskDone(done.done_at),
|
||||
DoneKind::Canceled => EntryKind::TaskCanceled(done.done_at),
|
||||
};
|
||||
let dates = done.date.map(|date| date.into());
|
||||
self.add_forced(self.entry_with_remind(kind, dates)?);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ use super::range::DateRange;
|
|||
pub enum EntryKind {
|
||||
Task,
|
||||
TaskDone(NaiveDate),
|
||||
TaskCanceled(NaiveDate),
|
||||
Note,
|
||||
Birthday(Option<i32>),
|
||||
}
|
||||
|
|
@ -120,7 +121,7 @@ impl Entries {
|
|||
}
|
||||
|
||||
// Tasks that were finished inside the range
|
||||
if let EntryKind::TaskDone(done) = entry.kind {
|
||||
if let EntryKind::TaskDone(done) | EntryKind::TaskCanceled(done) = entry.kind {
|
||||
if self.range.contains(done) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue