diff --git a/src/db.rs b/src/db.rs index c5b6c5c..c6a51c6 100644 --- a/src/db.rs +++ b/src/db.rs @@ -5,7 +5,7 @@ use anyhow::{anyhow, Result}; use crate::models::{DBState, Epic, Status, Story}; pub struct JiraDatabase { - database: Box, + pub(crate) database: Box, } impl JiraDatabase { diff --git a/src/ui/pages/page_helpers.rs b/src/ui/pages/page_helpers.rs index 53320ab..c28d5e3 100644 --- a/src/ui/pages/page_helpers.rs +++ b/src/ui/pages/page_helpers.rs @@ -1,7 +1,29 @@ use ellipse::Ellipse; pub fn get_column_string(text: &str, width: usize) -> String { - todo!() // use the truncate_ellipse function from the ellipse crate + match width { + 0 => return String::new(), + 1 => return ".".to_owned(), + 2 => return "..".to_owned(), + 3 => return "...".to_owned(), + _ => {} + } + + let length = text.len(); + + if width == length { + return text.to_owned(); + } + + if width > length { + let diff = " ".repeat(width - length); + let mut out = text.to_owned(); + out.push_str(&diff); + + return out; + } + + text.truncate_ellipse(width - 3).to_string() } #[cfg(test)]