From 0bfeabce33cead33338f7636db2dd401e0973711 Mon Sep 17 00:00:00 2001
From: Kavalar <apuc06@mail.ru>
Date: Tue, 19 Nov 2024 16:52:00 +0300
Subject: [PATCH] action btn

---
 app/modules/tag/manifest.json                |  2 +-
 kernel/app_modules/tag/views/index.php       |  4 +++
 kernel/views/module/index.php                | 14 +++++-----
 kernel/views/widgets/action_button.php       |  3 ++-
 kernel/widgets/ActionButtonWidget.php        |  3 ++-
 kernel/widgets/IconBtn/IconBtnViewWidget.php | 27 ++++++++++++++++++++
 6 files changed, 42 insertions(+), 11 deletions(-)
 create mode 100644 kernel/widgets/IconBtn/IconBtnViewWidget.php

diff --git a/app/modules/tag/manifest.json b/app/modules/tag/manifest.json
index 39df526..3967dd6 100644
--- a/app/modules/tag/manifest.json
+++ b/app/modules/tag/manifest.json
@@ -1,6 +1,6 @@
 {
   "name": "Tags",
-  "version": "0.12",
+  "version": "0.2",
   "author": "ITGuild",
   "slug": "tag",
   "description": "Tags module",
diff --git a/kernel/app_modules/tag/views/index.php b/kernel/app_modules/tag/views/index.php
index ceacd8f..0d5503f 100644
--- a/kernel/app_modules/tag/views/index.php
+++ b/kernel/app_modules/tag/views/index.php
@@ -8,6 +8,10 @@ use Itguild\EloquentTable\EloquentDataProvider;
 use Itguild\EloquentTable\ListEloquentTable;
 use kernel\app_modules\tag\models\Tag;
 use kernel\IGTabel\btn\PrimaryBtn;
+use kernel\models\Menu;
+use kernel\modules\menu\table\columns\MenuDeleteActionColumn;
+use kernel\modules\menu\table\columns\MenuEditActionColumn;
+use kernel\modules\menu\table\columns\MenuViewActionColumn;
 
 $table = new ListEloquentTable(new EloquentDataProvider(Tag::class, [
     'currentPage' => $page_number,
diff --git a/kernel/views/module/index.php b/kernel/views/module/index.php
index b1d887d..e5becf3 100644
--- a/kernel/views/module/index.php
+++ b/kernel/views/module/index.php
@@ -8,6 +8,7 @@
  */
 
 use kernel\widgets\ActionButtonWidget;
+use kernel\widgets\IconBtn\IconBtnViewWidget;
 use kernel\widgets\ModuleTabsWidget;
 
 $meta = [];
@@ -41,20 +42,17 @@ $table->addAction(function ($row, $url) use ($moduleService) {
     } else {
         return ActionButtonWidget::create([
             'label' => "<i class='fa-regular fa-circle-check'></i>",
-            'url' => "$url/deactivate/?slug=$slug",
-            'btn_type' => "success"
+            'url' => "$url/activate/?slug=$slug",
+            'btn_type' => "success",
+            'title' => "Активировать",
         ])->run();
     }
 });
 
 $table->addAction(function ($row, $url) use ($moduleService) {
-    $slug = $row['slug'];
+    $url = "$url/view/?slug=". $row['slug'];
 
-    return ActionButtonWidget::create([
-        'btn_type' => "primary",
-        'label' => "<i class='fa-regular fa-eye'></i>",
-        'url' => "$url/view/?slug=$slug",
-    ])->run();
+    return IconBtnViewWidget::create(['url' => $url])->run();
 });
 
 $table->addAction(function ($row, $url) use ($moduleService){
diff --git a/kernel/views/widgets/action_button.php b/kernel/views/widgets/action_button.php
index 918d5ac..b58234d 100644
--- a/kernel/views/widgets/action_button.php
+++ b/kernel/views/widgets/action_button.php
@@ -3,7 +3,8 @@
  * @var string $label
  * @var string $btn_type
  * @var string $url
+ * @var string $title
  */
 ?>
 
-<a class='btn btn-<?= $btn_type ?>' href='<?= $url ?>' style='margin: 3px' ><?= $label ?></a>
\ No newline at end of file
+<a title="<?= $title ?>" class='btn btn-<?= $btn_type ?>' href='<?= $url ?>' style='margin: 3px' ><?= $label ?></a>
\ No newline at end of file
diff --git a/kernel/widgets/ActionButtonWidget.php b/kernel/widgets/ActionButtonWidget.php
index d13148a..13d57d1 100644
--- a/kernel/widgets/ActionButtonWidget.php
+++ b/kernel/widgets/ActionButtonWidget.php
@@ -18,7 +18,8 @@ class ActionButtonWidget extends Widget
         $label = $this->data['label'];
         $btn_type = $this->data['btn_type'];
         $url = $this->data['url'];
+        $title = $this->data['title'] ?? '';
 
-        return $this->cgView->fetch('/action_button.php', ['label' => $label, 'btn_type' => $btn_type, 'url' => $url]);
+        return $this->cgView->fetch('/action_button.php', ['label' => $label, 'btn_type' => $btn_type, 'url' => $url, 'title' => $title]);
     }
 }
\ No newline at end of file
diff --git a/kernel/widgets/IconBtn/IconBtnViewWidget.php b/kernel/widgets/IconBtn/IconBtnViewWidget.php
new file mode 100644
index 0000000..73ee3d8
--- /dev/null
+++ b/kernel/widgets/IconBtn/IconBtnViewWidget.php
@@ -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();
+    }
+
+}
\ No newline at end of file