Set version to 1.2.0, fixed formatting for pagination for the most part.
This commit is contained in:
parent
a94666a8d6
commit
4370d8221f
2
pom.xml
2
pom.xml
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>com.andrewlalis</groupId>
|
||||
<artifactId>perfin</artifactId>
|
||||
<version>1.1.0</version>
|
||||
<version>1.2.0</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>21</maven.compiler.source>
|
||||
|
|
|
@ -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" \
|
||||
|
|
|
@ -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" `
|
||||
|
|
|
@ -36,7 +36,6 @@ import static com.andrewlalis.perfin.PerfinApp.router;
|
|||
*/
|
||||
public class TransactionsViewController implements RouteSelectionListener {
|
||||
public static List<Sort> 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));
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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<Sort> sorts = FXCollections.observableArrayList();
|
||||
|
||||
private final IntegerProperty itemsPerPage = new SimpleIntegerProperty();
|
||||
private final BooleanProperty fetching = new SimpleBooleanProperty(false);
|
||||
private final ObservableList<Node> 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<Integer> 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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
</top>
|
||||
<bottom>
|
||||
<HBox styleClass="std-padding,std-spacing">
|
||||
<Label text="Perfin Version 1.1.0"/>
|
||||
<Label text="Perfin Version 1.2.0"/>
|
||||
</HBox>
|
||||
</bottom>
|
||||
</BorderPane>
|
||||
|
|
Loading…
Reference in New Issue