action btn
This commit is contained in:
parent
6c2798c123
commit
0bfeabce33
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Tags",
|
||||
"version": "0.12",
|
||||
"version": "0.2",
|
||||
"author": "ITGuild",
|
||||
"slug": "tag",
|
||||
"description": "Tags module",
|
||||
|
@ -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,
|
||||
|
@ -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){
|
||||
|
@ -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>
|
||||
<a title="<?= $title ?>" class='btn btn-<?= $btn_type ?>' href='<?= $url ?>' style='margin: 3px' ><?= $label ?></a>
|
@ -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]);
|
||||
}
|
||||
}
|
27
kernel/widgets/IconBtn/IconBtnViewWidget.php
Normal file
27
kernel/widgets/IconBtn/IconBtnViewWidget.php
Normal 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();
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user