Skip to content
Snippets Groups Projects
Commit f98d01a6 authored by ArktikHunter's avatar ArktikHunter
Browse files

fixed some issues on add/remove positions

todo: positions in editEmployee?
parent fd3fa23b
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,7 @@ import javafx.event.Event; ...@@ -8,6 +8,7 @@ import javafx.event.Event;
import javafx.event.EventHandler; import javafx.event.EventHandler;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader; import javafx.fxml.FXMLLoader;
import javafx.geometry.Insets;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.Parent; import javafx.scene.Parent;
import javafx.scene.Scene; import javafx.scene.Scene;
...@@ -563,16 +564,21 @@ public class Controller { ...@@ -563,16 +564,21 @@ public class Controller {
} }
public void addRemovePosition(){ public void addRemovePosition(){
VBox tempBox = new VBox(); VBox tempBox = new VBox();
tempBox.setPadding(new Insets(20));
tempBox.setSpacing(20);
ComboBox tempCombo = new ComboBox(); ComboBox tempCombo = new ComboBox();
Button addPosition = new Button("Add Position"); Button addPosition = new Button("Add Position");
Button removePosition = new Button("Remove Position"); Button removePosition = new Button("Remove Position");
tempBox.getChildren().addAll(tempCombo,addPosition,removePosition); Label result = new Label("");
tempBox.getChildren().addAll(tempCombo,addPosition,removePosition, result);
tempCombo.setOnMouseClicked(this::populatePositionBox); tempCombo.setOnMouseClicked(this::populatePositionBox);
addPosition.setOnMouseClicked(new EventHandler<MouseEvent>() { addPosition.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override @Override
public void handle(MouseEvent mouseEvent) { public void handle(MouseEvent mouseEvent) {
VBox tempVBox = new VBox(); VBox tempVBox = new VBox();
tempVBox.setSpacing(20);
tempVBox.setPadding(new Insets(30));
TextField tempPositionText = new TextField("Enter Position Here"); TextField tempPositionText = new TextField("Enter Position Here");
TextField tempWageText = new TextField("Enter Wage Here"); TextField tempWageText = new TextField("Enter Wage Here");
Button addPositionSubmit = new Button("Submit"); Button addPositionSubmit = new Button("Submit");
...@@ -591,16 +597,11 @@ public class Controller { ...@@ -591,16 +597,11 @@ public class Controller {
}); });
} }
}); });
removePosition.setOnMouseClicked(new EventHandler<MouseEvent>() { removePosition.setOnMouseClicked(e -> {
@Override if (tempCombo.getValue() == null) result.setText("No position selected.");
public void handle(MouseEvent mouseEvent) { else result.setText(model.removePosition(tempCombo.getSelectionModel().getSelectedItem().toString()));
int boxIndex = tempCombo.getSelectionModel().getSelectedIndex(); });
if(boxIndex >= 0){
// TODO: remove position
System.out.println("remove position clicked");
}
}
});
root.setCenter(tempBox); root.setCenter(tempBox);
} }
......
...@@ -697,6 +697,9 @@ public class Model { ...@@ -697,6 +697,9 @@ public class Model {
} }
String removePosition(String position) { String removePosition(String position) {
if (position == null){
return "No position selected.";
}
if (position.contains("/") || position.contains(",")){ if (position.contains("/") || position.contains(",")){
return "Illegal character(s)"; return "Illegal character(s)";
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment