fix filter
This commit is contained in:
parent
f20f408f12
commit
0960a7b1fd
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
require_once "../vendor/autoload.php";
|
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\Filter\SelectFilter;
|
||||||
use Itguild\Tables\ListJsonTable;
|
use Itguild\Tables\ListJsonTable;
|
||||||
|
|
||||||
@ -13,16 +14,14 @@ $table->columns([
|
|||||||
"created_at" => [
|
"created_at" => [
|
||||||
"format" => "date:Y-m-d",
|
"format" => "date:Y-m-d",
|
||||||
'filter' => [
|
'filter' => [
|
||||||
'class' => InputFilter::class,
|
'class' => InputDateFilter::class,
|
||||||
'param' => 'date'
|
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'description' => [
|
'description' => [
|
||||||
"format" => "html",
|
"format" => "html",
|
||||||
"style" => ["width" => "300px"],
|
"style" => ["width" => "300px"],
|
||||||
"filter" => [
|
"filter" => [
|
||||||
'class' => InputFilter::class,
|
'class' => InputTextFilter::class,
|
||||||
'param' => 'text',
|
|
||||||
'value' => 'value'
|
'value' => 'value'
|
||||||
],
|
],
|
||||||
"value" => function ($cell) {
|
"value" => function ($cell) {
|
||||||
@ -38,7 +37,6 @@ $table->columns([
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
'status' => [
|
'status' => [
|
||||||
"format" => "integer",
|
|
||||||
"filter" => [
|
"filter" => [
|
||||||
'class' => SelectFilter::class,
|
'class' => SelectFilter::class,
|
||||||
'param' => getStatusLabel(),
|
'param' => getStatusLabel(),
|
||||||
@ -50,8 +48,8 @@ $table->columns([
|
|||||||
'k33' => [
|
'k33' => [
|
||||||
"format" => "integer",
|
"format" => "integer",
|
||||||
'filter' => [
|
'filter' => [
|
||||||
'class' => InputFilter::class,
|
'class' => \Itguild\Tables\Filter\InputRangeFilter::class,
|
||||||
'param' => 'range'
|
'param' => ['min' => 0, 'max' => 10],
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'email' => function ($cell) {
|
'email' => function ($cell) {
|
||||||
|
12
src/Filter/InputDateFilter.php
Normal file
12
src/Filter/InputDateFilter.php
Normal 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>";
|
||||||
|
}
|
||||||
|
}
|
@ -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>";
|
|
||||||
}
|
|
||||||
}
|
|
23
src/Filter/InputRangeFilter.php
Normal file
23
src/Filter/InputRangeFilter.php
Normal 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>";
|
||||||
|
}
|
||||||
|
}
|
11
src/Filter/InputTextFilter.php
Normal file
11
src/Filter/InputTextFilter.php
Normal 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>";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user