Skip to content

Commit

Permalink
Added new Menu to Host
Browse files Browse the repository at this point in the history
  • Loading branch information
tafid committed Nov 29, 2016
1 parent ecc900a commit 224543e
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/menus/HostActionsMenu.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace hipanel\modules\domain\menus;

use hiqdev\menumanager\Menu;
use Yii;

class HostActionsMenu extends Menu
{
public $models;

public function items()
{
return [
[
'label' => Yii::t('hipanel', 'Delete'),
'icon' => 'fa-trash',
'url' => ['@host/delete', 'id' => $this->model->id],
'linkOptions' => [
'data' => [
'confirm' => Yii::t('hipanel', 'Are you sure you want to delete this item?'),
'method' => 'post',
'pjax' => '0',
]
],
],
];
}
}
18 changes: 18 additions & 0 deletions src/menus/HostDetailMenu.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

namespace hipanel\modules\domain\menus;

use hiqdev\menumanager\Menu;

class HostDetailMenu extends Menu
{
public $model;

public function items()
{
$actions = HostActionsMenu::create(['model' => $this->model])->items();
$items = array_merge($actions, []);

return $items;
}
}
5 changes: 5 additions & 0 deletions src/views/host/view.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

use hipanel\modules\domain\grid\HostGridView;
use hipanel\modules\domain\menus\HostDetailMenu;
use hipanel\widgets\Box;
use hipanel\widgets\ClientSellerLink;
use hipanel\widgets\Pjax;
use hiqdev\menumanager\widgets\DetailMenu;
use yii\helpers\Html;

$this->title = Html::encode($model->host);
Expand Down Expand Up @@ -32,6 +34,9 @@
<br>
<span class="profile-user-name"><?= ClientSellerLink::widget(compact('model')) ?></span>
</p>
<div class="profile-usermenu">
<?= HostDetailMenu::create(['model' => $model])->render(DetailMenu::class) ?>
</div>
<?php Box::end() ?>
</div>

Expand Down

0 comments on commit 224543e

Please sign in to comment.