Skip to content

Commit

Permalink
Add Role column to admin user grid
Browse files Browse the repository at this point in the history
  • Loading branch information
mpchadwick committed Sep 14, 2017
1 parent 659a245 commit 3445928
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions app/code/Magento/User/Model/ResourceModel/User/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,18 @@ protected function _construct()
{
$this->_init(\Magento\User\Model\User::class, \Magento\User\Model\ResourceModel\User::class);
}

public function _initSelect()
{
parent::_initSelect();
$this->getSelect()->join(
['user_role' => $this->getTable('authorization_role')],
'main_table.user_id = user_role.user_id',
[]
)->join(
['detail_role' => $this->getTable('authorization_role')],
'user_role.parent_id = detail_role.role_id',
['role_name']
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@
<argument name="index" xsi:type="string">email</argument>
</arguments>
</block>
<block class="Magento\Backend\Block\Widget\Grid\Column" as="role_name">
<arguments>
<argument name="header" xsi:type="string" translate="true">Role</argument>
<argument name="index" xsi:type="string">role_name</argument>
<argument name="filter_index" xsi:type="string">detail_role.role_name</argument>
</arguments>
</block>
<block class="Magento\Backend\Block\Widget\Grid\Column" as="is_active">
<arguments>
<argument name="header" xsi:type="string" translate="true">Status</argument>
Expand Down

0 comments on commit 3445928

Please sign in to comment.