package seedu.unburden.ui;

import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import seedu.unburden.model.task.ReadOnlyTask;

//@@Gauri Joshi A0143095H
public class TaskCard extends UiPart{

    private static final String FXML = "TaskListCard.fxml";

    @FXML
    private HBox cardPane;
    @FXML
    private Label name;
    @FXML
    private Label taskD;
    @FXML
    private Label date;
    @FXML
    private Label startTime;
    @FXML
    private Label endTime;
    @FXML
    private Label id;
    @FXML
    private Label tags;
    @FXML
    private Label done;

    private ReadOnlyTask task;
    private int displayedIndex;

    public TaskCard(){

    }

    public static TaskCard load(ReadOnlyTask task, int displayedIndex){
        TaskCard card = new TaskCard();
        card.task = task;
        card.displayedIndex = displayedIndex;
        return UiPartLoader.loadUiPart(card);
    }

    @FXML
    public void initialize() {
        
        id.setText(displayedIndex + ". ");
        name.setText(task.getName().fullName);
        if(task.getDone()){
        	cardPane.setStyle("-fx-background-color : #f97f9c");
        }
        if(task.getTaskDescription().fullTaskDescriptions != "NIL"){
        	taskD.setText("Task Description : " + task.getTaskDescription().fullTaskDescriptions);
        }
        if(task.getDate().fullDate != "NIL"){
            date.setText("Date: " + task.getDate().fullDate);
        }
        if(task.getStartTime().fullTime != "NIL"){
        	startTime.setText("Start Time: " + task.getStartTime().fullTime);
        }
        if(task.getStartTime().fullTime != "NIL"){
            endTime.setText("End Time: " + task.getEndTime().fullTime);
        } 
        
        done.setText(" [ " + task.getDoneString() + " ] ");
        tags.setText("      " + task.tagsString());
        
        /*
    	if(person.getDate().fullDate != "NIL" && person.getStartTime().fullTime != "NIL"){
        name.setText(
        person.getName().fullName + "\n" 
        + "Deadline : " + person.getDate().fullDate + "\n"
        + "Start Time : " + person.getStartTime().fullTime + "\n"
        + "End Time : " + person.getEndTime().fullTime + "\n"
        );
        id.setText(displayedIndex + ". ");
        //date.setText(person.getDate().fullDate);
        //startTime.setText(person.getStartTime().fullTime);
        //endTime.setText(person.getEndTime().fullTime);
        tags.setText("      " + person.tagsString());
    	}
    	
    	if(person.getStartTime().fullTime == "NIL" && person.getEndTime().fullTime == "NIL" && person.getDate().fullDate != "NIL"){
    		name.setText(person.getName().fullName + "\n"
    		+ "Deadline : " + person.getDate().fullDate + "\n");
    		id.setText(displayedIndex + ". ");
            tags.setText("      " + person.tagsString());
    	}
    	
    	if(person.getStartTime().fullTime == "NIL" && person.getEndTime().fullTime == "NIL" && person.getDate().fullDate == "NIL"){
    		name.setText(person.getName().fullName + "\n");
    		id.setText(displayedIndex + ". ");
            tags.setText("      " + person.tagsString());
    	}
    	*/
    }

    public HBox getLayout() {
        return cardPane;
    }

    @Override
    public void setNode(Node node) {
        cardPane = (HBox)node;
    }

    @Override
    public String getFxmlPath() {
        return FXML;
    }
}

@@ -1215,68 +1215,8 @@
     
-if(task.getTaskDescription().fullTaskDescriptions != %22NIL%22)%7B
 %0A   
@@ -1220,17 +1220,16 @@
         
-%09
 taskD.se
@@ -1238,32 +1238,8 @@
 ext(
-%22Task Description : %22 + 
 task
@@ -1287,68 +1287,8 @@
 s);%0A
-        %7D%0A        if(task.getDate().fullDate != %22NIL%22)%7B%0A    
     
@@ -1308,19 +1308,8 @@
 ext(
-%22Date: %22 + 
 task
@@ -1342,70 +1342,8 @@
     
-%7D%0A        if(task.getStartTime().fullTime != %22NIL%22)%7B%0A        %09
 star
@@ -1360,25 +1360,8 @@
 ext(
-%22Start Time: %22 + 
 task
@@ -1391,73 +1391,8 @@
 e);%0A
-        %7D%0A        if(task.getStartTime().fullTime != %22NIL%22)%7B%0A    
     
@@ -1415,23 +1415,8 @@
 ext(
-%22End Time: %22 + 
 task
@@ -1443,21 +1443,8 @@
 me);
-%0A        %7D %0A 
     

update taskCard to remove if else statements