feat: text notes as descriptions

This commit is contained in:
xeruf 2024-07-25 10:50:53 +03:00
parent daad3faddb
commit 0c90086833
3 changed files with 26 additions and 6 deletions

View File

@ -32,9 +32,11 @@ TASK add syntax: `NAME: TAG1 TAG2`
Dots can be repeated to move to parent tasks Dots can be repeated to move to parent tasks
- `:[IND][COL]` - add / remove property column COL to IND or end - `:[IND][COL]` - add / remove property column COL to IND or end
- `>` - Complete active task and move to parent - `>[TEXT]` - Complete active task and move to parent, with optional state description
- `<` - Close active task and move to parent - `<[TEXT]` - Close active task and move to parent, with optional state description
- TBI: `-TEXT` - add text note (comment / description) - `-TEXT` - add text note (comment / description)
State descriptions can be used for example for Kanban columns.
### Columns ### Columns

View File

@ -194,6 +194,10 @@ async fn main() {
} }
}, },
Some('-') => {
tasks.add_note(&input[1..])
}
Some('>') | Some('<') => { Some('>') | Some('<') => {
tasks.update_state(&input[1..], |_| { tasks.update_state(&input[1..], |_| {
Some(if op.unwrap() == '<' { Some(if op.unwrap() == '<' {

View File

@ -246,9 +246,23 @@ impl Tasks {
where where
F: FnOnce(&Task) -> Option<State>, F: FnOnce(&Task) -> Option<State>,
{ {
self.position.and_then(|id| { self.position
self.update_state_for(&id, comment, f) .and_then(|id| self.update_state_for(&id, comment, f))
}) }
pub(crate) fn add_note(&mut self, note: &str) {
match self.position {
None => eprintln!("Cannot add note '{}' without active task", note),
Some(id) => {
self.sender
.submit(EventBuilder::text_note(note, vec![]))
.map(|e| {
self.tasks.get_mut(&id).map(|t| {
t.props.insert(e.clone());
});
});
}
}
} }
} }