package squire.controllers;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.stage.Stage;

import java.net.URL;
import java.util.ResourceBundle;

/**
 * Created by Domn Werner on 4/10/2016.
 */
public class PreferencesDialogController implements Initializable
{
    @FXML private PasswordField newPasswordField;
    @FXML private PasswordField confirmPasswordField;
    @FXML private TextField newEmailTextField;
    @FXML private TextField confirmEmailTextField;
    @FXML private Button closeButton;
    @FXML private Button submitButton;

    private Stage thisStage;

    @Override
    public void initialize(URL location, ResourceBundle resources)
    {

    }

    @FXML private void onCloseButtonClick(ActionEvent event)
    {
        thisStage = (Stage)closeButton.getScene().getWindow();
        System.out.println("Close button clicked.");
        thisStage.close();
    }

    @FXML private void onSubmitButtonClick(ActionEvent event)
    {
        thisStage = (Stage)submitButton.getScene().getWindow();
        System.out.println("Close button clicked.");
        thisStage.close();
    }
}

@@ -258,16 +258,85 @@
 e.Stage;
+%0Aimport squire.Networking.Request;%0Aimport squire.Networking.Response;
 %0A%0Aimport
@@ -1307,32 +1307,520 @@
 ked.%22);%0A        
+if (newPasswordField.getText().equals(confirmPasswordField.getText())) %7B%0A            Response res = new Request(%22user/ChangePassword%22)%0A                    .set(%22password%22, newPasswordField.getText())%0A                    .send();%0A%0A            if (res.getSuccess())%0A            %7B%0A                System.out.println(%22Password Changed.%22);%0A                thisStage.close();%0A            %7D%0A            else%0A            %7B%0A                //user already exists%0A            %7D%0A        %7D%0A%0A        //
 thisStage.close(

Change Password functionality added