Refine GUI Behavior
This commit is contained in:
@@ -263,7 +263,20 @@ public class AppointmentController {
|
|||||||
response.getEmployeeName() != null ? response.getEmployeeName() : "",
|
response.getEmployeeName() != null ? response.getEmployeeName() : "",
|
||||||
response.getAppointmentDate() != null ? response.getAppointmentDate().toString() : "",
|
response.getAppointmentDate() != null ? response.getAppointmentDate().toString() : "",
|
||||||
response.getAppointmentTime() != null ? response.getAppointmentTime().toString() : "",
|
response.getAppointmentTime() != null ? response.getAppointmentTime().toString() : "",
|
||||||
response.getAppointmentStatus() != null ? response.getAppointmentStatus() : ""
|
normalizeAppointmentStatus(response.getAppointmentStatus())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String normalizeAppointmentStatus(String status) {
|
||||||
|
if (status == null) {
|
||||||
|
return "Booked";
|
||||||
|
}
|
||||||
|
return switch (status.trim().toLowerCase()) {
|
||||||
|
case "booked" -> "Booked";
|
||||||
|
case "completed" -> "Completed";
|
||||||
|
case "missed" -> "Missed";
|
||||||
|
case "cancelled", "canceled" -> "Cancelled";
|
||||||
|
default -> "Booked";
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import javafx.scene.Scene;
|
|||||||
import javafx.scene.control.Alert;
|
import javafx.scene.control.Alert;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.ComboBox;
|
import javafx.scene.control.ComboBox;
|
||||||
|
import javafx.scene.control.TableCell;
|
||||||
import javafx.scene.control.Label;
|
import javafx.scene.control.Label;
|
||||||
import javafx.scene.control.SelectionMode;
|
import javafx.scene.control.SelectionMode;
|
||||||
import javafx.scene.control.Spinner;
|
import javafx.scene.control.Spinner;
|
||||||
@@ -156,6 +157,8 @@ public class SaleController {
|
|||||||
colCartQty.setCellValueFactory(new PropertyValueFactory<>("quantity"));
|
colCartQty.setCellValueFactory(new PropertyValueFactory<>("quantity"));
|
||||||
colCartUnitPrice.setCellValueFactory(new PropertyValueFactory<>("unitPrice"));
|
colCartUnitPrice.setCellValueFactory(new PropertyValueFactory<>("unitPrice"));
|
||||||
colCartTotal.setCellValueFactory(new PropertyValueFactory<>("total"));
|
colCartTotal.setCellValueFactory(new PropertyValueFactory<>("total"));
|
||||||
|
colCartUnitPrice.setCellFactory(column -> currencyCell());
|
||||||
|
colCartTotal.setCellFactory(column -> currencyCell());
|
||||||
tvCart.setItems(cartItems);
|
tvCart.setItems(cartItems);
|
||||||
tvCart.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
|
tvCart.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
|
||||||
|
|
||||||
@@ -169,6 +172,8 @@ public class SaleController {
|
|||||||
colSaleUnitPrice.setCellValueFactory(new PropertyValueFactory<>("unitPrice"));
|
colSaleUnitPrice.setCellValueFactory(new PropertyValueFactory<>("unitPrice"));
|
||||||
colSaleTotal.setCellValueFactory(new PropertyValueFactory<>("total"));
|
colSaleTotal.setCellValueFactory(new PropertyValueFactory<>("total"));
|
||||||
colSalePaymentType.setCellValueFactory(new PropertyValueFactory<>("paymentMethod"));
|
colSalePaymentType.setCellValueFactory(new PropertyValueFactory<>("paymentMethod"));
|
||||||
|
colSaleUnitPrice.setCellFactory(column -> currencyCell());
|
||||||
|
colSaleTotal.setCellFactory(column -> currencyCell());
|
||||||
|
|
||||||
filteredSales = new FilteredList<>(saleItems, s -> true);
|
filteredSales = new FilteredList<>(saleItems, s -> true);
|
||||||
TableViewSupport.bindSortedItems(tvSales, filteredSales);
|
TableViewSupport.bindSortedItems(tvSales, filteredSales);
|
||||||
@@ -539,6 +544,20 @@ public class SaleController {
|
|||||||
lblCartTotal.setText(currency.format(total));
|
lblCartTotal.setText(currency.format(total));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private <S> TableCell<S, Double> currencyCell() {
|
||||||
|
return new TableCell<>() {
|
||||||
|
@Override
|
||||||
|
protected void updateItem(Double value, boolean empty) {
|
||||||
|
super.updateItem(value, empty);
|
||||||
|
if (empty || value == null) {
|
||||||
|
setText(null);
|
||||||
|
} else {
|
||||||
|
setText(currency.format(value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
private void setCreateSaleControlsDisabled(boolean disabled) {
|
private void setCreateSaleControlsDisabled(boolean disabled) {
|
||||||
cbProduct.setDisable(disabled);
|
cbProduct.setDisable(disabled);
|
||||||
spQuantity.setDisable(disabled);
|
spQuantity.setDisable(disabled);
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ public class AppointmentDialogController {
|
|||||||
|
|
||||||
private ObservableList<String> statusList =
|
private ObservableList<String> statusList =
|
||||||
FXCollections.observableArrayList(
|
FXCollections.observableArrayList(
|
||||||
"Booked", "Completed", "Cancelled", "Missed"
|
"Booked", "Completed", "Missed", "Cancelled"
|
||||||
);
|
);
|
||||||
|
|
||||||
public void setMode(String mode) {
|
public void setMode(String mode) {
|
||||||
@@ -182,7 +182,7 @@ public class AppointmentDialogController {
|
|||||||
"Parsing appointment date");
|
"Parsing appointment date");
|
||||||
}
|
}
|
||||||
|
|
||||||
cbAppointmentStatus.setValue(appt.getAppointmentStatus());
|
cbAppointmentStatus.setValue(normalizeAppointmentStatus(appt.getAppointmentStatus()));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LocalTime time = LocalTime.parse(appt.getAppointmentTime());
|
LocalTime time = LocalTime.parse(appt.getAppointmentTime());
|
||||||
@@ -230,7 +230,7 @@ public class AppointmentDialogController {
|
|||||||
request.setEmployeeId(cbEmployee.getValue().getId());
|
request.setEmployeeId(cbEmployee.getValue().getId());
|
||||||
request.setAppointmentDate(dpAppointmentDate.getValue());
|
request.setAppointmentDate(dpAppointmentDate.getValue());
|
||||||
request.setAppointmentTime(appointmentTime);
|
request.setAppointmentTime(appointmentTime);
|
||||||
request.setAppointmentStatus(cbAppointmentStatus.getValue());
|
request.setAppointmentStatus(normalizeAppointmentStatus(cbAppointmentStatus.getValue()));
|
||||||
|
|
||||||
new Thread(() -> {
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
@@ -451,4 +451,17 @@ public class AppointmentDialogController {
|
|||||||
}
|
}
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String normalizeAppointmentStatus(String status) {
|
||||||
|
if (status == null) {
|
||||||
|
return "Booked";
|
||||||
|
}
|
||||||
|
return switch (status.trim().toLowerCase()) {
|
||||||
|
case "booked" -> "Booked";
|
||||||
|
case "completed" -> "Completed";
|
||||||
|
case "missed" -> "Missed";
|
||||||
|
case "cancelled", "canceled" -> "Cancelled";
|
||||||
|
default -> "Booked";
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,11 +32,9 @@ public final class TableViewSupport {
|
|||||||
}
|
}
|
||||||
label.setText(message);
|
label.setText(message);
|
||||||
label.setVisible(true);
|
label.setVisible(true);
|
||||||
label.setManaged(true);
|
|
||||||
PauseTransition delay = new PauseTransition(Duration.seconds(1.5));
|
PauseTransition delay = new PauseTransition(Duration.seconds(1.5));
|
||||||
delay.setOnFinished(event -> {
|
delay.setOnFinished(event -> {
|
||||||
label.setVisible(false);
|
label.setVisible(false);
|
||||||
label.setManaged(false);
|
|
||||||
});
|
});
|
||||||
delay.playFromStart();
|
delay.playFromStart();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@
|
|||||||
</TextField>
|
</TextField>
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
<Label fx:id="lblStatus" text="" textFill="#64748b" visible="false" managed="false">
|
<Label fx:id="lblStatus" text="" textFill="#64748b" visible="false" managed="true">
|
||||||
<font>
|
<font>
|
||||||
<Font size="13.0" />
|
<Font size="13.0" />
|
||||||
</font>
|
</font>
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</HBox>
|
</HBox>
|
||||||
|
|
||||||
<Label fx:id="lblStatus" textFill="#64748b" visible="false">
|
<Label fx:id="lblStatus" textFill="#64748b" visible="false" managed="true">
|
||||||
<font>
|
<font>
|
||||||
<Font size="13.0" />
|
<Font size="13.0" />
|
||||||
</font>
|
</font>
|
||||||
|
|||||||
@@ -73,7 +73,7 @@
|
|||||||
</TextField>
|
</TextField>
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
<Label fx:id="lblStatus" text="" textFill="#64748b" visible="false" managed="false">
|
<Label fx:id="lblStatus" text="" textFill="#64748b" visible="false" managed="true">
|
||||||
<font>
|
<font>
|
||||||
<Font size="13.0" />
|
<Font size="13.0" />
|
||||||
</font>
|
</font>
|
||||||
|
|||||||
@@ -73,7 +73,7 @@
|
|||||||
</TextField>
|
</TextField>
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
<Label fx:id="lblStatus" text="" textFill="#64748b" visible="false" managed="false">
|
<Label fx:id="lblStatus" text="" textFill="#64748b" visible="false" managed="true">
|
||||||
<font>
|
<font>
|
||||||
<Font size="13.0" />
|
<Font size="13.0" />
|
||||||
</font>
|
</font>
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
<ComboBox fx:id="cbStatusFilter" prefWidth="150.0" promptText="Status" />
|
<ComboBox fx:id="cbStatusFilter" prefWidth="150.0" promptText="Status" />
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
<Label fx:id="lblStatus" text="" textFill="#64748b" visible="false" managed="false">
|
<Label fx:id="lblStatus" text="" textFill="#64748b" visible="false" managed="true">
|
||||||
<font>
|
<font>
|
||||||
<Font size="13.0" />
|
<Font size="13.0" />
|
||||||
</font>
|
</font>
|
||||||
|
|||||||
@@ -73,7 +73,7 @@
|
|||||||
</TextField>
|
</TextField>
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
<Label fx:id="lblStatus" text="" textFill="#64748b" visible="false" managed="false">
|
<Label fx:id="lblStatus" text="" textFill="#64748b" visible="false" managed="true">
|
||||||
<font>
|
<font>
|
||||||
<Font size="13.0" />
|
<Font size="13.0" />
|
||||||
</font>
|
</font>
|
||||||
|
|||||||
@@ -75,7 +75,7 @@
|
|||||||
<ComboBox fx:id="cbCategoryFilter" prefWidth="180.0" promptText="Category" />
|
<ComboBox fx:id="cbCategoryFilter" prefWidth="180.0" promptText="Category" />
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
<Label fx:id="lblStatus" text="" textFill="#64748b" visible="false" managed="false">
|
<Label fx:id="lblStatus" text="" textFill="#64748b" visible="false" managed="true">
|
||||||
<font>
|
<font>
|
||||||
<Font size="13.0" />
|
<Font size="13.0" />
|
||||||
</font>
|
</font>
|
||||||
|
|||||||
@@ -55,7 +55,7 @@
|
|||||||
</HBox>
|
</HBox>
|
||||||
|
|
||||||
<!-- TABLE -->
|
<!-- TABLE -->
|
||||||
<Label fx:id="lblStatus" text="" textFill="#64748b" visible="false" managed="false">
|
<Label fx:id="lblStatus" text="" textFill="#64748b" visible="false" managed="true">
|
||||||
<font>
|
<font>
|
||||||
<Font size="13.0" />
|
<Font size="13.0" />
|
||||||
</font>
|
</font>
|
||||||
|
|||||||
@@ -89,7 +89,7 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
<Label fx:id="lblStatus" text="" textFill="#64748b" visible="false" managed="false">
|
<Label fx:id="lblStatus" text="" textFill="#64748b" visible="false" managed="true">
|
||||||
<font>
|
<font>
|
||||||
<Font size="13.0" />
|
<Font size="13.0" />
|
||||||
</font>
|
</font>
|
||||||
@@ -156,16 +156,16 @@
|
|||||||
</TextField>
|
</TextField>
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
<TableView fx:id="tvSales" prefHeight="362.0" style="-fx-background-color: white; -fx-background-radius: 12; -fx-padding: 6;" VBox.vgrow="ALWAYS">
|
<TableView fx:id="tvSales" prefHeight="362.0" style="-fx-background-color: white; -fx-background-radius: 12; -fx-padding: 6;" VBox.vgrow="ALWAYS">
|
||||||
<columns>
|
<columns>
|
||||||
<TableColumn fx:id="colSaleId" minWidth="54.0" prefWidth="62.0" text="ID" />
|
<TableColumn fx:id="colSaleId" minWidth="48.0" prefWidth="52.0" text="ID" />
|
||||||
<TableColumn fx:id="colSaleDate" minWidth="145.0" prefWidth="165.0" text="Date" />
|
<TableColumn fx:id="colSaleDate" minWidth="115.0" prefWidth="140.0" text="Date" />
|
||||||
<TableColumn fx:id="colEmployeeName" minWidth="130.0" prefWidth="155.0" text="Employee" />
|
<TableColumn fx:id="colEmployeeName" minWidth="100.0" prefWidth="130.0" text="Employee" />
|
||||||
<TableColumn fx:id="colServiceProduct" minWidth="180.0" prefWidth="240.0" text="Product" />
|
<TableColumn fx:id="colServiceProduct" minWidth="140.0" prefWidth="210.0" text="Product" />
|
||||||
<TableColumn fx:id="colSaleQuantity" minWidth="62.0" prefWidth="72.0" text="Qty" />
|
<TableColumn fx:id="colSaleQuantity" minWidth="48.0" prefWidth="58.0" text="Qty" />
|
||||||
<TableColumn fx:id="colSaleUnitPrice" minWidth="95.0" prefWidth="115.0" text="Unit Price" />
|
<TableColumn fx:id="colSaleUnitPrice" minWidth="75.0" prefWidth="92.0" text="Unit Price" />
|
||||||
<TableColumn fx:id="colSaleTotal" minWidth="90.0" prefWidth="108.0" text="Total" />
|
<TableColumn fx:id="colSaleTotal" minWidth="78.0" prefWidth="96.0" text="Total" />
|
||||||
<TableColumn fx:id="colSalePaymentType" minWidth="88.0" prefWidth="100.0" text="Payment" />
|
<TableColumn fx:id="colSalePaymentType" minWidth="76.0" prefWidth="90.0" text="Payment" />
|
||||||
</columns>
|
</columns>
|
||||||
</TableView>
|
</TableView>
|
||||||
</children>
|
</children>
|
||||||
|
|||||||
@@ -73,7 +73,7 @@
|
|||||||
</TextField>
|
</TextField>
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
<Label fx:id="lblStatus" text="" textFill="#64748b" visible="false" managed="false">
|
<Label fx:id="lblStatus" text="" textFill="#64748b" visible="false" managed="true">
|
||||||
<font>
|
<font>
|
||||||
<Font size="13.0" />
|
<Font size="13.0" />
|
||||||
</font>
|
</font>
|
||||||
|
|||||||
@@ -77,7 +77,7 @@
|
|||||||
</TableView>
|
</TableView>
|
||||||
|
|
||||||
|
|
||||||
<Label fx:id="lblStatus" text="" textFill="#64748b" visible="false" managed="false">
|
<Label fx:id="lblStatus" text="" textFill="#64748b" visible="false" managed="true">
|
||||||
<font>
|
<font>
|
||||||
<Font size="13.0" />
|
<Font size="13.0" />
|
||||||
</font>
|
</font>
|
||||||
|
|||||||
@@ -73,7 +73,7 @@
|
|||||||
</TextField>
|
</TextField>
|
||||||
</children>
|
</children>
|
||||||
</HBox>
|
</HBox>
|
||||||
<Label fx:id="lblStatus" text="" textFill="#64748b" visible="false" managed="false">
|
<Label fx:id="lblStatus" text="" textFill="#64748b" visible="false" managed="true">
|
||||||
<font>
|
<font>
|
||||||
<Font size="13.0" />
|
<Font size="13.0" />
|
||||||
</font>
|
</font>
|
||||||
|
|||||||
Reference in New Issue
Block a user