Refine GUI Behavior
This commit is contained in:
@@ -263,7 +263,20 @@ public class AppointmentController {
|
||||
response.getEmployeeName() != null ? response.getEmployeeName() : "",
|
||||
response.getAppointmentDate() != null ? response.getAppointmentDate().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.Button;
|
||||
import javafx.scene.control.ComboBox;
|
||||
import javafx.scene.control.TableCell;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.control.SelectionMode;
|
||||
import javafx.scene.control.Spinner;
|
||||
@@ -156,6 +157,8 @@ public class SaleController {
|
||||
colCartQty.setCellValueFactory(new PropertyValueFactory<>("quantity"));
|
||||
colCartUnitPrice.setCellValueFactory(new PropertyValueFactory<>("unitPrice"));
|
||||
colCartTotal.setCellValueFactory(new PropertyValueFactory<>("total"));
|
||||
colCartUnitPrice.setCellFactory(column -> currencyCell());
|
||||
colCartTotal.setCellFactory(column -> currencyCell());
|
||||
tvCart.setItems(cartItems);
|
||||
tvCart.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
|
||||
|
||||
@@ -169,6 +172,8 @@ public class SaleController {
|
||||
colSaleUnitPrice.setCellValueFactory(new PropertyValueFactory<>("unitPrice"));
|
||||
colSaleTotal.setCellValueFactory(new PropertyValueFactory<>("total"));
|
||||
colSalePaymentType.setCellValueFactory(new PropertyValueFactory<>("paymentMethod"));
|
||||
colSaleUnitPrice.setCellFactory(column -> currencyCell());
|
||||
colSaleTotal.setCellFactory(column -> currencyCell());
|
||||
|
||||
filteredSales = new FilteredList<>(saleItems, s -> true);
|
||||
TableViewSupport.bindSortedItems(tvSales, filteredSales);
|
||||
@@ -539,6 +544,20 @@ public class SaleController {
|
||||
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) {
|
||||
cbProduct.setDisable(disabled);
|
||||
spQuantity.setDisable(disabled);
|
||||
|
||||
@@ -49,7 +49,7 @@ public class AppointmentDialogController {
|
||||
|
||||
private ObservableList<String> statusList =
|
||||
FXCollections.observableArrayList(
|
||||
"Booked", "Completed", "Cancelled", "Missed"
|
||||
"Booked", "Completed", "Missed", "Cancelled"
|
||||
);
|
||||
|
||||
public void setMode(String mode) {
|
||||
@@ -182,7 +182,7 @@ public class AppointmentDialogController {
|
||||
"Parsing appointment date");
|
||||
}
|
||||
|
||||
cbAppointmentStatus.setValue(appt.getAppointmentStatus());
|
||||
cbAppointmentStatus.setValue(normalizeAppointmentStatus(appt.getAppointmentStatus()));
|
||||
|
||||
try {
|
||||
LocalTime time = LocalTime.parse(appt.getAppointmentTime());
|
||||
@@ -230,7 +230,7 @@ public class AppointmentDialogController {
|
||||
request.setEmployeeId(cbEmployee.getValue().getId());
|
||||
request.setAppointmentDate(dpAppointmentDate.getValue());
|
||||
request.setAppointmentTime(appointmentTime);
|
||||
request.setAppointmentStatus(cbAppointmentStatus.getValue());
|
||||
request.setAppointmentStatus(normalizeAppointmentStatus(cbAppointmentStatus.getValue()));
|
||||
|
||||
new Thread(() -> {
|
||||
try {
|
||||
@@ -451,4 +451,17 @@ public class AppointmentDialogController {
|
||||
}
|
||||
}).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.setVisible(true);
|
||||
label.setManaged(true);
|
||||
PauseTransition delay = new PauseTransition(Duration.seconds(1.5));
|
||||
delay.setOnFinished(event -> {
|
||||
label.setVisible(false);
|
||||
label.setManaged(false);
|
||||
});
|
||||
delay.playFromStart();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user