add relations

This commit is contained in:
JMARyA 2024-06-07 10:48:38 +02:00
parent 41524a18af
commit a721556902
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
5 changed files with 163 additions and 8 deletions

View file

@ -1,5 +1,5 @@
use crate::{
api::{Comment, Project, ProjectID, Task, VikunjaAPI},
api::{Comment, Project, ProjectID, Relation, Task, VikunjaAPI},
ui::{
format_html_to_terminal, hex_to_color, is_in_past, parse_datetime, print_color,
print_label, time_relative,
@ -157,10 +157,6 @@ pub fn print_task_info(task_id: isize, api: &VikunjaAPI) {
println!();
}
if task.description != "<p></p>" && !task.description.is_empty() {
println!("---\n{}", format_html_to_terminal(&task.description));
}
if let Some(assigned) = task.assignees {
print!("Assigned to: ");
for assignee in assigned {
@ -169,6 +165,25 @@ pub fn print_task_info(task_id: isize, api: &VikunjaAPI) {
println!();
}
if let Some(related) = task.related_tasks {
for relation in related {
print_color(
crossterm::style::Color::Magenta,
&format!("{}: ", Relation::try_parse(&relation.0).unwrap().repr()),
);
for t in relation.1 {
print_color(crossterm::style::Color::Blue, &t.title);
print_color(crossterm::style::Color::Yellow, &format!(" ({})", t.id));
print!(" ");
}
println!();
}
}
if task.description != "<p></p>" && !task.description.is_empty() {
println!("---\n{}", format_html_to_terminal(&task.description));
}
// pub percent_done: f64,
}