kernel update

This commit is contained in:
Билай Станислав 2024-11-20 12:56:15 +03:00
parent 1ea3eca919
commit fd9439c9e2
32 changed files with 405 additions and 114 deletions

View File

@ -11,7 +11,7 @@ class Widget
public function __construct(array $data = []) public function __construct(array $data = [])
{ {
$this->cgView = new CgView(); $this->cgView = new CgView();
$this->cgView->viewPath = ROOT_DIR . "/views/widgets"; $this->cgView->viewPath = KERNEL_DIR . "/views/widgets";
$this->data = $data; $this->data = $data;

View File

@ -13,7 +13,7 @@
<link href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700,800,900" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Poppins:300,400,500,600,700,800,900" rel="stylesheet">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.6.0/css/all.min.css">
<link rel="stylesheet" href="<?=$resources?>/css/style.css"> <link rel="stylesheet" href="<?=$resources?>/css/style.css">
</head> </head>
<body> <body>

View File

@ -3,8 +3,6 @@
* @var $json string * @var $json string
*/ */
use kernel\models\Option;
$table = new \Itguild\Tables\ListJsonTable($json); $table = new \Itguild\Tables\ListJsonTable($json);
$table->columns([ $table->columns([
@ -13,14 +11,15 @@ $table->columns([
} }
]); ]);
$table->addAction(function ($row, $url){ $table->addAction(function ($row, $url){
$path = $row['path'];
$active_admin_theme = \kernel\modules\option\service\OptionService::getItem('active_admin_theme'); $active_admin_theme = \kernel\modules\option\service\OptionService::getItem('active_admin_theme');
$btn = "<a class='btn btn-primary' href='$url/activate/?p=$path' style='margin: 3px; width: 150px;' >Активировать</a>";
if ($path === $active_admin_theme){
$btn = "Активна";
}
return $btn; if ($row['path'] === $active_admin_theme){
return "Активна";
} else {
$url = "$url/activate/?p=" . $row['path'];
return \kernel\widgets\IconBtn\IconBtnActivateWidget::create(['url' => $url])->run();
}
}); });
$table->create(); $table->create();
$table->render(); $table->render();

View File

@ -23,8 +23,7 @@ $table->rows([
} }
]); ]);
$table->beforePrint(function () { $table->beforePrint(function () {
$btn = PrimaryBtn::create("Список", "/admin/settings/admin-themes")->fetch(); return \kernel\widgets\IconBtn\IconBtnListWidget::create(['url' => '/admin/settings/admin-themes'])->run();
return $btn;
}); });
$table->create(); $table->create();
$table->render(); $table->render();

View File

