Merge Table Fixes #161

Merged
RecentRunner merged 10 commits from table-fixes into main 2026-04-09 21:49:18 -06:00
16 changed files with 71 additions and 28 deletions
Showing only changes of commit 1205459e53 - Show all commits

View File

@@ -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";
};
}
}

View File

@@ -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);

View File

@@ -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";
};
}
}

View File

@@ -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();
}

View File

@@ -73,7 +73,7 @@
</TextField>
</children>
</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 size="13.0" />
</font>

View File

@@ -37,7 +37,7 @@
</Button>
</HBox>
<Label fx:id="lblStatus" textFill="#64748b" visible="false">
<Label fx:id="lblStatus" textFill="#64748b" visible="false" managed="true">
<font>
<Font size="13.0" />
</font>

View File

@@ -73,7 +73,7 @@
</TextField>
</children>
</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 size="13.0" />
</font>

View File

@@ -73,7 +73,7 @@
</TextField>
</children>
</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 size="13.0" />
</font>

View File

@@ -77,7 +77,7 @@
<ComboBox fx:id="cbStatusFilter" prefWidth="150.0" promptText="Status" />
</children>
</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 size="13.0" />
</font>

View File

@@ -73,7 +73,7 @@
</TextField>
</children>
</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 size="13.0" />
</font>

View File

@@ -75,7 +75,7 @@
<ComboBox fx:id="cbCategoryFilter" prefWidth="180.0" promptText="Category" />
</children>
</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 size="13.0" />
</font>

View File

@@ -55,7 +55,7 @@
</HBox>
<!-- 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 size="13.0" />
</font>

View File

@@ -89,7 +89,7 @@
</Button>
</children>
</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 size="13.0" />
</font>
@@ -156,16 +156,16 @@
</TextField>
</children>
</HBox>
<TableView fx:id="tvSales" prefHeight="362.0" style="-fx-background-color: white; -fx-background-radius: 12; -fx-padding: 6;" VBox.vgrow="ALWAYS">
<columns>
<TableColumn fx:id="colSaleId" minWidth="54.0" prefWidth="62.0" text="ID" />
<TableColumn fx:id="colSaleDate" minWidth="145.0" prefWidth="165.0" text="Date" />
<TableColumn fx:id="colEmployeeName" minWidth="130.0" prefWidth="155.0" text="Employee" />
<TableColumn fx:id="colServiceProduct" minWidth="180.0" prefWidth="240.0" text="Product" />
<TableColumn fx:id="colSaleQuantity" minWidth="62.0" prefWidth="72.0" text="Qty" />
<TableColumn fx:id="colSaleUnitPrice" minWidth="95.0" prefWidth="115.0" text="Unit Price" />
<TableColumn fx:id="colSaleTotal" minWidth="90.0" prefWidth="108.0" text="Total" />
<TableColumn fx:id="colSalePaymentType" minWidth="88.0" prefWidth="100.0" text="Payment" />
<TableView fx:id="tvSales" prefHeight="362.0" style="-fx-background-color: white; -fx-background-radius: 12; -fx-padding: 6;" VBox.vgrow="ALWAYS">
<columns>
<TableColumn fx:id="colSaleId" minWidth="48.0" prefWidth="52.0" text="ID" />
<TableColumn fx:id="colSaleDate" minWidth="115.0" prefWidth="140.0" text="Date" />
<TableColumn fx:id="colEmployeeName" minWidth="100.0" prefWidth="130.0" text="Employee" />
<TableColumn fx:id="colServiceProduct" minWidth="140.0" prefWidth="210.0" text="Product" />
<TableColumn fx:id="colSaleQuantity" minWidth="48.0" prefWidth="58.0" text="Qty" />
<TableColumn fx:id="colSaleUnitPrice" minWidth="75.0" prefWidth="92.0" text="Unit Price" />
<TableColumn fx:id="colSaleTotal" minWidth="78.0" prefWidth="96.0" text="Total" />
<TableColumn fx:id="colSalePaymentType" minWidth="76.0" prefWidth="90.0" text="Payment" />
</columns>
</TableView>
</children>

View File

@@ -73,7 +73,7 @@
</TextField>
</children>
</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 size="13.0" />
</font>

View File

@@ -77,7 +77,7 @@
</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 size="13.0" />
</font>

View File

@@ -73,7 +73,7 @@
</TextField>
</children>
</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 size="13.0" />
</font>