fix filter
This commit is contained in:
@ -5,13 +5,11 @@ namespace Itguild\Tables\Filter;
|
||||
abstract class Filter
|
||||
{
|
||||
public string $html = '';
|
||||
public string|array $data;
|
||||
public string|array $param;
|
||||
public string $name;
|
||||
// public array|string $value;
|
||||
public function __construct(array $source)
|
||||
{
|
||||
$this->data = $source['data'] ?? '';
|
||||
// $this->value = $data['value'] ?? [];
|
||||
$this->param = $source['param'] ?? '';
|
||||
$this->name = $source['name'];
|
||||
}
|
||||
|
||||
|
@ -9,17 +9,6 @@ class InputFilter extends Filter
|
||||
|
||||
public function fetch()
|
||||
{
|
||||
// if(is_array($this->data)){
|
||||
// $this->html = "<td>";
|
||||
//// var_dump(key($this->data));
|
||||
// $key = key($this->data);
|
||||
// foreach ($this->data[$key] as $value){
|
||||
//// echo "<pre>";
|
||||
//// print_r($value);
|
||||
// $this->html .= "<input type='$key' name='$this->name' value='$value'>";
|
||||
// }
|
||||
// return $this->html . "</td>";
|
||||
// }
|
||||
return "<td><input type='$this->data' name='$this->name'></td>";
|
||||
return "<td><input type='$this->param' name='$this->name'></td>";
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ class SelectFilter extends Filter
|
||||
public function fetch()
|
||||
{
|
||||
$this->html = "<td><select name='$this->name'>";
|
||||
foreach ($this->data as $value) {
|
||||
foreach ($this->param as $value) {
|
||||
$this->html .= "<option value='$value'>$value</option>";
|
||||
}
|
||||
$this->html .= "</select></td>";
|
||||
|
@ -91,33 +91,33 @@ class JasonTable
|
||||
return $styleStr;
|
||||
}
|
||||
|
||||
protected function getTagFromCustomColumn(string $column): string
|
||||
{
|
||||
if (is_array($this->beforePrintCell[$column])) {
|
||||
if (isset($this->beforePrintCell[$column]['filter'])) {
|
||||
if (is_array($this->beforePrintCell[$column]['filter'])) {
|
||||
// foreach ($this->beforePrintCell[$column]['filter'] as $key => $value) {
|
||||
return key($this->beforePrintCell[$column]['filter']);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
return "text";
|
||||
}
|
||||
|
||||
protected function getFilterFromCustomColumn(string $column)
|
||||
{
|
||||
if (is_array($this->beforePrintCell[$column])) {
|
||||
if (isset($this->beforePrintCell[$column]['filter'])) {
|
||||
if (is_array($this->beforePrintCell[$column]['filter'])) {
|
||||
// foreach ($this->beforePrintCell[$column]['filter'] as $value) {
|
||||
// echo "<pre>";
|
||||
// print_r(current($this->beforePrintCell[$column]['filter']));
|
||||
return current($this->beforePrintCell[$column]['filter']);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
return "text";
|
||||
}
|
||||
// protected function getTagFromCustomColumn(string $column): string
|
||||
// {
|
||||
// if (is_array($this->beforePrintCell[$column])) {
|
||||
// if (isset($this->beforePrintCell[$column]['filter'])) {
|
||||
// if (is_array($this->beforePrintCell[$column]['filter'])) {
|
||||
//// foreach ($this->beforePrintCell[$column]['filter'] as $key => $value) {
|
||||
// return key($this->beforePrintCell[$column]['filter']);
|
||||
//// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return "text";
|
||||
// }
|
||||
//
|
||||
// protected function getFilterFromCustomColumn(string $column)
|
||||
// {
|
||||
// if (is_array($this->beforePrintCell[$column])) {
|
||||
// if (isset($this->beforePrintCell[$column]['filter'])) {
|
||||
// if (is_array($this->beforePrintCell[$column]['filter'])) {
|
||||
//// foreach ($this->beforePrintCell[$column]['filter'] as $value) {
|
||||
//// echo "<pre>";
|
||||
//// print_r(current($this->beforePrintCell[$column]['filter']));
|
||||
// return current($this->beforePrintCell[$column]['filter']);
|
||||
//// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// return "text";
|
||||
// }
|
||||
}
|
@ -147,13 +147,21 @@ class ListJsonTable extends JasonTable
|
||||
$this->actionsArray = array_merge($this->actionsArray, $this->customActionsArray);
|
||||
}
|
||||
|
||||
private function getCurrentFilter(string $filter): false|string
|
||||
private function getCurrentFilter(string $column)
|
||||
{
|
||||
return match ($filter) {
|
||||
'input' => InputFilter::class,
|
||||
'select' => SelectFilter::class,
|
||||
default => false,
|
||||
};
|
||||
// return match ($filter) {
|
||||
// 'input' => InputFilter::class,
|
||||
// 'select' => SelectFilter::class,
|
||||
// default => false,
|
||||
// };
|
||||
if (is_array($this->beforePrintCell[$column])) {
|
||||
if (isset($this->beforePrintCell[$column]['filter'])) {
|
||||
if (is_array($this->beforePrintCell[$column]['filter'])) {
|
||||
return $this->beforePrintCell[$column]['filter'];
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getCustomColumns($id = null): void
|
||||
@ -269,12 +277,18 @@ class ListJsonTable extends JasonTable
|
||||
foreach ($columnKeys as $key){
|
||||
if ($this->issetFilter($key)){
|
||||
// $this->html .= "<td><input type='" . $this->getFilterFromCustomColumn($key) . "' name='$key'></td>";
|
||||
$item = $this->getCurrentFilter($this->getTagFromCustomColumn($key));
|
||||
$objItem = new $item([
|
||||
'data' => $this->getFilterFromCustomColumn($key),
|
||||
// $item = $this->getCurrentFilter($this->getTagFromCustomColumn($key));
|
||||
// $objItem = new $item([
|
||||
// 'data' => $this->getFilterFromCustomColumn($key),
|
||||
// 'name' => $key
|
||||
// ]);
|
||||
// $this->html .= $objItem->fetch();
|
||||
$arr = $this->getCurrentFilter($key);
|
||||
$class = new $arr['class']([
|
||||
'param' => $arr['param'],
|
||||
'name' => $key
|
||||
]);
|
||||
$this->html .= $objItem->fetch();
|
||||
$this->html .= $class->fetch();
|
||||
}
|
||||
else {
|
||||
$this->html .= "<td></td>";
|
||||
|
Reference in New Issue
Block a user