fix filter

This commit is contained in:
Билай Станислав 2024-08-28 15:39:35 +03:00
parent f20f408f12
commit 0960a7b1fd
5 changed files with 52 additions and 22 deletions

View File

@ -2,7 +2,8 @@
require_once "../vendor/autoload.php";
use Itguild\Tables\Filter\InputFilter;
use Itguild\Tables\Filter\InputDateFilter;
use Itguild\Tables\Filter\InputTextFilter;
use Itguild\Tables\Filter\SelectFilter;
use Itguild\Tables\ListJsonTable;
@ -13,16 +14,14 @@ $table->columns([
"created_at" => [
"format" => "date:Y-m-d",
'filter' => [
'class' => InputFilter::class,
'param' => 'date'
'class' => InputDateFilter::class,
]
],
'description' => [
"format" => "html",
"style" => ["width" => "300px"],
"filter" => [
'class' => InputFilter::class,
'param' => 'text',
'class' => InputTextFilter::class,
'value' => 'value'
],
"value" => function ($cell) {
@ -38,7 +37,6 @@ $table->columns([
],
],
'status' => [
"format" => "integer",
"filter" => [
'class' => SelectFilter::class,
'param' => getStatusLabel(),
@ -50,8 +48,8 @@ $table->columns([
'k33' => [
"format" => "integer",
'filter' => [
'class' => InputFilter::class,
'param' => 'range'
'class' => \Itguild\Tables\Filter\InputRangeFilter::class,
'param' => ['min' => 0, 'max' => 10],
]
],
'email' => function ($cell) {

View File

@ -0,0 +1,12 @@
<?php
namespace Itguild\Tables\Filter;
class InputDateFilter extends Filter
{
public function fetch()
{
return "<td><input type='date' name='$this->name' value ='$this->value'></td>";
}
}

View File

@ -1,14 +0,0 @@
<?php
namespace Itguild\Tables\Filter;
use Itguild\Tables\Filter\Filter;
class InputFilter extends Filter
{
public function fetch()
{
return "<td><input type='$this->param' name='$this->name' value ='$this->value'></td>";
}
}

View File

@ -0,0 +1,23 @@
<?php
namespace Itguild\Tables\Filter;
use Itguild\Tables\Filter\Filter;
class InputRangeFilter extends Filter
{
private int $min;
private int $max;
public function __construct(array $source)
{
parent::__construct($source);
$this->min = $this->param['min'] ?? 0;
$this->max = $this->param['max'] ?? 100;
}
public function fetch()
{
return "<td>" . $this->min . " <input type='range' name='$this->name' min= '$this->min' max='$this->max' value ='$this->value'>" . $this->max . "</td>";
}
}

View File

@ -0,0 +1,11 @@
<?php
namespace Itguild\Tables\Filter;
class InputTextFilter extends \Itguild\Tables\Filter\Filter
{
public function fetch()
{
return "<td><input type='text' name='$this->name' value ='$this->value'></td>";
}
}