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

added non-functional manager buttons to scheduleView shift popup (edit / remove shift)

added attributes, get/set methods to model
parent 33c08caf
No related branches found
No related tags found
No related merge requests found
...@@ -52,6 +52,12 @@ public class Controller { ...@@ -52,6 +52,12 @@ public class Controller {
Scene popupScene; Scene popupScene;
RafisWeirdClass rafisWeirdClass = new RafisWeirdClass(); RafisWeirdClass rafisWeirdClass = new RafisWeirdClass();
Model model = new Model("127.0.0.1" ,3306); Model model = new Model("127.0.0.1" ,3306);
DailyView dailyView;
WeeklyView weeklyView;
BorderPane root;
Parent header;
Parent sidePanel;
Parent bottomPanel;
public void scheduleButtonClicked() throws IOException { public void scheduleButtonClicked() throws IOException {
System.out.println("schedule button clicked"); System.out.println("schedule button clicked");
...@@ -72,26 +78,33 @@ public class Controller { ...@@ -72,26 +78,33 @@ public class Controller {
} }
public void dailyScheduleButtonClicked() throws IOException { public void dailyScheduleButtonClicked() throws IOException {
System.out.println("daily schedule button clicked"); System.out.println("daily schedule button clicked");
FXMLLoader fxmlLoader = new FXMLLoader(ScheduleApp.class.getResource("dailySchedule.fxml")); root.setTop(header);
myBorderPane.setCenter(fxmlLoader.load()); root.setLeft(sidePanel);
root.setBottom(bottomPanel);
root.setCenter(dailyView);
} }
public void weeklyScheduleButtonClicked () throws Exception { public void weeklyScheduleButtonClicked () throws Exception {
System.out.println("weekly schedule button clicked"); System.out.println("weekly schedule button clicked");
FXMLLoader fxmlLoader = new FXMLLoader(ScheduleApp.class.getResource("weeklySchedule.fxml")); root.setTop(header);
myBorderPane.setCenter(fxmlLoader.load()); root.setLeft(sidePanel);
root.setBottom(bottomPanel);
root.setCenter(weeklyView);
} }
public void pickupsButtonClicked () { public void pickupsButtonClicked () {
System.out.println("pickups button clicked"); System.out.println("pickups button clicked");
} }
public void prevButtonClicked () { public void prevButtonClicked () {
System.out.println("prev button clicked"); System.out.println("prev button clicked");
model.datePrev();
} }
public void jumpButtonClicked () { public void jumpButtonClicked () {
System.out.println("jump button clicked"); System.out.println("jump button clicked");
//model.dateJump();
} }
public void nextButtonClicked () { public void nextButtonClicked () {
System.out.println("next button clicked"); System.out.println("next button clicked");
model.dateNext();
} }
public void addShiftClicked() throws IOException { public void addShiftClicked() throws IOException {
...@@ -130,18 +143,17 @@ public class Controller { ...@@ -130,18 +143,17 @@ public class Controller {
// Login Page // Login Page
public void managerLoginClicked(MouseEvent mouseEvent) throws IOException { public void managerLoginClicked(MouseEvent mouseEvent) throws IOException {
BorderPane root = new BorderPane(); model.setIsManager(true);
//FXMLLoader gridLoader = new FXMLLoader(this.getClass().getResource("dailySchedManager.fxml")); root = new BorderPane();
//Parent grid = gridLoader.load();
FXMLLoader headerLoader = new FXMLLoader(this.getClass().getResource("headerManager.fxml")); FXMLLoader headerLoader = new FXMLLoader(this.getClass().getResource("headerManager.fxml"));
Parent header = headerLoader.load(); header = headerLoader.load();
FXMLLoader sideLoader = new FXMLLoader(this.getClass().getResource("schedSidePanel.fxml")); FXMLLoader sideLoader = new FXMLLoader(this.getClass().getResource("schedSidePanel.fxml"));
Parent sidePanel = sideLoader.load(); sidePanel = sideLoader.load();
FXMLLoader bottomLoader = new FXMLLoader(this.getClass().getResource("schedBottomPanelManager.fxml")); FXMLLoader bottomLoader = new FXMLLoader(this.getClass().getResource("schedBottomPanelManager.fxml"));
Parent bottomPanel = bottomLoader.load(); bottomPanel = bottomLoader.load();
DailyView dailyView = new DailyView(); dailyView = new DailyView();
dailyView.setModel(model); dailyView.setModel(model);
WeeklyView weeklyView = new WeeklyView(); weeklyView = new WeeklyView();
weeklyView.setModel(model); weeklyView.setModel(model);
root.setTop(header); root.setTop(header);
...@@ -158,6 +170,11 @@ public class Controller { ...@@ -158,6 +170,11 @@ public class Controller {
public void employeeLoginClicked(MouseEvent mouseEvent) throws IOException { public void employeeLoginClicked(MouseEvent mouseEvent) throws IOException {
FXMLLoader employeeLoader = new FXMLLoader(this.getClass().getResource("mainView.fxml")); FXMLLoader employeeLoader = new FXMLLoader(this.getClass().getResource("mainView.fxml"));
Parent root = employeeLoader.load(); Parent root = employeeLoader.load();
dailyView = new DailyView();
dailyView.setModel(model);
weeklyView = new WeeklyView();
weeklyView.setModel(model);
Stage stage = (Stage)((Node)mouseEvent.getSource()).getScene().getWindow(); Stage stage = (Stage)((Node)mouseEvent.getSource()).getScene().getWindow();
Scene scene = new Scene(root, 800, 600); Scene scene = new Scene(root, 800, 600);
stage.setTitle("Scheduler App"); stage.setTitle("Scheduler App");
......
...@@ -11,27 +11,27 @@ public class DailyView extends ScheduleView{ ...@@ -11,27 +11,27 @@ public class DailyView extends ScheduleView{
public void draw(){ public void draw(){
//clear //clear
this.getChildren().clear(); contents.getChildren().clear();
//add to gridpane - time axis never changes //add to gridpane - time axis never changes
int i = 1; int i = 1;
for (Label time : times){ for (Label time : times){
this.add(time, 0, i); contents.add(time, 0, i);
i++; i++;
} }
int col = 1; //start on the second column int col = 1; //start on the second column
// update employee axis and schedule display // update employee axis and schedule display
/* ArrayList<Shift> schedule = model.getDailySchedule(); ArrayList<Shift> schedule = model.getDailySchedule();
for (Shift shift : schedule){ for (Shift shift : schedule){
Label name = new Label(Integer.toString(shift.getEmployeeID())); Label name = new Label(Integer.toString(shift.getEmployeeID()));
GridPane.setHalignment(name, HPos.CENTER); GridPane.setHalignment(name, HPos.CENTER);
this.add(name, col, 0); //todo: display name instead contents.add(name, col, 0); //todo: display name instead
this.add(this.formatShiftButton(shift), col, this.shiftGetRow(shift), 1, this.shiftGetLength(shift)); contents.add(this.formatShiftButton(shift), col, this.shiftGetRow(shift), 1, this.shiftGetLength(shift));
col++; col++;
}*/ }
} }
} }
...@@ -15,9 +15,13 @@ public class Model { ...@@ -15,9 +15,13 @@ public class Model {
protected ArrayList<String> employees; protected ArrayList<String> employees;
public LocalDate date; public LocalDate date;
private boolean isManager;
private int thisEmployee;
private int selectedEmployee;
public Model(String hostname, int port) { public Model(String hostname, int port) {
date = LocalDate.now(); date = LocalDate.now();
isManager = false; // changes if manager logs in
this.shifts = new ArrayList<>(); this.shifts = new ArrayList<>();
this.employees = new ArrayList<>(); this.employees = new ArrayList<>();
try { try {
...@@ -37,6 +41,44 @@ public class Model { ...@@ -37,6 +41,44 @@ public class Model {
} }
} }
public void setIsManager(boolean aBool){
isManager = aBool;
}
public boolean getIsManager(){
return isManager;
}
public void setThisEmployee(int id){
thisEmployee = selectedEmployee = id;
}
public int getThisEmployee(){
return thisEmployee;
}
//for manager only, allows viewing of weekly schedule by employee
public void setSelectedEmployee(int id){
selectedEmployee = id;
}
public int getSelectedEmployee(){
return selectedEmployee;
}
public void dateNext(){
date = date.plusDays(1);
}
public void datePrev(){
date = date.minusDays(1);
}
//todo: add calender to fill jump field
public void dateJump(LocalDate date){
this.date = date;
}
//todo //todo
//Return //Return
void getAllEmployees() { void getAllEmployees() {
...@@ -178,8 +220,7 @@ public class Model { ...@@ -178,8 +220,7 @@ public class Model {
//for view //for view
public ArrayList<Shift> getDailySchedule(){ public ArrayList<Shift> getDailySchedule(){
return convertToShift(getShiftsByDay(date.toString()));
return new ArrayList<>();
} }
//format id.yyyy-mm-dd.start.end //format id.yyyy-mm-dd.start.end
......
...@@ -6,26 +6,30 @@ import javafx.geometry.Insets; ...@@ -6,26 +6,30 @@ import javafx.geometry.Insets;
import javafx.scene.Node; import javafx.scene.Node;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.GridPane; import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox; import javafx.scene.layout.VBox;
import javafx.stage.Popup; import javafx.stage.Popup;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.ArrayList; import java.util.ArrayList;
public class ScheduleView extends GridPane implements ModelSubscriber{ public class ScheduleView extends ScrollPane implements ModelSubscriber{
Model model; Model model;
ArrayList<Label> times; ArrayList<Label> times;
Popup dropShift; Popup dropShift;
DateTimeFormatter dateFormatView; DateTimeFormatter dateFormatView;
DateTimeFormatter timeFormat; DateTimeFormatter timeFormat;
GridPane contents;
// must be implemented by the child class // must be implemented by the child class
public void draw(){} public void draw(){}
public ScheduleView(){ public ScheduleView(){
contents = new GridPane();
this.setContent(contents);
//list of time labels //list of time labels
times = new ArrayList<>(); times = new ArrayList<>();
for (int i = 8; i < 24; i++){ for (int i = 8; i < 24; i++){
...@@ -41,7 +45,7 @@ public class ScheduleView extends GridPane implements ModelSubscriber{ ...@@ -41,7 +45,7 @@ public class ScheduleView extends GridPane implements ModelSubscriber{
times.add(kLabel); times.add(kLabel);
} }
for (Label label : times){ for (Label label : times){
label.setPrefHeight(20); label.setPrefHeight(18);
//label.setStyle(" -fx-border-color: black"); //label.setStyle(" -fx-border-color: black");
} }
dateFormatView = DateTimeFormatter.ofPattern("MMM dd, yyyy"); dateFormatView = DateTimeFormatter.ofPattern("MMM dd, yyyy");
...@@ -70,19 +74,37 @@ public class ScheduleView extends GridPane implements ModelSubscriber{ ...@@ -70,19 +74,37 @@ public class ScheduleView extends GridPane implements ModelSubscriber{
Label start = new Label("Start: " + shift.getStart().format(timeFormat)); Label start = new Label("Start: " + shift.getStart().format(timeFormat));
Label end = new Label("End: " + shift.getEnd().format(timeFormat)); Label end = new Label("End: " + shift.getEnd().format(timeFormat));
HBox buttons = new HBox(); GridPane buttons = new GridPane();
buttons.setSpacing(10); buttons.setHgap(10);
buttons.setVgap(10);
//todo: only display buttons if this is your shift //Buttons
Button cancel = new Button("Cancel"); Button cancel = new Button("Cancel");
cancel.setCancelButton(true); cancel.setCancelButton(true);
cancel.setOnAction(cancelDrop); //debug cancel.setOnAction(cancelDrop); //debug
Button drop = new Button("Drop Shift"); Button drop = new Button("Drop Shift");
drop.setDefaultButton(true);
drop.setOnAction(dropShiftConfirm); //debug drop.setOnAction(dropShiftConfirm); //debug
buttons.getChildren().addAll(cancel, drop); //Manager Buttons
Button remove = new Button("Remove Shift");
remove.setOnAction(removeShift);
Button edit = new Button("Edit Shift");
edit.setOnAction(editShift);
buttons.add(cancel, 0, 0);
if (model.getThisEmployee() == shift.getEmployeeID()){
buttons.add(drop, 1, 0);
}
if (model.getIsManager()) {
buttons.add(edit, 0, 1);
buttons.add(remove, 1, 1);
}
for (Node button : buttons.getChildren()){
((Button) button).setMaxWidth(200);
}
details.getChildren().addAll(name, date, start, end, buttons); details.getChildren().addAll(name, date, start, end, buttons);
dropShift.getContent().add(details); dropShift.getContent().add(details);
dropShift.setAutoHide(true); dropShift.setAutoHide(true);
...@@ -103,7 +125,7 @@ public class ScheduleView extends GridPane implements ModelSubscriber{ ...@@ -103,7 +125,7 @@ public class ScheduleView extends GridPane implements ModelSubscriber{
public ShiftButton formatShiftButton(Shift shift){ public ShiftButton formatShiftButton(Shift shift){
ShiftButton shiftRep = new ShiftButton(formatShiftTimeLabel(shift), shift); ShiftButton shiftRep = new ShiftButton(formatShiftTimeLabel(shift), shift);
shiftRep.setMaxHeight(700); //so it always fills its region shiftRep.setMaxHeight(700); //so it always fills its region
shiftRep.setPrefWidth(60); shiftRep.setMaxWidth(100);
GridPane.setFillHeight(shiftRep, true); GridPane.setFillHeight(shiftRep, true);
GridPane.setFillWidth(shiftRep, true); GridPane.setFillWidth(shiftRep, true);
//css styling //css styling
...@@ -158,5 +180,23 @@ public class ScheduleView extends GridPane implements ModelSubscriber{ ...@@ -158,5 +180,23 @@ public class ScheduleView extends GridPane implements ModelSubscriber{
} }
}; };
EventHandler<ActionEvent> removeShift =
new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
System.out.println("todo: delete shift");
dropShift.hide();
}
};
EventHandler<ActionEvent> editShift =
new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
System.out.println("todo: edit shift");
dropShift.hide();
}
};
} }
...@@ -33,14 +33,14 @@ public class WeeklyView extends ScheduleView{ ...@@ -33,14 +33,14 @@ public class WeeklyView extends ScheduleView{
//add to gridpane - time axis never changes //add to gridpane - time axis never changes
int i = 1; int i = 1;
for (Label time : times){ for (Label time : times){
this.add(time, 0, i); contents.add(time, 0, i);
i++; i++;
} }
//add to gridpane - day axis never changes //add to gridpane - day axis never changes
i = 1; i = 1;
for (Label time : days){ for (Label time : days){
this.add(time, i, 0); contents.add(time, i, 0);
i++; i++;
} }
...@@ -51,7 +51,7 @@ public class WeeklyView extends ScheduleView{ ...@@ -51,7 +51,7 @@ public class WeeklyView extends ScheduleView{
for (Shift shift : schedule){ for (Shift shift : schedule){
col = (shift.getStart().getDayOfWeek().getValue() % 7) + 1; //need Sunday=7 to be 1 col = (shift.getStart().getDayOfWeek().getValue() % 7) + 1; //need Sunday=7 to be 1
this.add(this.formatShiftButton(shift), col, this.shiftGetRow(shift), 1, this.shiftGetLength(shift)); contents.add(this.formatShiftButton(shift), col, this.shiftGetRow(shift), 1, this.shiftGetLength(shift));
} }
} }
} }
No preview for this file type
No preview for this file type
No preview for this file type
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