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

commit before pull

parent 7c26edaa
No related branches found
No related tags found
No related merge requests found
......@@ -276,4 +276,8 @@ public class Employee {
public void removePosition(String position) {
this.positions.remove(position);
}
public String toString(){
return this.employeeID + " - " + this.getFullName();
}
}
......@@ -26,8 +26,10 @@ public class ScheduleView extends ScrollPane implements ModelSubscriber{
ArrayList<String> timesString;
Popup dropShift;
Popup editShiftPopup;
Popup reassignPopup;
DateTimeFormatter dateFormatView;
DateTimeFormatter timeFormat;
DateTimeFormatter dbTimeFormat;
GridPane contents;
......@@ -61,6 +63,7 @@ public class ScheduleView extends ScrollPane implements ModelSubscriber{
}
dateFormatView = DateTimeFormatter.ofPattern("MMM dd, yyyy");
timeFormat = DateTimeFormatter.ofPattern("kk:mm");
dbTimeFormat = DateTimeFormatter.ofPattern("kkmm");
}
......@@ -93,6 +96,7 @@ public class ScheduleView extends ScrollPane implements ModelSubscriber{
Label date = new Label("Date: " + shift.getStart().format(dateFormatView));
Label start = new Label("Start: " + shift.getStart().format(timeFormat));
Label end = new Label("End: " + shift.getEnd().format(timeFormat));
Label result = new Label();
GridPane buttons = new GridPane();
buttons.setHgap(10);
......@@ -104,7 +108,10 @@ public class ScheduleView extends ScrollPane implements ModelSubscriber{
cancel.setOnAction(cancelDrop); //debug
Button drop = new Button("Drop Shift");
drop.setOnAction(dropShiftConfirm); //debug
drop.setOnAction(e -> {
dropShift(shift.getShiftID());
result.setText("Shift dropped");
});
//Manager Buttons
Button remove = new Button("Remove Shift");
......@@ -116,6 +123,12 @@ public class ScheduleView extends ScrollPane implements ModelSubscriber{
editShiftPopup.show(this.getScene().getWindow());
});
Button reassign = new Button("Reassign Shift");
reassign.setOnAction(e -> {
drawReassignPopUp(shift);
reassignPopup.show(this.getScene().getWindow());
});
buttons.add(cancel, 0, 0);
if (model.getThisEmployee() == shift.getEmployeeID()){
buttons.add(drop, 1, 0);
......@@ -123,12 +136,13 @@ public class ScheduleView extends ScrollPane implements ModelSubscriber{
if (model.getIsManager()) {
buttons.add(edit, 0, 1);
buttons.add(remove, 1, 1);
buttons.add(reassign, 2, 1);
}
for (Node button : buttons.getChildren()){
((Button) button).setMaxWidth(200);
}
details.getChildren().addAll(name, position, date, start, end, buttons);
details.getChildren().addAll(name, position, date, start, end, result, buttons);
dropShift.getContent().add(details);
dropShift.setAutoHide(true);
}
......@@ -172,6 +186,44 @@ public class ScheduleView extends ScrollPane implements ModelSubscriber{
editShiftPopup.setAutoHide(true);
}
public void drawReassignPopUp(Shift shift){
reassignPopup = new Popup();
reassignPopup.setHeight(300);
reassignPopup.setWidth(300);
VBox details = new VBox();
details.setStyle("-fx-background-color: papayawhip; -fx-border-color: black");
details.setPadding(new Insets(20));
details.setSpacing(20);
ComboBox<Employee> name = new ComboBox<>(FXCollections.observableArrayList(model.getAllEmployees()));
Label position = new Label("Position: " + shift.getPosition());
Label date = new Label("Date: " + shift.getStart().format(dateFormatView));
Label start = new Label("Start: " + shift.getStart().format(timeFormat));
Label end = new Label("End: " + shift.getEnd().format(timeFormat));
Label result = new Label();
GridPane buttons = new GridPane();
buttons.setHgap(10);
buttons.setVgap(10);
//Buttons
Button cancel = new Button("Close");
cancel.setCancelButton(true);
cancel.setOnAction(e -> cancelReassign());
Button confirm = new Button("Confirm");
confirm.setOnAction(e -> {
result.setText(reassignShift(shift.getShiftID(), name.getSelectionModel().getSelectedItem().getEmployeeID()));
});
buttons.addRow(0, cancel, confirm);
details.getChildren().addAll(name, position, date, start, end, result, buttons);
reassignPopup.getContent().add(details);
reassignPopup.setAutoHide(true);
}
public void modelChanged() {
......@@ -256,11 +308,21 @@ public class ScheduleView extends ScrollPane implements ModelSubscriber{
shift.isAvailable(), shift.getEmployeeID());
}
private void reassignShift(int shiftID){
private String reassignShift(int shiftID, int empID){
Shift shift = model.getShift(shiftID);
return model.editShift(shiftID, shift.getDate(), Integer.parseInt(shift.getStart().format(dbTimeFormat)),
Integer.parseInt(shift.getEnd().format(dbTimeFormat)), false, empID);
}
private void cancelEdit(){
editShiftPopup.hide();
}
private void cancelReassign(){
reassignPopup.hide();
}
private void dropShift(int shiftID){
model.editShiftAvailability(shiftID, true);
}
}
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