Skip to content

Firefly III: a personal finances manager

First attempts at filter + view.

James Cole9705ee76e891
diff --git a/app/Api/V1/Requests/Generic/FilterRequest.php b/app/Api/V1/Requests/Generic/FilterRequest.php
new file mode 100644
index 0000000000..89a6c95efd
--- /dev/null
+++ b/app/Api/V1/Requests/Generic/FilterRequest.php
@@ -0,0 +1,75 @@
+<?php
+
+/*
+ * QueryRequest.php
+ * Copyright (c) 2026 [email protected]
+ *
+ * This file is part of Firefly III (https://github.com/firefly-iii).
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+declare(strict_types=1);
+
+namespace FireflyIII\Api\V1\Requests\Generic;
+
+use FireflyIII\Api\V1\Requests\ApiRequest;
+use FireflyIII\Rules\IsValidFilterInstruction;
+use FireflyIII\Rules\IsValidSortInstruction;
+use FireflyIII\Support\Request\ChecksLogin;
+use FireflyIII\Support\Request\ConvertsDataTypes;
+use Illuminate\Contracts\Validation\Validator;
+use RuntimeException;
+
+class FilterRequest extends ApiRequest
+{
+ use ChecksLogin;
+ use ConvertsDataTypes;
+ private ?string $filterClass = null;
+
+ public function handleConfig(array $config): void
+ {
+ parent::handleConfig($config);
+
+ $this->filterClass = $config['filter_class'] ?? null;
+
+ if (null === $this->filterClass) {
+ throw new RuntimeException('FilterRequest requires a filter_class config');
+ }
+ }
+
+ public function rules(): array
+ {
+ return [
+ 'filter.*' => ['min:0','max:255', $this->required, new IsValidFilterInstruction((string) $this->filterClass)],
+ ];
+ }
+
+ public function withValidator(Validator $validator): void
+ {
+ $validator->after(function (Validator $validator): void {
+ if (count($validator->failed()) > 0) {
+ return;
+ }
+ var_dump($this->input('filter'));exit;
+ $filter = $this->convertToFilter();
+ $this->attributes->set('filter', $filter);
+ });
+ }
+ private function convertToFilter(string $value): array {
+ var_dump($value);
+ exit;
+ return [];
+ }
+}
diff --git a/app/Api/V1/Requests/Models/Account/ShowRequest.php b/app/Api/V1/Requests/Models/Account/ShowRequest.php
index f303c645de..e5b8c26d4f 100644
--- a/app/Api/V1/Requests/Models/Account/ShowRequest.php
+++ b/app/Api/V1/Requests/Models/Account/ShowRequest.php
@@ -28,6 +28,7 @@ use FireflyIII\Api\V1\Requests\AggregateFormRequest;
use FireflyIII\Api\V1\Requests\DateRangeRequest;
use FireflyIII\Api\V1\Requests\DateRequest;
use FireflyIII\Api\V1\Requests\Generic\ActiveObjectRequest;
+use FireflyIII\Api\V1\Requests\Generic\FilterRequest;
use FireflyIII\Api\V1\Requests\PaginationRequest;
use FireflyIII\Models\Account;
@@ -37,6 +38,7 @@ class ShowRequest extends AggregateFormRequest
{
return [
[PaginationRequest::class, 'sort_class' => Account::class],
+ [FilterRequest::class, 'filter_class' => Account::class],
DateRangeRequest::class,
ActiveObjectRequest::class,
DateRequest::class,
diff --git a/app/Rules/IsValidFilterInstruction.php b/app/Rules/IsValidFilterInstruction.php
new file mode 100644
index 0000000000..5fc32153ab
--- /dev/null
+++ b/app/Rules/IsValidFilterInstruction.php
@@ -0,0 +1,43 @@
+<?php
+/*
+ * IsValidFilterInstructions.php
+ * Copyright (c) 2026 [email protected]
+ *
+ * This file is part of Firefly III (https://github.com/firefly-iii).
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
+ */
+
+namespace FireflyIII\Rules;
+
+use Closure;
+use Illuminate\Contracts\Validation\ValidationRule;
+
+class IsValidFilterInstruction implements ValidationRule
+{
+ public function __construct(
+ private readonly string $class
+ ) {}
+
+ #[\Override]
+ public function validate(string $attribute, mixed $value, Closure $fail): void
+ {
+ if('' === (string)$value) {
+ return;
+ }
+ var_dump($attribute);
+ var_dump($value);
+ // TODO: Implement validate() method.
+ }
+}
diff --git a/resources/assets/v3/js/pages/accounts/index.js b/resources/assets/v3/js/pages/accounts/index.js
index c64c223626..33bec441d2 100644
--- a/resources/assets/v3/js/pages/accounts/index.js
+++ b/resources/assets/v3/js/pages/accounts/index.js
@@ -124,7 +124,7 @@ let index = function () {
// hide search again
document.querySelectorAll("table.sortable .hide-button").forEach((el) => {
- el.addEventListener("click", (event) => {
+ el.addEventListener("click", () => {
let column = el.dataset.column;
// show search input again
document.querySelector(`span.title[data-column="${column}"]`).classList.remove('d-none');
@@ -141,7 +141,7 @@ let index = function () {
// add filterable click events.
document.querySelectorAll("table.sortable .search-button").forEach((el) => {
- el.addEventListener("click", (event) => {
+ el.addEventListener("click", () => {
let column = el.dataset.column;
// hide search buttons etc.
el.classList.add('d-none');
diff --git a/resources/assets/v3/js/pages/dashboard/dashboard.js b/resources/assets/v3/js/pages/dashboard/dashboard.js
index 934f8ecfcf..55f262d033 100644
--- a/resources/assets/v3/js/pages/dashboard/dashboard.js
+++ b/resources/assets/v3/js/pages/dashboard/dashboard.js
@@ -35,6 +35,10 @@ let index = function () {
anonymous: false,
loadingPiggyBanks: true,
init() {
+
+ console.log('I am translation');
+ console.log(i18next.t(format(new Date(), "d MMMM yyyy 'o' HH:mm")));
+
getVariable("anonymous").then((value) => {
let start = new Date(window.store.get("start"));
let end = new Date(window.store.get("end"));