-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
187 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/ca/mcgill/ecse/assetplus/javafx/controllers/AddUserController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package ca.mcgill.ecse.assetplus.javafx.controllers; | ||
|
||
import ca.mcgill.ecse.assetplus.controller.AssetPlusFeatureSet1Controller; | ||
import static ca.mcgill.ecse.assetplus.javafx.controllers.ViewUtils.successful; | ||
import javafx.event.ActionEvent; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.Button; | ||
import javafx.scene.control.TextField; | ||
|
||
public class AddUserController { | ||
|
||
@FXML | ||
private TextField AddEmail; | ||
|
||
@FXML | ||
private TextField AddName; | ||
|
||
@FXML | ||
private TextField AddPassword; | ||
|
||
@FXML | ||
private TextField AddPhone; | ||
|
||
@FXML | ||
private Button AddUser; | ||
|
||
@FXML | ||
private Button cancelAddUser; | ||
|
||
@FXML | ||
void addUserClicked(ActionEvent event) { | ||
String name = AddEmail.getText(); | ||
String email = AddEmail.getText(); | ||
String password = AddPassword.getText(); | ||
String phone = AddPhone.getText(); | ||
if (successful(AssetPlusFeatureSet1Controller.addEmployeeOrGuest(email, password, name, phone, true))) { | ||
AddEmail.setText(""); | ||
AddName.setText(""); | ||
AddPassword.setText(""); | ||
AddPhone.setText(""); | ||
} | ||
// NEED TO RETURN TO USER VIEW PAGE, IF APPLICABLE | ||
|
||
} | ||
|
||
@FXML | ||
void cancelAddUserClicked(ActionEvent event) { | ||
AddEmail.setText(""); | ||
AddName.setText(""); | ||
AddPassword.setText(""); | ||
AddPhone.setText(""); | ||
// NEED TO RETURN TO USER VIEW PAGE | ||
} | ||
|
||
} |
41 changes: 41 additions & 0 deletions
41
src/main/java/ca/mcgill/ecse/assetplus/javafx/controllers/UpdatePasswordController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package ca.mcgill.ecse.assetplus.javafx.controllers; | ||
|
||
import ca.mcgill.ecse.assetplus.controller.AssetPlusFeatureSet1Controller; | ||
import static ca.mcgill.ecse.assetplus.javafx.controllers.ViewUtils.successful; | ||
import javafx.event.ActionEvent; | ||
import javafx.fxml.FXML; | ||
import javafx.scene.control.Button; | ||
import javafx.scene.control.TextField; | ||
|
||
public class UpdatePasswordController { | ||
|
||
@FXML | ||
private Button cancelUpdatePassword; | ||
|
||
@FXML | ||
private TextField newPassword; | ||
|
||
@FXML | ||
private TextField newPasswordConfirm; | ||
|
||
@FXML | ||
private Button updatePassword; | ||
|
||
@FXML | ||
void cancelUpdatePasswordClicked(ActionEvent event) { | ||
|
||
} | ||
|
||
@FXML | ||
void updatePasswordClicked(ActionEvent event) { | ||
String password = newPassword.getText(); | ||
String passowrdConfirm = newPasswordConfirm.getText(); | ||
if (!password.equals(passowrdConfirm)) { | ||
ViewUtils.showError("Please ensure that the new password match."); | ||
} else if (successful(AssetPlusFeatureSet1Controller.updateManager(password))) { | ||
newPassword.setText(""); | ||
newPasswordConfirm.setText(""); | ||
} | ||
} | ||
|
||
} |
65 changes: 65 additions & 0 deletions
65
src/main/java/ca/mcgill/ecse/assetplus/javafx/controllers/ViewUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package ca.mcgill.ecse.assetplus.javafx.controllers; | ||
|
||
import java.util.List; | ||
import ca.mcgill.ecse.assetplus.javafx.AssetPlusFxmlView; | ||
import javafx.collections.FXCollections; | ||
import javafx.collections.ObservableList; | ||
import javafx.geometry.Insets; | ||
import javafx.geometry.Pos; | ||
import javafx.scene.Scene; | ||
import javafx.scene.control.Button; | ||
import javafx.scene.layout.VBox; | ||
import javafx.scene.text.Text; | ||
import javafx.stage.Modality; | ||
import javafx.stage.Stage; | ||
|
||
public class ViewUtils { | ||
|
||
/** Calls the controller and shows an error, if applicable. */ | ||
public static boolean callController(String result) { | ||
if (result.isEmpty()) { | ||
AssetPlusFxmlView.getInstance().refresh(); | ||
return true; | ||
} | ||
showError(result); | ||
return false; | ||
} | ||
|
||
/** Calls the controller and returns true on success. This method is included for readability. */ | ||
public static boolean successful(String controllerResult) { | ||
return callController(controllerResult); | ||
} | ||
|
||
/** | ||
* Creates a popup window. | ||
* | ||
* @param title: title of the popup window | ||
* @param message: message to display | ||
*/ | ||
public static void makePopupWindow(String title, String message) { | ||
Stage dialog = new Stage(); | ||
dialog.initModality(Modality.APPLICATION_MODAL); | ||
VBox dialogPane = new VBox(); | ||
|
||
// create UI elements | ||
Text text = new Text(message); | ||
Button okButton = new Button("OK"); | ||
okButton.setOnAction(a -> dialog.close()); | ||
|
||
// display the popup window | ||
int innerPadding = 10; // inner padding/spacing | ||
int outerPadding = 100; // outer padding | ||
dialogPane.setSpacing(innerPadding); | ||
dialogPane.setAlignment(Pos.CENTER); | ||
dialogPane.setPadding(new Insets(innerPadding, innerPadding, innerPadding, innerPadding)); | ||
dialogPane.getChildren().addAll(text, okButton); | ||
Scene dialogScene = new Scene(dialogPane, outerPadding + 5 * message.length(), outerPadding); | ||
dialog.setScene(dialogScene); | ||
dialog.setTitle(title); | ||
dialog.show(); | ||
} | ||
|
||
public static void showError(String message) { | ||
makePopupWindow("Error", message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters