action button widget

This commit is contained in:
Билай Станислав 2024-11-19 11:21:46 +03:00
parent f4b0f006aa
commit 202d265cab
5 changed files with 28 additions and 5 deletions

View File

@ -14,7 +14,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/bootstrap.min.css"> <link rel="stylesheet" href="<?= $resources ?>/css/bootstrap.min.css">
<link rel="stylesheet" href="<?= $resources ?>/css/style.css"> <link rel="stylesheet" href="<?= $resources ?>/css/style.css">
</head> </head>

View File

@ -122,8 +122,6 @@ class ModuleController extends AdminController
$this->redirect("/admin/module_shop_client/update/?slug=" . $slug, 302); $this->redirect("/admin/module_shop_client/update/?slug=" . $slug, 302);
} }
$this->cgView->render("view.php", ['data' => $mod_info]); $this->cgView->render("view.php", ['data' => $mod_info]);
} }

View File

@ -34,9 +34,9 @@ $table->addAction(function ($row, $url) use ($moduleService) {
$btn = "<a class='btn btn-$btn_type' href='$url/deactivate/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>"; $btn = "<a class='btn btn-$btn_type' href='$url/deactivate/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>";
} else { } else {
$label = "Активировать"; $label = "<i class='fa-regular fa-circle-check'></i>";
$btn_type = "success"; $btn_type = "success";
$btn = "<a class='btn btn-$btn_type' href='$url/activate/?slug=$slug' style='margin: 3px; width: 150px;' >$label</a>"; $btn = "<a class='btn btn-$btn_type' href='$url/activate/?slug=$slug' style='margin: 3px;' >$label</a>";
} }
return $btn; return $btn;

View File

@ -0,0 +1,16 @@
<?php
namespace kernel\widgets;
use kernel\Widget;
class ActionButtonWidget extends Widget
{
public function run(): void
{
$icon = $this->data['icon'];
$btn = $this->data['btn'];
$url = $this->data['url'];
$this->cgView->render('/admin/action_button.php', ['icon' => $icon, 'btn' => $btn, 'url' => $url]);
}
}

View File

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