diff --git a/kernel/IGTabel/btn/ActionButton.php b/kernel/IGTabel/btn/ActionButton.php deleted file mode 100644 index a11431c..0000000 --- a/kernel/IGTabel/btn/ActionButton.php +++ /dev/null @@ -1,15 +0,0 @@ -$label"; - } -} \ No newline at end of file diff --git a/kernel/modules/admin_themes/views/index.php b/kernel/modules/admin_themes/views/index.php index 50d728e..14ca134 100644 --- a/kernel/modules/admin_themes/views/index.php +++ b/kernel/modules/admin_themes/views/index.php @@ -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 = "Активировать"; + $btn = ActionButtonWidget::create([ + 'btn_type' => "primary", + 'label' => "Активировать", + 'url' => "$url/activate/?p=$path", + ])->run(); + if ($path === $active_admin_theme){ $btn = "Активна"; } diff --git a/kernel/modules/module_shop_client/views/index.php b/kernel/modules/module_shop_client/views/index.php index ab0199c..c54f279 100644 --- a/kernel/modules/module_shop_client/views/index.php +++ b/kernel/modules/module_shop_client/views/index.php @@ -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' => "", + '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 = "$label"; + return ActionButtonWidget::create([ + 'btn_type' => "danger", + 'label' => "", + 'url' => "$url/delete/?slug=$slug", + ])->run(); } else { - $label = "Установить"; - $btn_type = "success"; - $btn = "$label"; + return ActionButtonWidget::create([ + 'btn_type' => "success", + 'label' => "", + '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 "$label"; + return ActionButtonWidget::create([ + 'btn_type' => "info", + 'label' => "", + 'url' => "$url/update/?slug=$slug", + ])->run(); } } diff --git a/kernel/views/module/index.php b/kernel/views/module/index.php index f53961f..b1d887d 100644 --- a/kernel/views/module/index.php +++ b/kernel/views/module/index.php @@ -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' => "", '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' => "", -// 'url' => "$url/deactivate/?slug=$slug", -// ]); } }); $table->addAction(function ($row, $url) use ($moduleService) { $slug = $row['slug']; -// return "Просмотр"; - return ActionButton::create([ + return ActionButtonWidget::create([ 'btn_type' => "primary", 'label' => "", '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 "$label"; + return ActionButtonWidget::create([ + 'btn_type' => "info", + 'label' => "", + 'url' => "$url/view/?slug=$slug", + ])->run(); } } @@ -79,22 +74,18 @@ $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 "$label"; - - return ActionButton::create([ + if (!$moduleService->isKernelModule($slug)) { + return ActionButtonWidget::create([ 'btn_type' => "danger", 'label' => "", '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(); diff --git a/kernel/widgets/ActionButtonWidget.php b/kernel/widgets/ActionButtonWidget.php index 5dc6ac1..d13148a 100644 --- a/kernel/widgets/ActionButtonWidget.php +++ b/kernel/widgets/ActionButtonWidget.php @@ -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'];