Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Platform
Commits
0ca58c65
Unverified
Commit
0ca58c65
authored
Oct 11, 2017
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Creating and using a current_permission_value_for_roles helper, which defaults to -1 (deny)
parent
d22a026e
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
4 deletions
+22
-4
AsgardPermissions.vue
Modules/User/Assets/js/components/AsgardPermissions.vue
+3
-1
RoleForm.vue
Modules/User/Assets/js/components/RoleForm.vue
+1
-0
FullRoleTransformer.php
Modules/User/Transformers/FullRoleTransformer.php
+1
-1
helpers.php
Modules/User/helpers.php
+11
-0
app.js
public/js/app.js
+6
-2
No files found.
Modules/User/Assets/js/components/AsgardPermissions.vue
View file @
0ca58c65
...
...
@@ -14,6 +14,7 @@
{{
trans
(
'
roles.allow all
'
)
}}
</el-button>
<el-button
type=
"text"
:disabled=
"isRole"
@
click=
"changeState(subPermissionTitle, permissionActions, 0)"
>
{{
trans
(
'
roles.inherit all
'
)
}}
</el-button>
...
...
@@ -40,7 +41,7 @@
<div
class=
"col-md-9"
>
<el-radio-group
v-model=
"permissions[`$
{subPermissionTitle}.${permissionAction}`]">
<el-radio-button
:label=
"1"
@
click=
"triggerEvent"
>
{{
trans
(
'
roles.allow
'
)
}}
</el-radio-button>
<el-radio-button
:label=
"0"
@
click=
"triggerEvent"
>
{{
trans
(
'
roles.inherit
'
)
}}
</el-radio-button>
<el-radio-button
:label=
"0"
@
click=
"triggerEvent"
:disabled=
"isRole"
>
{{
trans
(
'
roles.inherit
'
)
}}
</el-radio-button>
<el-radio-button
:label=
"-1"
@
click=
"triggerEvent"
>
{{
trans
(
'
roles.deny
'
)
}}
</el-radio-button>
</el-radio-group>
</div>
...
...
@@ -59,6 +60,7 @@
export
default
{
mixins
:
[
StringHelpers
],
props
:
{
isRole
:
{
type
:
Boolean
},
currentPermissions
:
{
default
:
null
},
},
data
()
{
...
...
Modules/User/Assets/js/components/RoleForm.vue
View file @
0ca58c65
...
...
@@ -44,6 +44,7 @@
<
/el-tab-pane
>
<
el
-
tab
-
pane
:
label
=
"
trans('roles.tabs.permissions')
"
>
<
asgard
-
permissions
v
-
model
=
"
role.permissions
"
is
-
role
:
current
-
permissions
=
"
role.permissions
"
><
/asgard-permissions
>
<
/el-tab-pane
>
<
el
-
tab
-
pane
:
label
=
"
trans('users.title.users')
"
>
...
...
Modules/User/Transformers/FullRoleTransformer.php
View file @
0ca58c65
...
...
@@ -38,7 +38,7 @@ class FullRoleTransformer extends Resource
foreach
(
$permissionsConfig
as
$mainKey
=>
$subPermissions
)
{
foreach
(
$subPermissions
as
$key
=>
$permissionGroup
)
{
foreach
(
$permissionGroup
as
$lastKey
=>
$description
)
{
$list
[
strtolower
(
$key
)
.
'.'
.
$lastKey
]
=
current_permission_value
(
$this
,
$key
,
$lastKey
);
$list
[
strtolower
(
$key
)
.
'.'
.
$lastKey
]
=
current_permission_value
_for_roles
(
$this
,
$key
,
$lastKey
);
}
}
}
...
...
Modules/User/helpers.php
View file @
0ca58c65
...
...
@@ -14,3 +14,14 @@ if (function_exists('current_permission_value') === false) {
return
0
;
}
}
if
(
function_exists
(
'current_permission_value_for_roles'
)
===
false
)
{
function
current_permission_value_for_roles
(
$model
,
$permissionTitle
,
$permissionAction
)
{
$value
=
array_get
(
$model
->
permissions
,
"
$permissionTitle
.
$permissionAction
"
);
if
(
$value
===
true
)
{
return
1
;
}
return
-
1
;
}
}
public/js/app.js
View file @
0ca58c65
...
...
@@ -106410,6 +106410,7 @@ exports.default = {
//
//
//
//
/***/ }),
/* 508 */
...
...
@@ -106580,10 +106581,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
//
//
//
//
exports.default = {
mixins: [_StringHelpers2.default],
props: {
isRole: { type: Boolean },
currentPermissions: { default: null }
},
data: function data() {
...
...
@@ -106690,7 +106693,7 @@ var render = function() {
_c(
"el-button",
{
attrs: { type: "text" },
attrs: { type: "text"
, disabled: _vm.isRole
},
on: {
click: function($event) {
_vm.changeState(
...
...
@@ -106815,7 +106818,7 @@ var render = function() {
_c(
"el-radio-button",
{
attrs: { label: 0 },
attrs: { label: 0
, disabled: _vm.isRole
},
on: { click: _vm.triggerEvent }
},
[_vm._v(_vm._s(_vm.trans("roles.inherit")))]
...
...
@@ -107057,6 +107060,7 @@ var render = function() {
[
_c("asgard-permissions", {
attrs: {
"is-role": "",
"current-permissions": _vm.role.permissions
},
model: {
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment