First attempts at filter + view.

This commit is contained in:
James Cole committed 2026-09-28 18:33:14 +02:00
1 parent 8d2ed34c54
commit 9705ee76e8
5 files changed
+126 -2

No files matched your search

@@ -0,0 +1,75 @@
<?php
/*
* QueryRequest.php
* Copyright (c) 2026 james@firefly-iii.org
*
* 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 [];
}
}
@@ -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,
+43
View File
@@ -0,0 +1,43 @@
<?php
/*
* IsValidFilterInstructions.php
* Copyright (c) 2026 james@firefly-iii.org
*
* 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.
}
}
@@ -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');
@@ -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"));