4 Commits
0.1.2 ... 0.1.5

Author SHA1 Message Date
85c4a850b1 set action 2024-07-16 13:26:29 +03:00
02ded1a613 some fix 2024-07-16 13:20:48 +03:00
c648bd37b6 edit class column 2024-07-16 13:12:40 +03:00
cf347f1dc2 custom ation column 2024-07-15 17:19:30 +03:00
5 changed files with 18 additions and 7 deletions

View File

@ -8,8 +8,11 @@ abstract class ActionColumn
protected string $prefix;
protected int $id;
public function __construct(string $baseUrl, int $id)
public function __construct(string $baseUrl, int $id, string $prefix = '')
{
if (!empty($prefix)){
$this->prefix = $prefix;
}
$this->baseUrl = $baseUrl;
$this->id = $id;
}

View File

@ -4,7 +4,7 @@ namespace Itguild\Tables\ActionColumn;
class DeleteActionColumn extends ActionColumn
{
protected string $prefix = "/form-delete/";
protected string $prefix = "/delete/";
public function fetch(): string
{

View File

@ -5,7 +5,7 @@ namespace Itguild\Tables\ActionColumn;
class EditActionColumn extends ActionColumn
{
protected string $prefix = "/form-edit/";
protected string $prefix = "/edit/";
public function fetch(): string
{

View File

@ -4,7 +4,7 @@ namespace Itguild\Tables\ActionColumn;
class ViewActionColumn extends ActionColumn
{
protected string $prefix = "/form-item/";
protected string $prefix = "/view/";
public function fetch(): string
{

View File

@ -2,6 +2,7 @@
namespace Itguild\Tables;
use Itguild\Tables\ActionColumn\ActionColumn;
use Itguild\Tables\ActionColumn\DeleteActionColumn;
use Itguild\Tables\ActionColumn\EditActionColumn;
use Itguild\Tables\ActionColumn\ViewActionColumn;
@ -21,6 +22,7 @@ class ListJsonTable
private array $data;
private array $actionsArray = [];
private array $customActionsArray = [];
public function __construct(string $json)
{
@ -30,7 +32,6 @@ class ListJsonTable
$this->json = $json;
$this->data = json_decode($this->json, true);
$this->baseUrl = $this->data['meta']['baseUrl'] ?? '';
$this->setActions();
}
public function beginTable(): void
@ -89,6 +90,11 @@ class ListJsonTable
}
}
public function addAction(string $actionColumn): void
{
$this->customActionsArray[] = $actionColumn;
}
private function setActions(): void
{
if (isset($this->data['meta']['actions'])) {
@ -106,9 +112,10 @@ class ListJsonTable
}
}
}
$this->actionsArray = array_merge($this->actionsArray, $this->customActionsArray);
}
private function issetColumn($column)
private function issetColumn($column): bool
{
if (isset($this->data['meta']['columns'])) {
foreach ($this->data['meta']['columns'] as $key => $currentColumn) {
@ -145,8 +152,9 @@ class ListJsonTable
return $actions;
}
public function create()
public function create(): void
{
$this->setActions();
$this->beginTable();
$this->createThead();
$this->createTbody();