Skip to content

Commit

Permalink
Ui consistency fixes + new theme dracula!! Thanks @lmstolton + clippy…
Browse files Browse the repository at this point in the history
… fixes
  • Loading branch information
yashs662 committed Jul 26, 2023
1 parent 5e41e67 commit 5d40957
Show file tree
Hide file tree
Showing 7 changed files with 236 additions and 152 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rust-kanban"
version = "0.7.2"
version = "0.7.3"
authors = ["Yash Sharma <yashs662@gmail.com>"]
edition = "2021"
license = "MIT"
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,5 @@
![Matrix](https://user-images.githubusercontent.com/66156000/232308312-56cebb9f-eb93-4a20-8758-4a1e9db96c35.png)
- Cyberpunk
![Cyberpunk](https://user-images.githubusercontent.com/66156000/232308321-4eeec180-6f05-4b49-948a-1166792ad25e.png)
- Dracula
![Dracula](https://github.com/yashs662/rust_kanban/assets/66156000/70d3cb2f-3373-419d-9fa7-dc772bf8fdad)
7 changes: 6 additions & 1 deletion src/app/app_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5473,7 +5473,9 @@ fn handle_new_board_action(app: &mut App) {
if app.state.focus == Focus::SubmitButton {
// check if app.state.new_board_form[0] is not empty or is not the same as any of the existing boards
let new_board_name = app.state.new_board_form[0].clone();
let new_board_name = new_board_name.trim();
let new_board_description = app.state.new_board_form[1].clone();
let new_board_description = new_board_description.trim();
let mut same_name_exists = false;
for board in app.boards.iter() {
if board.name == new_board_name {
Expand Down Expand Up @@ -5519,8 +5521,11 @@ fn handle_new_card_action(app: &mut App) -> AppReturn {
if app.state.focus == Focus::SubmitButton {
// check if app.state.new_card_form[0] is not empty or is not the same as any of the existing cards
let new_card_name = app.state.new_card_form[0].clone();
let new_card_name = new_card_name.trim();
let new_card_description = app.state.new_card_form[1].clone();
let new_card_description = new_card_description.trim();
let new_card_due_date = app.state.new_card_form[2].clone();
let new_card_due_date = new_card_due_date.trim();
let mut same_name_exists = false;
let current_board_id = app.state.current_board_id.unwrap_or((0, 0));
let current_board = app.boards.iter().find(|board| board.id == current_board_id);
Expand Down Expand Up @@ -5568,7 +5573,7 @@ fn handle_new_card_action(app: &mut App) -> AppReturn {
let new_card = Card::new(
new_card_name,
new_card_description,
parsed_date,
&parsed_date,
CardPriority::Low,
vec![],
vec![],
Expand Down
26 changes: 10 additions & 16 deletions src/app/kanban.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ pub struct Board {
}

impl Board {
pub fn new(name: String, description: String) -> Self {
pub fn new(name: &str, description: &str) -> Self {
Self {
id: get_id(),
name,
description,
name: name.to_owned(),
description: description.to_owned(),
cards: Vec::new(),
}
}
Expand Down Expand Up @@ -155,27 +155,27 @@ pub struct Card {

impl Card {
pub fn new(
name: String,
description: String,
due_date: String,
name: &str,
description: &str,
due_date: &str,
priority: CardPriority,
tags: Vec<String>,
comments: Vec<String>,
) -> Self {
let name = if name.is_empty() {
FIELD_NOT_SET
} else {
&name
name
};
let description = if description.is_empty() {
FIELD_NOT_SET
} else {
&description
description
};
let due_date = if due_date.is_empty() {
FIELD_NOT_SET
} else {
&due_date
due_date
};
let priority = if priority.to_string().is_empty() {
CardPriority::Low
Expand Down Expand Up @@ -249,13 +249,7 @@ impl Card {
};
let due_date = match value["due_date"].as_str() {
Some(due_date) => due_date,
None => {
// TODO : This is a fall back for old cards that had the field date_due instead of due_date. remove this in the future
match value["date_due"].as_str() {
Some(date_due) => date_due,
None => return Err("card due_date is invalid for card".to_string()),
}
}
None => return Err("card due_date is invalid for card".to_string()),
};
let date_completed = match value["date_completed"].as_str() {
Some(date_completed) => date_completed,
Expand Down
72 changes: 34 additions & 38 deletions src/io/data_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,47 +221,43 @@ pub fn get_available_local_save_files(config: &AppConfig) -> Option<Vec<String>>
// example kanban_02-12-2022_v7
// use regex to match the pattern

// TODO: Regex is not being used to allow people to use older save files
// let re = Regex::new(r"^kanban_\d{2}-\d{2}-\d{4}_v\d+.json").unwrap();

// using any .json file for now
let re = Regex::new(r"^.*\.json").unwrap();
let re = Regex::new(r"^kanban_\d{2}-\d{2}-\d{4}_v\d+.json").unwrap();

savefiles.retain(|file| re.is_match(file));
// order the files by date and version
// savefiles.sort_by(|a, b| {
// let a_date = a.split('_').nth(1).unwrap();
// let b_date = b.split('_').nth(1).unwrap();
// let a_version = a.split('_').nth(2).unwrap();
// let b_version = b.split('_').nth(2).unwrap();
// let a_date = chrono::NaiveDate::parse_from_str(a_date, "%d-%m-%Y").unwrap();
// let b_date = chrono::NaiveDate::parse_from_str(b_date, "%d-%m-%Y").unwrap();
// let a_version = a_version
// .split('v')
// .nth(1)
// .unwrap()
// .replace(".json", "")
// .parse::<u32>()
// .unwrap();
// let b_version = b_version
// .split('v')
// .nth(1)
// .unwrap()
// .replace(".json", "")
// .parse::<u32>()
// .unwrap();
// if a_date > b_date {
// std::cmp::Ordering::Greater
// } else if a_date < b_date {
// std::cmp::Ordering::Less
// } else if a_version > b_version {
// std::cmp::Ordering::Greater
// } else if a_version < b_version {
// std::cmp::Ordering::Less
// } else {
// std::cmp::Ordering::Equal
// }
// });
savefiles.sort_by(|a, b| {
let a_date = a.split('_').nth(1).unwrap();
let b_date = b.split('_').nth(1).unwrap();
let a_version = a.split('_').nth(2).unwrap();
let b_version = b.split('_').nth(2).unwrap();
let a_date = chrono::NaiveDate::parse_from_str(a_date, "%d-%m-%Y").unwrap();
let b_date = chrono::NaiveDate::parse_from_str(b_date, "%d-%m-%Y").unwrap();
let a_version = a_version
.split('v')
.nth(1)
.unwrap()
.replace(".json", "")
.parse::<u32>()
.unwrap();
let b_version = b_version
.split('v')
.nth(1)
.unwrap()
.replace(".json", "")
.parse::<u32>()
.unwrap();
if a_date > b_date {
std::cmp::Ordering::Greater
} else if a_date < b_date {
std::cmp::Ordering::Less
} else if a_version > b_version {
std::cmp::Ordering::Greater
} else if a_version < b_version {
std::cmp::Ordering::Less
} else {
std::cmp::Ordering::Equal
}
});
Some(savefiles)
}
Err(_) => {
Expand Down
Loading

0 comments on commit 5d40957

Please sign in to comment.