Compare commits

...

5 Commits

Author SHA1 Message Date
f11d155606 fix filter 2024-12-27 14:55:06 +03:00
557fa1e22b fix filter 2024-12-27 14:50:28 +03:00
33d7069708 param => params fix 2024-12-27 12:28:49 +03:00
8063ec0735 filter fix 2024-12-23 16:30:18 +03:00
d7e9e06925 fix filter submit button 2024-12-23 15:24:15 +03:00
2 changed files with 12 additions and 6 deletions

View File

@ -5,12 +5,12 @@ namespace Itguild\Tables\Filter;
abstract class Filter
{
public string $html = '';
public string|array $param;
public string|array $params;
public string $name;
public string $value;
public function __construct(array $source)
{
$this->param = $source['param'] ?? '';
$this->params = $source['params'] ?? '';
$this->name = $source['name'];
$this->value = $source['value'] ?? '';
}

View File

@ -9,6 +9,7 @@ use Itguild\Tables\ActionColumn\ViewActionColumn;
use Itguild\Tables\Filter\InputTextFilter;
use Itguild\Tables\traits\CreateParams;
use JetBrains\PhpStorm\NoReturn;
use kernel\helpers\Debug;
class ListJsonTable extends JasonTable
{
@ -18,6 +19,7 @@ class ListJsonTable extends JasonTable
private int $count = 0;
private string $baseUrl;
private string $searchPrefix;
private array $data;
private bool $pagination = true;
@ -35,6 +37,7 @@ class ListJsonTable extends JasonTable
$this->json = $json;
$this->data = json_decode($this->json, true);
$this->baseUrl = $this->data['meta']['baseUrl'] ?? '';
$this->searchPrefix = $this->data['meta']['searchPrefix'] ?? '/search';
$this->pagination = $this->data['meta']['pagination'] ?? true;
$this->showActionColumn = $this->data['meta']['showActionColumn'] ?? true;
$this->showFiltersRow = $this->data['meta']['showFiltersRow'] ?? true;
@ -73,8 +76,8 @@ class ListJsonTable extends JasonTable
}
if ($this->showFiltersRow) {
$this->getFilters($columnKeys);
$this->html .= "</thead>";
}
$this->html .= "</thead>";
}
public function createTbody(): void
@ -270,12 +273,14 @@ class ListJsonTable extends JasonTable
private function getFilters(array $columnKeys): void
{
$this->html .= "<tr><form action='$this->baseUrl/search'>";
$this->html .= "<tr><form action='$this->baseUrl$this->searchPrefix'>";
$flag = false;
foreach ($columnKeys as $key) {
if ($this->issetFilter($key)) {
$flag = true;
$filter = $this->getCurrentFilter($key);
$params = [
'param' => $filter['param'] ?? '',
'params' => $filter['params'] ?? '',
'name' => $key,
'value' => $filter['value'] ?? '',
];
@ -290,7 +295,8 @@ class ListJsonTable extends JasonTable
$this->html .= "<td></td>";
}
}
if ($this->showActionColumn) {
if ($flag) {
$this->showActionColumn = true;
$this->html .= "<td><input class='btn btn-primary' type='submit' style='width: 150px' value='Применить'></td>";
}
$this->html .= "</form></tr>";