@ -6,11 +6,11 @@
use Itguild\EloquentTable\EloquentDataProvider; use Itguild\EloquentTable\EloquentDataProvider;
use Itguild\EloquentTable\ListEloquentTable; use Itguild\EloquentTable\ListEloquentTable;
use kernel\IGTabel\action_column\DeleteActionColumn;
use kernel\IGTabel\action_column\EditActionColumn;
use kernel\IGTabel\action_column\ViewActionColumn;
use kernel\IGTabel\btn\PrimaryBtn;
use kernel\models\Menu; use kernel\models\Menu;
use kernel\widgets\IconBtn\IconBtnCreateWidget;
use kernel\widgets\IconBtn\IconBtnDeleteWidget;
use kernel\widgets\IconBtn\IconBtnEditWidget;
use kernel\widgets\IconBtn\IconBtnViewWidget;
$table = new ListEloquentTable(new EloquentDataProvider(Menu::class, [ $table = new ListEloquentTable(new EloquentDataProvider(Menu::class, [
'currentPage' => $page_number, 'currentPage' => $page_number,
@ -25,11 +25,17 @@ $table->columns([
}), }),
]); ]);
$table->beforePrint(function () { $table->beforePrint(function () {
return PrimaryBtn::create("Создать", "/admin/settings/menu/create")->fetch(); return IconBtnCreateWidget::create(['url' => '/admin/settings/menu/create'])->run();
//return (new PrimaryBtn("Создать", "/admin/user/create"))->fetch(); });
$table->addAction(function($row) {
return IconBtnViewWidget::create(['url' => '/admin/settings/menu/view/' . $row['id']])->run();
});
$table->addAction(function($row) {
return IconBtnEditWidget::create(['url' => '/admin/settings/menu/update/' . $row['id']])->run();
});
$table->addAction(function($row) {
return IconBtnDeleteWidget::create(['url' => '/admin/settings/menu/delete/' . $row['id']])->run();
}); });
$table->addAction(ViewActionColumn::class);
$table->addAction(EditActionColumn::class);
$table->addAction(DeleteActionColumn::class);
$table->create(); $table->create();
$table->render(); $table->render();

View File

@ -6,10 +6,10 @@
use Itguild\EloquentTable\ViewEloquentTable; use Itguild\EloquentTable\ViewEloquentTable;
use Itguild\EloquentTable\ViewJsonTableEloquentModel; use Itguild\EloquentTable\ViewJsonTableEloquentModel;
use kernel\IGTabel\btn\DangerBtn;
use kernel\IGTabel\btn\PrimaryBtn;
use kernel\IGTabel\btn\SuccessBtn;
use kernel\models\Menu; use kernel\models\Menu;
use kernel\widgets\IconBtn\IconBtnDeleteWidget;
use kernel\widgets\IconBtn\IconBtnEditWidget;
use kernel\widgets\IconBtn\IconBtnListWidget;
$table = new ViewEloquentTable(new ViewJsonTableEloquentModel($menu, [ $table = new ViewEloquentTable(new ViewJsonTableEloquentModel($menu, [
'params' => ["class" => "table table-bordered", "border" => "2"], 'params' => ["class" => "table table-bordered", "border" => "2"],
@ -17,9 +17,9 @@ $table = new ViewEloquentTable(new ViewJsonTableEloquentModel($menu, [
])); ]));
$table->beforePrint(function () use ($menu) { $table->beforePrint(function () use ($menu) {
$btn = PrimaryBtn::create("Список", "/admin/settings/menu")->fetch(); $btn = IconBtnListWidget::create(['url' => '/admin/settings/menu'])->run();
$btn .= SuccessBtn::create("Редактировать", "/admin/settings/menu/update/" . $menu->id)->fetch(); $btn .= IconBtnEditWidget::create(['url' => '/admin/settings/menu/update/' . $menu->id])->run();
$btn .= DangerBtn::create("Удалить", "/admin/settings/menu/delete/" . $menu->id)->fetch(); $btn .= IconBtnDeleteWidget::create(['url' => '/admin/settings/menu/delete/' . $menu->id])->run();
return $btn; return $btn;
}); });
$table->rows([ $table->rows([

View File

@ -8,6 +8,7 @@
*/ */
use Itguild\Tables\ListJsonTable; use Itguild\Tables\ListJsonTable;
use kernel\widgets\ActionButtonWidget;
$meta = []; $meta = [];
$meta['columns'] = [ $meta['columns'] = [
@ -29,40 +30,39 @@ $info_to_table['data'] = $modules_info;
$table = new ListJsonTable(json_encode($info_to_table, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); $table = new ListJsonTable(json_encode($info_to_table, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
$table->addAction(\kernel\IGTabel\action_column\ViewActionColumn::class); $table->addAction(function ($row, $url) use ($moduleService) {
$url = "$url/view/" . $row['id'];
return \kernel\widgets\IconBtn\IconBtnViewWidget::create(['url' => $url])->run();
});
$table->addAction(function ($row, $url) use ($moduleService){ $table->addAction(function ($row, $url) use ($moduleService){
$slug = $row['slug']; if ($moduleService->isInstall($row['slug'])){
$id = $row['id']; $url = "$url/delete/?slug=" . $row['slug'];
if ($moduleService->isInstall($slug)){
$label = "Удалить"; return \kernel\widgets\IconBtn\IconBtnDeleteWidget::create(['url' => $url])->run();
$btn_type = "danger";
$btn = "<a class='btn btn-$btn_type' href='$url/delete/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>";
} }
else { else {
$label = "Установить"; $url = "$url/install/?id=" . $row['id'];
$btn_type = "success";
$btn = "<a class='btn btn-$btn_type' href='$url/install/?id=$id' style='margin: 3px; width: 150px;' >$label</a>";
}
return $btn; return \kernel\widgets\IconBtn\IconBtnInstallWidget::create(['url' => $url])->run();
}
}); });
$table->addAction(function ($row, $url) use ($moduleService){ $table->addAction(function ($row, $url) use ($moduleService){
$slug = $row['slug']; $slug = $row['slug'];
if ($moduleService->isInstall($slug)){ if ($moduleService->isInstall($slug)){
if (!$moduleService->isLastVersion($slug)) { if (!$moduleService->isLastVersion($slug)) {
$label = "Обновить"; $url = "$url/update/?slug=" . $slug;
$btn_type = "info";
return "<a class='btn btn-$btn_type' href='$url/update/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>"; return \kernel\widgets\IconBtn\IconBtnUpdateWidget::create(['url' => $url])->run();
} }
} }
return false; return false;
}); });
\kernel\widgets\ModuleTabsWidget::create()->run();
$table->create(); $table->create();
\kernel\widgets\ModuleTabsWidget::create()->run();
$table->render(); $table->render();

View File

@ -25,8 +25,7 @@ $table_info = [
$table = new \Itguild\Tables\ViewJsonTable(json_encode($table_info, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); $table = new \Itguild\Tables\ViewJsonTable(json_encode($table_info, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
$table->beforePrint(function () { $table->beforePrint(function () {
$btn = PrimaryBtn::create("Список", "/admin/module_shop_client")->fetch(); return \kernel\widgets\IconBtn\IconBtnListWidget::create(['url' => '/admin/module_shop_client'])->run();
return $btn;
}); });
$table->create(); $table->create();
$table->render(); $table->render();

View File

@ -11,6 +11,10 @@ use kernel\IGTabel\action_column\EditActionColumn;
use kernel\IGTabel\action_column\ViewActionColumn; use kernel\IGTabel\action_column\ViewActionColumn;
use kernel\IGTabel\btn\PrimaryBtn; use kernel\IGTabel\btn\PrimaryBtn;
use kernel\modules\option\models\Option; use kernel\modules\option\models\Option;
use kernel\widgets\IconBtn\IconBtnCreateWidget;
use kernel\widgets\IconBtn\IconBtnDeleteWidget;
use kernel\widgets\IconBtn\IconBtnEditWidget;
use kernel\widgets\IconBtn\IconBtnViewWidget;
$table = new ListEloquentTable(new EloquentDataProvider(Option::class, [ $table = new ListEloquentTable(new EloquentDataProvider(Option::class, [
'current_page' => $page_number, 'current_page' => $page_number,
@ -20,8 +24,7 @@ $table = new ListEloquentTable(new EloquentDataProvider(Option::class, [
])); ]));
$table->beforePrint(function () { $table->beforePrint(function () {
return PrimaryBtn::create("Создать", "/admin/option/create")->fetch(); return IconBtnCreateWidget::create(['url' => '/admin/option/create'])->run();
//return (new PrimaryBtn("Создать", "/admin/user/create"))->fetch();
}); });
$table->columns([ $table->columns([
@ -31,8 +34,15 @@ $table->columns([
}] }]
]); ]);
$table->addAction(ViewActionColumn::class); $table->addAction(function($row) {
$table->addAction(EditActionColumn::class); return IconBtnViewWidget::create(['url' => '/admin/option/view/' . $row['id']])->run();
$table->addAction(DeleteActionColumn::class); });
$table->addAction(function($row) {
return IconBtnEditWidget::create(['url' => '/admin/option/update/' . $row['id']])->run();
});
$table->addAction(function($row) {
return IconBtnDeleteWidget::create(['url' => '/admin/option/delete/' . $row['id']])->run();
});
$table->create(); $table->create();
$table->render(); $table->render();

View File

@ -8,15 +8,18 @@ use Itguild\EloquentTable\ViewJsonTableEloquentModel;
use kernel\IGTabel\btn\DangerBtn; use kernel\IGTabel\btn\DangerBtn;
use kernel\IGTabel\btn\PrimaryBtn; use kernel\IGTabel\btn\PrimaryBtn;
use kernel\IGTabel\btn\SuccessBtn; use kernel\IGTabel\btn\SuccessBtn;
use kernel\widgets\IconBtn\IconBtnDeleteWidget;
use kernel\widgets\IconBtn\IconBtnEditWidget;
use kernel\widgets\IconBtn\IconBtnListWidget;
$table = new ViewEloquentTable(new ViewJsonTableEloquentModel($option, [ $table = new ViewEloquentTable(new ViewJsonTableEloquentModel($option, [
'params' => ["class" => "table table-bordered", "border" => "2"], 'params' => ["class" => "table table-bordered", "border" => "2"],
'baseUrl' => "/admin/user", 'baseUrl' => "/admin/user",
])); ]));
$table->beforePrint(function () use ($option) { $table->beforePrint(function () use ($option) {
$btn = PrimaryBtn::create("Список", "/admin/option")->fetch(); $btn = IconBtnListWidget::create(['url' => '/admin/option'])->run();
$btn .= SuccessBtn::create("Редактировать", "/admin/option/update/" . $option->id)->fetch(); $btn .= IconBtnEditWidget::create(['url' => '/admin/option/update/' . $option->id])->run();
$btn .= DangerBtn::create("Удалить", "/admin/option/delete/" . $option->id)->fetch(); $btn .= IconBtnDeleteWidget::create(['url' => '/admin/option/delete/' . $option->id])->run();
return $btn; return $btn;
}); });

View File

@ -13,6 +13,10 @@ use kernel\modules\user\models\User;
use Itguild\EloquentTable\EloquentDataProvider; use Itguild\EloquentTable\EloquentDataProvider;
use Itguild\EloquentTable\ListEloquentTable; use Itguild\EloquentTable\ListEloquentTable;
use kernel\IGTabel\btn\PrimaryBtn; use kernel\IGTabel\btn\PrimaryBtn;
use kernel\widgets\IconBtn\IconBtnCreateWidget;
use kernel\widgets\IconBtn\IconBtnDeleteWidget;
use kernel\widgets\IconBtn\IconBtnEditWidget;
use kernel\widgets\IconBtn\IconBtnViewWidget;
$table = new ListEloquentTable(new EloquentDataProvider(Post::class, [ $table = new ListEloquentTable(new EloquentDataProvider(Post::class, [
'currentPage' => $page_number, 'currentPage' => $page_number,
@ -39,12 +43,18 @@ $table->columns([
return User::find($data)->username; return User::find($data)->username;
}) })
]); ]);
$table->beforePrint(function () { $table->beforePrint(function () {
return PrimaryBtn::create("Создать", "/admin/post/create")->fetch(); return IconBtnCreateWidget::create(['url' => '/admin/post/create'])->run();
//return (new PrimaryBtn("Создать", "/admin/user/create"))->fetch(); });
$table->addAction(function($row) {
return IconBtnViewWidget::create(['url' => '/admin/post/view/' . $row['id']])->run();
});
$table->addAction(function($row) {
return IconBtnEditWidget::create(['url' => '/admin/post/update/' . $row['id']])->run();
});
$table->addAction(function($row) {
return IconBtnDeleteWidget::create(['url' => '/admin/post/delete/' . $row['id']])->run();
}); });
$table->addAction(ViewActionColumn::class);
$table->addAction(EditActionColumn::class);
$table->addAction(DeleteActionColumn::class);
$table->create(); $table->create();
$table->render(); $table->render();

View File

@ -10,17 +10,21 @@ use Itguild\EloquentTable\ViewJsonTableEloquentModel;
use kernel\IGTabel\btn\DangerBtn; use kernel\IGTabel\btn\DangerBtn;
use kernel\IGTabel\btn\PrimaryBtn; use kernel\IGTabel\btn\PrimaryBtn;
use kernel\IGTabel\btn\SuccessBtn; use kernel\IGTabel\btn\SuccessBtn;
use kernel\widgets\IconBtn\IconBtnDeleteWidget;
use kernel\widgets\IconBtn\IconBtnEditWidget;
use kernel\widgets\IconBtn\IconBtnListWidget;
$table = new ViewEloquentTable(new ViewJsonTableEloquentModel($content, [ $table = new ViewEloquentTable(new ViewJsonTableEloquentModel($content, [
'params' => ["class" => "table table-bordered", "border" => "2"], 'params' => ["class" => "table table-bordered", "border" => "2"],
'baseUrl' => "/admin/post", 'baseUrl' => "/admin/post",
])); ]));
$table->beforePrint(function () use ($content) { $table->beforePrint(function () use ($content) {
$btn = PrimaryBtn::create("Список", "/admin/post")->fetch(); $btn = IconBtnListWidget::create(['url' => '/admin/post'])->run();
$btn .= SuccessBtn::create("Редактировать", "/admin/post/update/" . $content->id)->fetch(); $btn .= IconBtnEditWidget::create(['url' => '/admin/post/update/' . $content->id])->run();
$btn .= DangerBtn::create("Удалить", "/admin/post/delete/" . $content->id)->fetch(); $btn .= IconBtnDeleteWidget::create(['url' => '/admin/post/delete/' . $content->id])->run();
return $btn; return $btn;
}); });
$table->rows([ $table->rows([
'created_at' => function ($data) { 'created_at' => function ($data) {
if (!$data){ if (!$data){

View File

@ -12,6 +12,10 @@ use kernel\IGTabel\action_column\EditActionColumn;
use kernel\IGTabel\action_column\ViewActionColumn; use kernel\IGTabel\action_column\ViewActionColumn;
use kernel\IGTabel\btn\PrimaryBtn; use kernel\IGTabel\btn\PrimaryBtn;
use kernel\modules\user\models\User; use kernel\modules\user\models\User;
use kernel\widgets\IconBtn\IconBtnCreateWidget;
use kernel\widgets\IconBtn\IconBtnDeleteWidget;
use kernel\widgets\IconBtn\IconBtnEditWidget;
use kernel\widgets\IconBtn\IconBtnViewWidget;
$table = new ListEloquentTable(new EloquentDataProvider(User::class, [ $table = new ListEloquentTable(new EloquentDataProvider(User::class, [
'currentPage' => $page_number, 'currentPage' => $page_number,
@ -42,11 +46,16 @@ $table->columns([
} }
]); ]);
$table->beforePrint(function () { $table->beforePrint(function () {
return PrimaryBtn::create("Создать", "/admin/user/create")->fetch(); return IconBtnCreateWidget::create(['url' => '/admin/user/create'])->run();
//return (new PrimaryBtn("Создать", "/admin/user/create"))->fetch(); });
$table->addAction(function($row) {
return IconBtnViewWidget::create(['url' => '/admin/user/view/' . $row['id']])->run();
});
$table->addAction(function($row) {
return IconBtnEditWidget::create(['url' => '/admin/user/update/' . $row['id']])->run();
});
$table->addAction(function($row) {
return IconBtnDeleteWidget::create(['url' => '/admin/user/delete/' . $row['id']])->run();
}); });
$table->addAction(ViewActionColumn::class);
$table->addAction(EditActionColumn::class);
$table->addAction(DeleteActionColumn::class);
$table->create(); $table->create();
$table->render(); $table->render();

View File

@ -10,17 +10,21 @@ use Itguild\EloquentTable\ViewJsonTableEloquentModel;
use kernel\IGTabel\btn\DangerBtn; use kernel\IGTabel\btn\DangerBtn;
use kernel\IGTabel\btn\PrimaryBtn; use kernel\IGTabel\btn\PrimaryBtn;
use kernel\IGTabel\btn\SuccessBtn; use kernel\IGTabel\btn\SuccessBtn;
use kernel\widgets\IconBtn\IconBtnDeleteWidget;
use kernel\widgets\IconBtn\IconBtnEditWidget;
use kernel\widgets\IconBtn\IconBtnListWidget;
$table = new ViewEloquentTable(new ViewJsonTableEloquentModel($user, [ $table = new ViewEloquentTable(new ViewJsonTableEloquentModel($user, [
'params' => ["class" => "table table-bordered", "border" => "2"], 'params' => ["class" => "table table-bordered", "border" => "2"],
'baseUrl' => "/admin/user", 'baseUrl' => "/admin/user",
])); ]));
$table->beforePrint(function () use ($user) { $table->beforePrint(function () use ($user) {
$btn = PrimaryBtn::create("Список", "/admin/user")->fetch(); $btn = IconBtnListWidget::create(['url' => '/admin/user'])->run();
$btn .= SuccessBtn::create("Редактировать", "/admin/user/update/" . $user->id)->fetch(); $btn .= IconBtnEditWidget::create(['url' => '/admin/user/update/' . $user->id])->run();
$btn .= DangerBtn::create("Удалить", "/admin/user/delete/" . $user->id)->fetch(); $btn .= IconBtnDeleteWidget::create(['url' => '/admin/user/delete/' . $user->id])->run();
return $btn; return $btn;
}); });
$table->rows([ $table->rows([
'created_at' => function ($data) { 'created_at' => function ($data) {
if (!$data){ if (!$data){

View File

@ -7,6 +7,13 @@
* @var \kernel\services\ModuleService $moduleService * @var \kernel\services\ModuleService $moduleService
*/ */
use kernel\widgets\IconBtn\IconBtnActivateWidget;
use kernel\widgets\IconBtn\IconBtnDeactivateWidget;
use kernel\widgets\IconBtn\IconBtnDeleteWidget;
use kernel\widgets\IconBtn\IconBtnUpdateWidget;
use kernel\widgets\IconBtn\IconBtnViewWidget;
use kernel\widgets\ModuleTabsWidget;
$meta = []; $meta = [];
$meta['columns'] = [ $meta['columns'] = [
"name" => "Название", "name" => "Название",
@ -29,31 +36,29 @@ $table = new \Itguild\Tables\ListJsonTable(json_encode($info_to_table, JSON_PRET
$table->addAction(function ($row, $url) use ($moduleService) { $table->addAction(function ($row, $url) use ($moduleService) {
$slug = $row['slug']; $slug = $row['slug'];
if ($moduleService->isActive($slug)) { if ($moduleService->isActive($slug)) {
$label = "Деактивировать"; $url = "$url/deactivate/?slug=". $row['slug'];
$btn_type = "warning";
$btn = "<a class='btn btn-$btn_type' href='$url/deactivate/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>";
return IconBtnDeactivateWidget::create(['url' => $url])->run();
} else { } else {
$label = "<i class='fa-regular fa-circle-check'></i>"; $url = "$url/activate/?slug=". $row['slug'];
$btn_type = "success";
$btn = "<a class='btn btn-$btn_type' href='$url/activate/?slug=$slug' style='margin: 3px;' >$label</a>";
}
return $btn; return IconBtnActivateWidget::create(['url' => $url])->run();
}
}); });
$table->addAction(function ($row, $url) use ($moduleService) { $table->addAction(function ($row, $url) use ($moduleService) {
$slug = $row['slug']; $url = "$url/view/?slug=". $row['slug'];
return "<a class='btn btn-primary' href='$url/view/?slug=$slug' style='margin: 3px; width: 150px;' >Просмотр</a>";
return IconBtnViewWidget::create(['url' => $url])->run();
}); });
$table->addAction(function ($row, $url) use ($moduleService){ $table->addAction(function ($row, $url) use ($moduleService){
$slug = $row['slug']; if (!$moduleService->isKernelModule($row['slug'])){
if (!$moduleService->isKernelModule($slug)){ if (!$moduleService->isLastVersion($row['slug'])) {
if (!$moduleService->isLastVersion($slug)) { $url = "$url/update/?slug=". $row['slug'];
$label = "Обновить";
$btn_type = "info"; return IconBtnUpdateWidget::create(['url' => $url])->run();
return "<a class='btn btn-$btn_type' href='$url/update/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>";
} }
} }
@ -62,17 +67,17 @@ $table->addAction(function ($row, $url) use ($moduleService){
$table->addAction(function ($row) use ($moduleService){ $table->addAction(function ($row) use ($moduleService){
$slug = $row['slug']; $slug = $row['slug'];
if (!$moduleService->isKernelModule($slug)){ if (!$moduleService->isKernelModule($slug)) {
$label = "Удалить"; $url = "admin/module_shop_client/delete/?slug=" . $row['slug'];
$btn_type = "danger";
return "<a class='btn btn-$btn_type' href='admin/module_shop_client/delete/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>"; return IconBtnDeleteWidget::create(['url' => $url])->run();
} }
return false; return false;
}); });
$table->create();
if ($moduleService->isActive('module_shop_client')) { if ($moduleService->isActive('module_shop_client')) {
\kernel\widgets\ModuleTabsWidget::create()->run(); ModuleTabsWidget::create()->run();
} }
$table->create();
$table->render(); $table->render();

View File

@ -3,9 +3,8 @@
* @var array $data * @var array $data
*/ */
use kernel\IGTabel\btn\DangerBtn; use Itguild\Tables\ViewJsonTable;
use kernel\IGTabel\btn\PrimaryBtn; use kernel\widgets\IconBtn\IconBtnListWidget;
use kernel\IGTabel\btn\SuccessBtn;
$table_info = [ $table_info = [
"meta" => [ "meta" => [
@ -20,11 +19,10 @@ $table_info = [
], ],
"data" => $data "data" => $data
]; ];
$table = new \Itguild\Tables\ViewJsonTable(json_encode($table_info, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE)); $table = new ViewJsonTable(json_encode($table_info, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE));
$table->beforePrint(function () { $table->beforePrint(function () {
$btn = PrimaryBtn::create("Список", "/admin")->fetch(); return IconBtnListWidget::create(['url' => '/admin'])->run();
return $btn;
}); });
$table->create(); $table->create();
$table->render(); $table->render();

View File

@ -0,0 +1,10 @@
<?php
/**
* @var string $label
* @var string $btn_type
* @var string $url
* @var string $title
*/
?>
<a title="<?= $title ?>" class='btn btn-<?= $btn_type ?>' href='<?= $url ?>' style='margin: 3px' ><?= $label ?></a>

View File

@ -1,9 +0,0 @@
<?php
/**
* @var string $icon
* @var string $btn
* @var string $url
*/
?>
"<a class='btn btn-$btn' href='$url/deactivate/?slug=$slug' style='margin: 3px; width: 150px;' >$icon</a>";

View File

@ -2,15 +2,24 @@
namespace kernel\widgets; namespace kernel\widgets;
use kernel\helpers\Debug;
use kernel\Widget; use kernel\Widget;
class ActionButtonWidget extends Widget class ActionButtonWidget extends Widget
{ {
public function run(): void
public static function create(array $data = []): ActionButtonWidget
{ {
$icon = $this->data['icon']; return new static($data);
$btn = $this->data['btn']; }
public function run(): string
{
$label = $this->data['label'];
$btn_type = $this->data['btn_type'];
$url = $this->data['url']; $url = $this->data['url'];
$this->cgView->render('/admin/action_button.php', ['icon' => $icon, 'btn' => $btn, 'url' => $url]); $title = $this->data['title'] ?? '';
return $this->cgView->fetch('/action_button.php', ['label' => $label, 'btn_type' => $btn_type, 'url' => $url, 'title' => $title]);
} }
} }

View File

@ -0,0 +1,26 @@
<?php
namespace kernel\widgets\IconBtn;
use kernel\Widget;
use kernel\widgets\ActionButtonWidget;
class IconBtnActivateWidget extends Widget
{
public static function create(array $data = []): IconBtnActivateWidget
{
return new static($data);
}
public function run()
{
$url = $this->data['url'];
return ActionButtonWidget::create([
'label' => "<i class='fa-regular fa-circle-check'></i>",
'url' => $url,
'btn_type' => "success",
'title' => "Активировать"
])->run();
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace kernel\widgets\IconBtn;
use kernel\Widget;
use kernel\widgets\ActionButtonWidget;
class IconBtnCreateWidget extends Widget
{
public static function create(array $data = []): IconBtnCreateWidget
{
return new static($data);
}
public function run()
{
$url = $this->data['url'];
return ActionButtonWidget::create([
'label' => "<i class='fa-regular fa-square-plus'></i>",
'url' => $url,
'btn_type' => "success",
'title' => "Создать"
])->run();
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace kernel\widgets\IconBtn;
use kernel\Widget;
use kernel\widgets\ActionButtonWidget;
class IconBtnDeactivateWidget extends Widget
{
public static function create(array $data = []): IconBtnDeactivateWidget
{
return new static($data);
}
public function run()
{
$url = $this->data['url'];
return ActionButtonWidget::create([
'label' => "<i class='fa-regular fa-circle-xmark'></i>",
'url' => $url,
'btn_type' => "warning",
'title' => "Деактивировать"
])->run();
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace kernel\widgets\IconBtn;
use kernel\Widget;
use kernel\widgets\ActionButtonWidget;
class IconBtnDeleteWidget extends Widget
{
public static function create(array $data = []): IconBtnDeleteWidget
{
return new static($data);
}
public function run()
{
$url = $this->data['url'];
return ActionButtonWidget::create([
'label' => "<i class='fa-regular fa-trash-can'></i>",
'url' => $url,
'btn_type' => "danger",
'title' => "Удалить"
])->run();
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace kernel\widgets\IconBtn;
use kernel\Widget;
use kernel\widgets\ActionButtonWidget;
class IconBtnEditWidget extends Widget
{
public static function create(array $data = []): IconBtnEditWidget
{
return new static($data);
}
public function run()
{
$url = $this->data['url'];
return ActionButtonWidget::create([
'label' => "<i class='fa-solid fa-pen'></i>",
'url' => $url,
'btn_type' => "success",
'title' => "Редактировать"
])->run();
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace kernel\widgets\IconBtn;
use kernel\Widget;
use kernel\widgets\ActionButtonWidget;
class IconBtnInstallWidget extends Widget
{
public static function create(array $data = []): IconBtnInstallWidget
{
return new static($data);
}
public function run()
{
$url = $this->data['url'];
return ActionButtonWidget::create([
'label' => "<i class='fa-solid fa-download'></i>",
'url' => $url,
'btn_type' => "success",
'title' => "Установить"
])->run();
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace kernel\widgets\IconBtn;
use kernel\Widget;
use kernel\widgets\ActionButtonWidget;
class IconBtnListWidget extends Widget
{
public static function create(array $data = []): IconBtnListWidget
{
return new static($data);
}
public function run()
{
$url = $this->data['url'];
return ActionButtonWidget::create([
'label' => "<i class='fa-regular fa-rectangle-list'></i>",
'url' => $url,
'btn_type' => "primary",
'title' => "Список"
])->run();
}
}

View File

@ -0,0 +1,26 @@
<?php
namespace kernel\widgets\IconBtn;
use kernel\Widget;
use kernel\widgets\ActionButtonWidget;
class IconBtnUpdateWidget extends Widget
{
public static function create(array $data = []): IconBtnUpdateWidget
{
return new static($data);
}
public function run()
{
$url = $this->data['url'];
return ActionButtonWidget::create([
'label' => "<i class='fa-solid fa-cloud-arrow-down'></i>",
'url' => $url,
'btn_type' => "info",
'title' => "Обновить"
])->run();
}
}

View File

@ -0,0 +1,27 @@
<?php
namespace kernel\widgets\IconBtn;
use kernel\Widget;
use kernel\widgets\ActionButtonWidget;
class IconBtnViewWidget extends Widget
{
public static function create(array $data = []): IconBtnViewWidget
{
return new static($data);
}
public function run(): string
{
$url = $this->data['url'];
return ActionButtonWidget::create([
'btn_type' => "primary",
'label' => "<i class='fa-regular fa-eye'></i>",
'url' => $url,
'title' => "Просмотреть"
])->run();
}
}

View File

@ -11,7 +11,7 @@ class MenuWidget extends Widget
public function run(): void public function run(): void
{ {
$menu = Menu::where("parent_id", 0)->get()->sortBy("priority"); $menu = Menu::where("parent_id", 0)->get()->sortBy("priority");
$this->cgView->render('/admin/menu.php', ['menu' => $menu]); $this->cgView->render('/menu.php', ['menu' => $menu]);
} }
} }

View File

@ -13,6 +13,6 @@ class ModuleTabsWidget extends Widget
'/admin' => 'Локальные', '/admin' => 'Локальные',
'/admin/module_shop_client' => 'Каталог' '/admin/module_shop_client' => 'Каталог'
]; ];
$this->cgView->render('/admin/module_tabs.php', ['tabs' => $tabs]); $this->cgView->render('/module_tabs.php', ['tabs' => $tabs]);
} }
} }