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

view / modify availabilty should work, needs more testing

parent 961c7c49
No related branches found
No related tags found
No related merge requests found
...@@ -58,7 +58,7 @@ public class AvailabilityView extends ScrollPane implements ModelSubscriber{ ...@@ -58,7 +58,7 @@ public class AvailabilityView extends ScrollPane implements ModelSubscriber{
//clear //clear
contents.getChildren().clear(); contents.getChildren().clear();
Label blank = new Label(" "); Label blank = new Label(" ");
blank.setStyle("-fx-background-color: white"); blank.setStyle("-fx-background-color: white");
contents.add(blank, 0, 0); contents.add(blank, 0, 0);
...@@ -103,7 +103,7 @@ public class AvailabilityView extends ScrollPane implements ModelSubscriber{ ...@@ -103,7 +103,7 @@ public class AvailabilityView extends ScrollPane implements ModelSubscriber{
public int availGetLength(LocalTime[] times){ public int availGetLength(LocalTime[] times){
//calculate length //calculate length
int length = (times[0].getHour() - times[1].getHour()) * 2; int length = (times[1].getHour() - times[0].getHour()) * 2;
if (times[0].getMinute() == 30) length--; if (times[0].getMinute() == 30) length--;
if (times[1].getMinute() == 30) length++; if (times[1].getMinute() == 30) length++;
return length; return length;
...@@ -121,7 +121,7 @@ public class AvailabilityView extends ScrollPane implements ModelSubscriber{ ...@@ -121,7 +121,7 @@ public class AvailabilityView extends ScrollPane implements ModelSubscriber{
public Button formatButton(LocalTime start, LocalTime end){ public Button formatButton(LocalTime start, LocalTime end){
Button rep = new Button(formatTimeLabel(start, end)); Button rep = new Button(formatTimeLabel(start, end));
rep.setMaxHeight(700); //so it always fills its region rep.setMaxHeight(1000); //so it always fills its region
rep.setMaxWidth(100); rep.setMaxWidth(100);
GridPane.setFillHeight(rep, true); GridPane.setFillHeight(rep, true);
GridPane.setFillWidth(rep, true); GridPane.setFillWidth(rep, true);
......
...@@ -208,7 +208,6 @@ public class Employee { ...@@ -208,7 +208,6 @@ public class Employee {
} else { } else {
result[i] = s[i]; result[i] = s[i];
} }
System.out.println(s[i]);
} }
return result; return result;
} }
......
...@@ -287,7 +287,7 @@ public class Model { ...@@ -287,7 +287,7 @@ public class Model {
return "New shift added"; return "New shift added";
} }
boolean hasEmployee(int id){ boolean hasEmployee(int id){
return employees.containsKey(id); return employees.containsKey(id);
} }
...@@ -482,15 +482,39 @@ public class Model { ...@@ -482,15 +482,39 @@ public class Model {
if (dayOfTheWeek < 0 || dayOfTheWeek > 8){ if (dayOfTheWeek < 0 || dayOfTheWeek > 8){
return "Invalid day"; return "Invalid day";
} }
if (start < 0 || end < 0 || start > 2359 || end > 2359){ if (end < start){
return "End must be after start";
}
if (start < 0 || end < 0 || start > 2400 || end > 2400){
return "Invalid start or end time"; return "Invalid start or end time";
} }
if (this.employees.containsKey(employeeID)) { if (this.employees.containsKey(employeeID)) {
writer.println("editAvailability/" + employeeID + "/" + dayOfTheWeek + "/" + start + "/" + end); writer.println("editAvailability/" + employeeID + "/" + dayOfTheWeek + "/" + start + "/" + end);
editLocalAvailability(employeeID, dayOfTheWeek, start, end);
notifySubscribers();
return "Availability changed successfully";
} }
return "Employee does not exist"; return "Employee does not exist";
} }
private void editLocalAvailability(int employeeID, int dayOfTheWeek, int start, int end){
employees.get(employeeID).updateAvailability(dayOfTheWeek, intToLocalTime(start), intToLocalTime(end));
}
public LocalTime intToLocalTime(int time){
String resultString;
String sub = "0000";
String timeString = String.valueOf(time);
if (timeString.length() < 4){
resultString = sub.substring(0, 4-timeString.length()) + timeString;
} else {
resultString = timeString;
}
DateTimeFormatter dbTimeFormat = DateTimeFormatter.ofPattern("kkmm");
LocalTime result = LocalTime.parse(resultString, dbTimeFormat);
return result;
}
//"YYYY-MM-DD" //"YYYY-MM-DD"
String addTimeOff(int employeeID, String startDate, String endDate, String reason) { String addTimeOff(int employeeID, String startDate, String endDate, String reason) {
if (employeeID <= 0){ if (employeeID <= 0){
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<HBox prefHeight="25.0" prefWidth="800.0"> <HBox prefHeight="25.0" prefWidth="800.0">
<children> <children>
<Button mnemonicParsing="false" onMouseClicked="#prevButtonClicked" prefHeight="25.0" prefWidth="200.0" text="Previous" /> <Button mnemonicParsing="false" onMouseClicked="#prevButtonClicked" prefHeight="25.0" prefWidth="200.0" text="Previous" />
<Label fx:id="currentDateText" prefHeight="25.0" prefWidth="200.0" text="Current: " /> <Label fx:id="currentDateTextAvail" prefHeight="25.0" prefWidth="200.0" text="Current: " />
<Button mnemonicParsing="false" onMouseClicked="#jumpButtonClicked" prefHeight="25.0" prefWidth="200.0" text="Jump" /> <Button mnemonicParsing="false" onMouseClicked="#jumpButtonClicked" prefHeight="25.0" prefWidth="200.0" text="Jump" />
<Button mnemonicParsing="false" onMouseClicked="#nextButtonClicked" prefHeight="25.0" prefWidth="200.0" text="Next" /> <Button mnemonicParsing="false" onMouseClicked="#nextButtonClicked" prefHeight="25.0" prefWidth="200.0" text="Next" />
</children> </children>
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<HBox prefHeight="100.0" prefWidth="200.0"> <HBox prefHeight="100.0" prefWidth="200.0">
<children> <children>
<Label prefWidth="60.0" text="Day" /> <Label prefWidth="60.0" text="Day" />
<ComboBox fx:id="AvailabilityDayBox" onMouseClicked="#populateDaysOfWeek" prefHeight="26.0" prefWidth="150.0" /> <ComboBox fx:id="availabilityDayBox" onMouseClicked="#populateDaysOfWeek" prefHeight="26.0" prefWidth="150.0" />
</children> </children>
</HBox> </HBox>
<HBox prefHeight="100.0" prefWidth="200.0"> <HBox prefHeight="100.0" prefWidth="200.0">
...@@ -21,13 +21,13 @@ ...@@ -21,13 +21,13 @@
<HBox prefHeight="94.0" prefWidth="256.0"> <HBox prefHeight="94.0" prefWidth="256.0">
<children> <children>
<Label prefWidth="60.0" text="Start Time" /> <Label prefWidth="60.0" text="Start Time" />
<ComboBox fx:id="editAvailabilityStartBox" onMouseClicked="#addShiftTimeBoxClicked" prefHeight="26.0" prefWidth="150.0" /> <ComboBox fx:id="editAvailabilityStartBox" onMouseClicked="#availabilityTimeBoxClicked" prefHeight="26.0" prefWidth="150.0" />
</children> </children>
</HBox> </HBox>
<HBox prefHeight="100.0" prefWidth="200.0"> <HBox prefHeight="100.0" prefWidth="200.0">
<children> <children>
<Label prefWidth="60.0" text="End Time" /> <Label prefWidth="60.0" text="End Time" />
<ComboBox fx:id="editAvailabilityEndBox" onMouseClicked="#addShiftTimeBoxClicked" prefWidth="150.0" /> <ComboBox fx:id="editAvailabilityEndBox" onMouseClicked="#availabilityTimeBoxClicked" prefWidth="150.0" />
</children> </children>
</HBox> </HBox>
</children> </children>
...@@ -39,6 +39,9 @@ ...@@ -39,6 +39,9 @@
<right> <right>
<Button fx:id="cancelButton" mnemonicParsing="false" onMouseClicked="#cancelClicked" text="Cancel" BorderPane.alignment="CENTER" /> <Button fx:id="cancelButton" mnemonicParsing="false" onMouseClicked="#cancelClicked" text="Cancel" BorderPane.alignment="CENTER" />
</right> </right>
<top>
<Label fx:id="availabilityResult" BorderPane.alignment="CENTER" />
</top>
</BorderPane> </BorderPane>
</children> </children>
<opaqueInsets> <opaqueInsets>
......
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
<VBox minHeight="-Infinity" minWidth="-Infinity" prefHeight="540.0" prefWidth="100.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" > <VBox minHeight="-Infinity" minWidth="-Infinity" prefHeight="540.0" prefWidth="100.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" >
<children> <children>
<Button maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onMouseClicked="#staffManagerClicked" prefHeight="135.0" prefWidth="100.0" text="Add Employee" textAlignment="CENTER" wrapText="true" /> <Button maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onMouseClicked="#viewAddEmployee" prefHeight="135.0" prefWidth="100.0" text="Add Employee" textAlignment="CENTER" wrapText="true" />
<Button maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onMouseClicked="#viewEditEmployee" prefHeight="135.0" prefWidth="100.0" text="Edit Employee" textAlignment="CENTER" wrapText="true" /> <Button maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onMouseClicked="#viewEditEmployee" prefHeight="135.0" prefWidth="100.0" text="Edit Employee" textAlignment="CENTER" wrapText="true" />
<Button alignment="CENTER" contentDisplay="CENTER" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onMouseClicked="#removeStaffSidePanelClicked" prefHeight="135.0" prefWidth="100.0" text="Remove Employee" textAlignment="CENTER" wrapText="true" /> <Button alignment="CENTER" contentDisplay="CENTER" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onMouseClicked="#viewRemoveEmployee" prefHeight="135.0" prefWidth="100.0" text="Remove Employee" textAlignment="CENTER" wrapText="true" />
<Button maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onMouseClicked="#viewStaff" prefHeight="135.0" prefWidth="100.0" text="View Employees" textAlignment="CENTER" wrapText="true" /> <Button maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" mnemonicParsing="false" onMouseClicked="#viewViewEmployees" prefHeight="135.0" prefWidth="100.0" text="View Employees" textAlignment="CENTER" wrapText="true" />
</children> </children>
</VBox> </VBox>
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