feat(tasks): add task author to default columns

This commit is contained in:
xeruf 2024-08-19 21:18:11 +03:00
parent 721c200b97
commit c64a1fa051
2 changed files with 18 additions and 16 deletions

View File

@ -30,7 +30,7 @@ Immutable:
- `parentid` - unique task id of the parent, if any - `parentid` - unique task id of the parent, if any
- `name` - initial name of the task - `name` - initial name of the task
- `created` - task creation timestamp - `created` - task creation timestamp
- `author` - name of the task creator - `author` - name or abbreviated key of the task creator
Task: Task:
- `status` - pure task status - `status` - pure task status
- `hashtags` - list of hashtags set for the task - `hashtags` - list of hashtags set for the task

View File

@ -119,19 +119,21 @@ impl Tasks {
tasks: Default::default(), tasks: Default::default(),
history: Default::default(), history: Default::default(),
users: Default::default(), users: Default::default(),
properties: vec![ properties: [
"state".into(), "author",
"rtime".into(), "state",
"hashtags".into(), "rtime",
"rpath".into(), "hashtags",
"desc".into(), "rpath",
], "desc",
sorting: VecDeque::from([ ].into_iter().map(|s| s.to_string()).collect(),
"state".into(), sorting: [
"hashtags".into(), "author",
"rtime".into(), "state",
"name".into(), "hashtags",
]), "rtime",
"name",
].into_iter().map(|s| s.to_string()).collect(),
view: Default::default(), view: Default::default(),
tags: Default::default(), tags: Default::default(),
tags_excluded: Default::default(), tags_excluded: Default::default(),
@ -425,7 +427,7 @@ impl Tasks {
writeln!(lock, "{}\n{}", label.italic(), times_recent.join("\n"))?; writeln!(lock, "{}\n{}", label.italic(), times_recent.join("\n"))?;
return Ok(()); return Ok(());
} }
// TODO proper column alignment // TODO proper column alignment
// TODO hide empty columns // TODO hide empty columns
writeln!(lock, "{}", self.properties.join("\t").bold())?; writeln!(lock, "{}", self.properties.join("\t").bold())?;
@ -502,7 +504,7 @@ impl Tasks {
pub(crate) fn get_author(&self, pubkey: &PublicKey) -> String { pub(crate) fn get_author(&self, pubkey: &PublicKey) -> String {
self.users.get(pubkey) self.users.get(pubkey)
.and_then(|m| m.name.clone()) .and_then(|m| m.name.clone())
.unwrap_or_else(|| pubkey.to_string()) .unwrap_or_else(|| format!("{:.6}", pubkey.to_string()))
} }
// Movement and Selection // Movement and Selection