Added card creation
This commit is contained in:
parent
e580dc02dc
commit
a421ccfbb1
1 changed files with 55 additions and 15 deletions
|
@ -1,5 +1,5 @@
|
|||
// Libraries
|
||||
use crate::{board, manager};
|
||||
use crate::{board, card, manager};
|
||||
use std::{io, process::exit};
|
||||
|
||||
// Structures
|
||||
|
@ -71,11 +71,12 @@ impl<'a> Interface<'a> {
|
|||
}
|
||||
|
||||
// Presenting options
|
||||
println!("\n1) Edit Card");
|
||||
println!("2) Delete Card");
|
||||
println!("3) Delete Board");
|
||||
println!("4) Exit");
|
||||
println!("\nSelect Option [1-4]: ");
|
||||
println!("\n1) Create Card");
|
||||
println!("2) Edit Card");
|
||||
println!("3) Delete Card");
|
||||
println!("4) Delete Board");
|
||||
println!("5) Exit");
|
||||
println!("\nSelect Option [1-5]: ");
|
||||
|
||||
// Selection option
|
||||
let mut user_input: String = String::new();
|
||||
|
@ -84,20 +85,58 @@ impl<'a> Interface<'a> {
|
|||
println!("");
|
||||
|
||||
// What to do
|
||||
if user_input == "1"{
|
||||
|
||||
if user_input == "1" {
|
||||
self.page = 3;
|
||||
} else if user_input == "2"{
|
||||
self.mode = 0;
|
||||
self.page = 4;
|
||||
|
||||
} else if user_input == "3"{
|
||||
self.mode = 1;
|
||||
self.page = 4;
|
||||
self.mode = 0;
|
||||
self.page = 5;
|
||||
} else if user_input == "4"{
|
||||
self.mode = 1;
|
||||
self.page = 5;
|
||||
} else if user_input == "5"{
|
||||
self.page = 0;
|
||||
}
|
||||
}
|
||||
fn p_3(&mut self){
|
||||
// Title
|
||||
println!(" - Create Card - \n");
|
||||
|
||||
fn p_4(&mut self){
|
||||
// Variables
|
||||
let mut user_input: String = String::new();
|
||||
|
||||
// Asking the user what the name is
|
||||
println!("What is your card's name?");
|
||||
println!("Select name: ");
|
||||
|
||||
// Reading input
|
||||
io::stdin().read_line(&mut user_input).expect("Failed to read line");
|
||||
let _name: String = String::from(user_input.trim());
|
||||
println!("");
|
||||
|
||||
// Reset user input
|
||||
user_input = String::new();
|
||||
|
||||
// Asking the user what the description is
|
||||
println!("Give your card a description!");
|
||||
println!("Select description: ");
|
||||
|
||||
// Reading input
|
||||
io::stdin().read_line(&mut user_input).expect("Failed to read line");
|
||||
let _desc: String = String::from(user_input.trim());
|
||||
println!("");
|
||||
|
||||
// Creating a card
|
||||
let _new_card: card::TaskCard = card::TaskCard::init_val(_name, _desc);
|
||||
|
||||
// Throw this into our manager
|
||||
self.manager.boards[self.on as usize].cards.push(_new_card);
|
||||
|
||||
// Finished!
|
||||
self.page = 2;
|
||||
}
|
||||
fn p_5(&mut self){
|
||||
// Which title do we use
|
||||
let title: String = String::from(match self.mode {
|
||||
0 => "Card",
|
||||
|
@ -127,7 +166,7 @@ impl<'a> Interface<'a> {
|
|||
user_input = String::from(user_input.to_lowercase().trim());
|
||||
|
||||
// Parse user input into a usize
|
||||
let card_index: usize = user_input.parse().unwrap();
|
||||
let card_index: usize = user_input.parse::<usize>().unwrap() - 1;
|
||||
|
||||
// Reset user input
|
||||
user_input = String::new();
|
||||
|
@ -182,7 +221,8 @@ impl<'a> Interface<'a> {
|
|||
0 => self.p_0(),
|
||||
1 => self.p_1(),
|
||||
2 => self.p_2(),
|
||||
4 => self.p_4(),
|
||||
3 => self.p_3(),
|
||||
5 => self.p_5(),
|
||||
_ => Interface::error("Invalid Page")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue