Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
c648bd37b6 | |||
cf347f1dc2 | |||
4bdd883d67 | |||
f9fc6b9f17 |
@ -8,8 +8,11 @@ abstract class ActionColumn
|
|||||||
protected string $prefix;
|
protected string $prefix;
|
||||||
|
|
||||||
protected int $id;
|
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->baseUrl = $baseUrl;
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
}
|
}
|
@ -4,7 +4,7 @@ namespace Itguild\Tables\ActionColumn;
|
|||||||
|
|
||||||
class DeleteActionColumn extends ActionColumn
|
class DeleteActionColumn extends ActionColumn
|
||||||
{
|
{
|
||||||
protected string $prefix = "/form-delete/";
|
protected string $prefix = "/delete/";
|
||||||
|
|
||||||
public function fetch(): string
|
public function fetch(): string
|
||||||
{
|
{
|
@ -5,7 +5,7 @@ namespace Itguild\Tables\ActionColumn;
|
|||||||
class EditActionColumn extends ActionColumn
|
class EditActionColumn extends ActionColumn
|
||||||
{
|
{
|
||||||
|
|
||||||
protected string $prefix = "/form-edit/";
|
protected string $prefix = "/edit/";
|
||||||
|
|
||||||
public function fetch(): string
|
public function fetch(): string
|
||||||
{
|
{
|
@ -4,7 +4,7 @@ namespace Itguild\Tables\ActionColumn;
|
|||||||
|
|
||||||
class ViewActionColumn extends ActionColumn
|
class ViewActionColumn extends ActionColumn
|
||||||
{
|
{
|
||||||
protected string $prefix = "/form-item/";
|
protected string $prefix = "/view/";
|
||||||
|
|
||||||
public function fetch(): string
|
public function fetch(): string
|
||||||
{
|
{
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
namespace Itguild\Tables;
|
namespace Itguild\Tables;
|
||||||
|
|
||||||
|
use Itguild\Tables\ActionColumn\ActionColumn;
|
||||||
use Itguild\Tables\ActionColumn\DeleteActionColumn;
|
use Itguild\Tables\ActionColumn\DeleteActionColumn;
|
||||||
use Itguild\Tables\ActionColumn\EditActionColumn;
|
use Itguild\Tables\ActionColumn\EditActionColumn;
|
||||||
use Itguild\Tables\ActionColumn\ViewActionColumn;
|
use Itguild\Tables\ActionColumn\ViewActionColumn;
|
||||||
@ -21,11 +22,13 @@ class ListJsonTable
|
|||||||
private array $data;
|
private array $data;
|
||||||
|
|
||||||
private array $actionsArray = [];
|
private array $actionsArray = [];
|
||||||
|
private array $customActionsArray = [];
|
||||||
|
|
||||||
public function __construct(string $json)
|
public function __construct(string $json)
|
||||||
{
|
{
|
||||||
$this->beforePrintCell = false;
|
$this->beforePrintCell = false;
|
||||||
$this->beforePrint = function (){};
|
$this->beforePrint = function () {
|
||||||
|
};
|
||||||
$this->json = $json;
|
$this->json = $json;
|
||||||
$this->data = json_decode($this->json, true);
|
$this->data = json_decode($this->json, true);
|
||||||
$this->baseUrl = $this->data['meta']['baseUrl'] ?? '';
|
$this->baseUrl = $this->data['meta']['baseUrl'] ?? '';
|
||||||
@ -88,6 +91,11 @@ class ListJsonTable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addAction(ActionColumn $actionColumn): void
|
||||||
|
{
|
||||||
|
$this->customActionsArray[] = $actionColumn;
|
||||||
|
}
|
||||||
|
|
||||||
private function setActions(): void
|
private function setActions(): void
|
||||||
{
|
{
|
||||||
if (isset($this->data['meta']['actions'])) {
|
if (isset($this->data['meta']['actions'])) {
|
||||||
@ -105,9 +113,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'])) {
|
if (isset($this->data['meta']['columns'])) {
|
||||||
foreach ($this->data['meta']['columns'] as $key => $currentColumn) {
|
foreach ($this->data['meta']['columns'] as $key => $currentColumn) {
|
||||||
@ -122,12 +131,11 @@ class ListJsonTable
|
|||||||
|
|
||||||
private function is_fillable($column): bool
|
private function is_fillable($column): bool
|
||||||
{
|
{
|
||||||
if (isset($this->data['meta']['fillable'])){
|
if (isset($this->data['meta']['fillable'])) {
|
||||||
if (in_array($column, $this->data['meta']['fillable'])) {
|
if (in_array($column, $this->data['meta']['fillable'])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user