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

parent d22a026e
......@@ -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() {
......
......@@ -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')">
......
......@@ -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);
}
}
}
......
......@@ -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;
}
}
......@@ -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: {
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