Creating and using a current_permission_value_for_roles helper, which defaults to -1 (deny)

parent d22a026e
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
{{ trans('roles.allow all') }} {{ trans('roles.allow all') }}
</el-button> </el-button>
<el-button type="text" <el-button type="text"
:disabled="isRole"
@click="changeState(subPermissionTitle, permissionActions, 0)"> @click="changeState(subPermissionTitle, permissionActions, 0)">
{{ trans('roles.inherit all') }} {{ trans('roles.inherit all') }}
</el-button> </el-button>
...@@ -40,7 +41,7 @@ ...@@ -40,7 +41,7 @@
<div class="col-md-9"> <div class="col-md-9">
<el-radio-group v-model="permissions[`${subPermissionTitle}.${permissionAction}`]"> <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="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-button :label="-1" @click="triggerEvent">{{ trans('roles.deny') }}</el-radio-button>
</el-radio-group> </el-radio-group>
</div> </div>
...@@ -59,6 +60,7 @@ ...@@ -59,6 +60,7 @@
export default { export default {
mixins: [StringHelpers], mixins: [StringHelpers],
props: { props: {
isRole: { type: Boolean },
currentPermissions: { default: null }, currentPermissions: { default: null },
}, },
data() { data() {
......
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="trans('roles.tabs.permissions')"> <el-tab-pane :label="trans('roles.tabs.permissions')">
<asgard-permissions v-model="role.permissions" <asgard-permissions v-model="role.permissions"
is-role
:current-permissions="role.permissions"></asgard-permissions> :current-permissions="role.permissions"></asgard-permissions>
</el-tab-pane> </el-tab-pane>
<el-tab-pane :label="trans('users.title.users')"> <el-tab-pane :label="trans('users.title.users')">
......
...@@ -38,7 +38,7 @@ class FullRoleTransformer extends Resource ...@@ -38,7 +38,7 @@ class FullRoleTransformer extends Resource
foreach ($permissionsConfig as $mainKey => $subPermissions) { foreach ($permissionsConfig as $mainKey => $subPermissions) {
foreach ($subPermissions as $key => $permissionGroup) { foreach ($subPermissions as $key => $permissionGroup) {
foreach ($permissionGroup as $lastKey => $description) { 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);
} }
} }
} }
......
...@@ -14,3 +14,14 @@ if (function_exists('current_permission_value') === false) { ...@@ -14,3 +14,14 @@ if (function_exists('current_permission_value') === false) {
return 0; 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;
}
}
...@@ -106410,6 +106410,7 @@ exports.default = { ...@@ -106410,6 +106410,7 @@ exports.default = {
// //
// //
// //
//
/***/ }), /***/ }),
/* 508 */ /* 508 */
...@@ -106580,10 +106581,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de ...@@ -106580,10 +106581,12 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
// //
// //
// //
//
exports.default = { exports.default = {
mixins: [_StringHelpers2.default], mixins: [_StringHelpers2.default],
props: { props: {
isRole: { type: Boolean },
currentPermissions: { default: null } currentPermissions: { default: null }
}, },
data: function data() { data: function data() {
...@@ -106690,7 +106693,7 @@ var render = function() { ...@@ -106690,7 +106693,7 @@ var render = function() {
_c( _c(
"el-button", "el-button",
{ {
attrs: { type: "text" }, attrs: { type: "text", disabled: _vm.isRole },
on: { on: {
click: function($event) { click: function($event) {
_vm.changeState( _vm.changeState(
...@@ -106815,7 +106818,7 @@ var render = function() { ...@@ -106815,7 +106818,7 @@ var render = function() {
_c( _c(
"el-radio-button", "el-radio-button",
{ {
attrs: { label: 0 }, attrs: { label: 0, disabled: _vm.isRole },
on: { click: _vm.triggerEvent } on: { click: _vm.triggerEvent }
}, },
[_vm._v(_vm._s(_vm.trans("roles.inherit")))] [_vm._v(_vm._s(_vm.trans("roles.inherit")))]
...@@ -107057,6 +107060,7 @@ var render = function() { ...@@ -107057,6 +107060,7 @@ var render = function() {
[ [
_c("asgard-permissions", { _c("asgard-permissions", {
attrs: { attrs: {
"is-role": "",
"current-permissions": _vm.role.permissions "current-permissions": _vm.role.permissions
}, },
model: { model: {
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment