action btns
This commit is contained in:
parent
7a90980772
commit
6c2798c123
@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace kernel\IGTabel\btn;
|
||||
|
||||
|
||||
class ActionButton
|
||||
{
|
||||
public static function create(array $data): string
|
||||
{
|
||||
$btn_type = $data['btn_type'];
|
||||
$url = $data['url'];
|
||||
$label = $data['label'];
|
||||
return "<a class='btn btn-$btn_type' href='$url' style='margin: 3px'>$label</a>";
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@
|
||||
*/
|
||||
|
||||
use kernel\models\Option;
|
||||
use kernel\widgets\ActionButtonWidget;
|
||||
|
||||
|
||||
$table = new \Itguild\Tables\ListJsonTable($json);
|
||||
@ -15,7 +16,12 @@ $table->columns([
|
||||
$table->addAction(function ($row, $url){
|
||||
$path = $row['path'];
|
||||
$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>";
|
||||
$btn = ActionButtonWidget::create([
|
||||
'btn_type' => "primary",
|
||||
'label' => "Активировать",
|
||||
'url' => "$url/activate/?p=$path",
|
||||
])->run();
|
||||
|
||||
if ($path === $active_admin_theme){
|
||||
$btn = "Активна";
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
*/
|
||||
|
||||
use Itguild\Tables\ListJsonTable;
|
||||
use kernel\widgets\ActionButtonWidget;
|
||||
|
||||
$meta = [];
|
||||
$meta['columns'] = [
|
||||
@ -29,32 +30,44 @@ $info_to_table['data'] = $modules_info;
|
||||
|
||||
$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) {
|
||||
$id = $row['id'];
|
||||
|
||||
return ActionButtonWidget::create([
|
||||
'btn_type' => "primary",
|
||||
'label' => "<i class='fa-regular fa-eye'></i>",
|
||||
'url' => "$url/view/$id",
|
||||
])->run();
|
||||
});
|
||||
|
||||
$table->addAction(function ($row, $url) use ($moduleService){
|
||||
$slug = $row['slug'];
|
||||
$id = $row['id'];
|
||||
if ($moduleService->isInstall($slug)){
|
||||
$label = "Удалить";
|
||||
$btn_type = "danger";
|
||||
$btn = "<a class='btn btn-$btn_type' href='$url/delete/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>";
|
||||
return ActionButtonWidget::create([
|
||||
'btn_type' => "danger",
|
||||
'label' => "<i class='fa-regular fa-trash-can'></i>",
|
||||
'url' => "$url/delete/?slug=$slug",
|
||||
])->run();
|
||||
}
|
||||
else {
|
||||
$label = "Установить";
|
||||
$btn_type = "success";
|
||||
$btn = "<a class='btn btn-$btn_type' href='$url/install/?id=$id' style='margin: 3px; width: 150px;' >$label</a>";
|
||||
return ActionButtonWidget::create([
|
||||
'btn_type' => "success",
|
||||
'label' => "<i class='fa-solid fa-download'></i>",
|
||||
'url' => "$url/install/?id=$id",
|
||||
])->run();
|
||||
}
|
||||
|
||||
return $btn;
|
||||
});
|
||||
|
||||
$table->addAction(function ($row, $url) use ($moduleService){
|
||||
$slug = $row['slug'];
|
||||
if ($moduleService->isInstall($slug)){
|
||||
if (!$moduleService->isLastVersion($slug)) {
|
||||
$label = "Обновить";
|
||||
$btn_type = "info";
|
||||
return "<a class='btn btn-$btn_type' href='$url/update/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>";
|
||||
return ActionButtonWidget::create([
|
||||
'btn_type' => "info",
|
||||
'label' => "<i class='fa-regular fa-pen-to-square'></i>",
|
||||
'url' => "$url/update/?slug=$slug",
|
||||
])->run();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,8 +7,8 @@
|
||||
* @var \kernel\services\ModuleService $moduleService
|
||||
*/
|
||||
|
||||
use kernel\IGTabel\btn\ActionButton;
|
||||
use kernel\widgets\ActionButtonWidget;
|
||||
use kernel\widgets\ModuleTabsWidget;
|
||||
|
||||
$meta = [];
|
||||
$meta['columns'] = [
|
||||
@ -32,11 +32,11 @@ $table = new \Itguild\Tables\ListJsonTable(json_encode($info_to_table, JSON_PRET
|
||||
$table->addAction(function ($row, $url) use ($moduleService) {
|
||||
$slug = $row['slug'];
|
||||
if ($moduleService->isActive($slug)) {
|
||||
return ActionButton::create([
|
||||
return ActionButtonWidget::create([
|
||||
'btn_type' => "warning",
|
||||
'label' => "<i class='fa-regular fa-circle-xmark'></i>",
|
||||
'url' => "$url/deactivate/?slug=$slug",
|
||||
]);
|
||||
])->run();
|
||||
|
||||
} else {
|
||||
return ActionButtonWidget::create([
|
||||
@ -44,33 +44,28 @@ $table->addAction(function ($row, $url) use ($moduleService) {
|
||||
'url' => "$url/deactivate/?slug=$slug",
|
||||
'btn_type' => "success"
|
||||
])->run();
|
||||
|
||||
// return ActionButton::create([
|
||||
// 'btn_type' => "success",
|
||||
// 'label' => "<i class='fa-regular fa-circle-check'></i>",
|
||||
// 'url' => "$url/deactivate/?slug=$slug",
|
||||
// ]);
|
||||
}
|
||||
});
|
||||
|
||||
$table->addAction(function ($row, $url) use ($moduleService) {
|
||||
$slug = $row['slug'];
|
||||
// return "<a class='btn btn-primary' href='$url/view/?slug=$slug' style='margin: 3px; width: 150px;' >Просмотр</a>";
|
||||
|
||||
return ActionButton::create([
|
||||
return ActionButtonWidget::create([
|
||||
'btn_type' => "primary",
|
||||
'label' => "<i class='fa-regular fa-eye'></i>",
|
||||
'url' => "$url/view/?slug=$slug",
|
||||
]);
|
||||
])->run();
|
||||
});
|
||||
|
||||
$table->addAction(function ($row, $url) use ($moduleService){
|
||||
$slug = $row['slug'];
|
||||
if (!$moduleService->isKernelModule($slug)){
|
||||
if (!$moduleService->isLastVersion($slug)) {
|
||||
$label = "Обновить";
|
||||
$btn_type = "info";
|
||||
return "<a class='btn btn-$btn_type' href='$url/update/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>";
|
||||
return ActionButtonWidget::create([
|
||||
'btn_type' => "info",
|
||||
'label' => "<i class='fa-regular fa-pen-to-square'></i>",
|
||||
'url' => "$url/view/?slug=$slug",
|
||||
])->run();
|
||||
}
|
||||
}
|
||||
|
||||
@ -80,21 +75,17 @@ $table->addAction(function ($row, $url) use ($moduleService){
|
||||
$table->addAction(function ($row) use ($moduleService){
|
||||
$slug = $row['slug'];
|
||||
if (!$moduleService->isKernelModule($slug)) {
|
||||
// $label = "Удалить";
|
||||
// $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 ActionButton::create([
|
||||
return ActionButtonWidget::create([
|
||||
'btn_type' => "danger",
|
||||
'label' => "<i class='fa-regular fa-trash-can'></i>",
|
||||
'url' => "admin/module_shop_client/delete/?slug=$slug",
|
||||
]);
|
||||
])->run();
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
if ($moduleService->isActive('module_shop_client')) {
|
||||
\kernel\widgets\ModuleTabsWidget::create()->run();
|
||||
ModuleTabsWidget::create()->run();
|
||||
}
|
||||
|
||||
$table->create();
|
||||
|
@ -2,10 +2,17 @@
|
||||
|
||||
namespace kernel\widgets;
|
||||
|
||||
use kernel\helpers\Debug;
|
||||
use kernel\Widget;
|
||||
|
||||
class ActionButtonWidget extends Widget
|
||||
{
|
||||
|
||||
public static function create(array $data = []): ActionButtonWidget
|
||||
{
|
||||
return new static($data);
|
||||
}
|
||||
|
||||
public function run(): string
|
||||
{
|
||||
$label = $this->data['label'];
|
||||
|
Loading…
Reference in New Issue
Block a user