diff --git a/pom.xml b/pom.xml index e1490f2..804980a 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.andrewlalis perfin - 1.1.0 + 1.2.0 21 diff --git a/scripts/package-linux-deb.sh b/scripts/package-linux-deb.sh index 05a4d83..7f46cd2 100755 --- a/scripts/package-linux-deb.sh +++ b/scripts/package-linux-deb.sh @@ -24,7 +24,7 @@ module_path="$module_path:target/modules/h2-2.2.224.jar" jpackage \ --name "Perfin" \ - --app-version "1.1.0" \ + --app-version "1.2.0" \ --description "Desktop application for personal finance. Add your accounts, track transactions, and store receipts, invoices, and more." \ --icon design/perfin-logo_256.png \ --vendor "Andrew Lalis" \ diff --git a/scripts/package-windows-msi.ps1 b/scripts/package-windows-msi.ps1 index 6916a20..69d496b 100644 --- a/scripts/package-windows-msi.ps1 +++ b/scripts/package-windows-msi.ps1 @@ -12,7 +12,7 @@ $modulePath = "$modulePath;target\modules\h2-2.2.224.jar" jpackage ` --name "Perfin" ` - --app-version "1.1.0" ` + --app-version "1.2.0" ` --description "Desktop application for personal finance. Add your accounts, track transactions, and store receipts, invoices, and more." ` --icon design\perfin-logo_256.ico ` --vendor "Andrew Lalis" ` diff --git a/src/main/java/com/andrewlalis/perfin/control/TransactionsViewController.java b/src/main/java/com/andrewlalis/perfin/control/TransactionsViewController.java index e9eba2c..19a0d58 100644 --- a/src/main/java/com/andrewlalis/perfin/control/TransactionsViewController.java +++ b/src/main/java/com/andrewlalis/perfin/control/TransactionsViewController.java @@ -36,7 +36,6 @@ import static com.andrewlalis.perfin.PerfinApp.router; */ public class TransactionsViewController implements RouteSelectionListener { public static List DEFAULT_SORTS = List.of(Sort.desc("timestamp")); - public static int DEFAULT_ITEMS_PER_PAGE = 5; public record RouteContext(Long selectedTransactionId) {} @FXML public BorderPane transactionsListBorderPane; @@ -119,7 +118,6 @@ public class TransactionsViewController implements RouteSelectionListener { @Override public void onRouteSelected(Object context) { paginationControls.sorts.setAll(DEFAULT_SORTS); - paginationControls.itemsPerPage.set(DEFAULT_ITEMS_PER_PAGE); // Refresh account filter options. Thread.ofVirtual().start(() -> { @@ -142,7 +140,7 @@ public class TransactionsViewController implements RouteSelectionListener { Profile.getCurrent().getDataSource().useTransactionRepository(repo -> { repo.findById(ctx.selectedTransactionId).ifPresent(tx -> { long offset = repo.countAllAfter(tx.id); - int pageNumber = (int) (offset / DEFAULT_ITEMS_PER_PAGE) + 1; + int pageNumber = (int) (offset / paginationControls.getItemsPerPage()) + 1; paginationControls.setPage(pageNumber).thenRun(() -> selectedTransaction.set(tx)); }); }); diff --git a/src/main/java/com/andrewlalis/perfin/view/component/DataSourcePaginationControls.java b/src/main/java/com/andrewlalis/perfin/view/component/DataSourcePaginationControls.java index 74ad29f..2c672b2 100644 --- a/src/main/java/com/andrewlalis/perfin/view/component/DataSourcePaginationControls.java +++ b/src/main/java/com/andrewlalis/perfin/view/component/DataSourcePaginationControls.java @@ -10,11 +10,15 @@ import javafx.beans.property.SimpleBooleanProperty; import javafx.beans.property.SimpleIntegerProperty; import javafx.collections.FXCollections; import javafx.collections.ObservableList; +import javafx.geometry.Pos; import javafx.scene.Node; import javafx.scene.control.Button; -import javafx.scene.layout.*; +import javafx.scene.control.ChoiceBox; +import javafx.scene.control.Label; +import javafx.scene.layout.AnchorPane; +import javafx.scene.layout.BorderPane; +import javafx.scene.layout.HBox; import javafx.scene.text.Text; -import javafx.scene.text.TextAlignment; import javafx.scene.text.TextFlow; import java.util.concurrent.CompletableFuture; @@ -34,8 +38,9 @@ public class DataSourcePaginationControls extends BorderPane { public final IntegerProperty currentPage = new SimpleIntegerProperty(1); public final IntegerProperty maxPages = new SimpleIntegerProperty(-1); - public final IntegerProperty itemsPerPage = new SimpleIntegerProperty(5); public final ObservableList sorts = FXCollections.observableArrayList(); + + private final IntegerProperty itemsPerPage = new SimpleIntegerProperty(); private final BooleanProperty fetching = new SimpleBooleanProperty(false); private final ObservableList target; private final PageFetcherFunction fetcher; @@ -46,12 +51,16 @@ public class DataSourcePaginationControls extends BorderPane { Text currentPageLabel = new Text(); currentPageLabel.textProperty().bind(currentPage.asString()); + Text maxPagesLabel = new Text(); maxPagesLabel.textProperty().bind(maxPages.asString()); + TextFlow maxPagesText = new TextFlow(new Text(" / "), maxPagesLabel); maxPagesText.managedProperty().bind(maxPagesText.visibleProperty()); maxPagesText.visibleProperty().bind(maxPages.greaterThan(0)); + TextFlow pageText = new TextFlow(new Text("Page "), currentPageLabel, maxPagesText); + AnchorPane pageTextContainer = new AnchorPane(pageText); AnchorPane.setTopAnchor(pageText, 4.0); AnchorPane.setRightAnchor(pageText, 0.0); @@ -62,14 +71,30 @@ public class DataSourcePaginationControls extends BorderPane { Button previousPageButton = new Button("Previous Page"); previousPageButton.disableProperty().bind(currentPage.lessThan(2).or(fetching)); previousPageButton.setOnAction(event -> setPage(currentPage.get() - 1)); + Button nextPageButton = new Button("Next Page"); nextPageButton.disableProperty().bind(fetching.or(currentPage.greaterThanOrEqualTo(maxPages))); nextPageButton.setOnAction(event -> setPage(currentPage.get() + 1)); + ChoiceBox itemsPerPageChoice = new ChoiceBox<>(); + itemsPerPageChoice.getItems().addAll(5, 10, 20, 50, 100); + itemsPerPageChoice.getSelectionModel().select(10); + itemsPerPageChoice.setValue(10); + itemsPerPage.bind(itemsPerPageChoice.valueProperty()); + itemsPerPage.addListener((observable, oldValue, newValue) -> setPage(1)); + + BorderPane pageSizePane = new BorderPane(); + Label pageSizeLabel = new Label("Items Per Page"); + pageSizeLabel.getStyleClass().add("std-padding"); + BorderPane.setAlignment(pageSizeLabel, Pos.CENTER_LEFT); + pageSizePane.setLeft(pageSizeLabel); + pageSizePane.setCenter(itemsPerPageChoice); + HBox hbox = new HBox( previousPageButton, pageTextContainer, - nextPageButton + nextPageButton, + pageSizePane ); hbox.getStyleClass().addAll("std-padding", "std-spacing"); setCenter(hbox); @@ -107,4 +132,8 @@ public class DataSourcePaginationControls extends BorderPane { }); return cf; } + + public int getItemsPerPage() { + return itemsPerPage.get(); + } } diff --git a/src/main/resources/main-view.fxml b/src/main/resources/main-view.fxml index 07ed13b..e91f01b 100644 --- a/src/main/resources/main-view.fxml +++ b/src/main/resources/main-view.fxml @@ -22,7 +22,7 @@ -