Adding the ability to allow, inherit or deny for all permissions at once

parent 28d49acb
<template> <template>
<div> <div>
<p class="pull-right">
<el-button type="text"
@click="changeStateForAll(1)">
{{ trans('roles.allow all') }}
</el-button>
<el-button type="text"
:disabled="isRole"
@click="changeStateForAll(0)">
{{ trans('roles.inherit all') }}
</el-button>
<el-button type="text"
@click="changeStateForAll(-1)">
{{ trans('roles.deny all') }}
</el-button>
</p>
<div v-for="(value, name) in allPermissions" :key="name"> <div v-for="(value, name) in allPermissions" :key="name">
<h3>{{ name }}</h3> <h3>{{ name }}</h3>
<div v-for="(permissionActions, subPermissionTitle) in value" :key="subPermissionTitle"> <div v-for="(permissionActions, subPermissionTitle) in value" :key="subPermissionTitle">
...@@ -84,6 +99,11 @@ ...@@ -84,6 +99,11 @@
this.permissions[`${permissionPart}.${key}`] = state; this.permissions[`${permissionPart}.${key}`] = state;
}); });
}, },
changeStateForAll(state) {
_.forEach(this.permissions, (index, permission) => {
this.permissions[permission] = state;
});
},
fetchPermissions() { fetchPermissions() {
axios.get(route('api.user.permissions.index')) axios.get(route('api.user.permissions.index'))
.then((response) => { .then((response) => {
......
...@@ -106583,6 +106583,21 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de ...@@ -106583,6 +106583,21 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
// //
// //
// //
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
exports.default = { exports.default = {
mixins: [_StringHelpers2.default], mixins: [_StringHelpers2.default],
...@@ -106614,12 +106629,19 @@ exports.default = { ...@@ -106614,12 +106629,19 @@ exports.default = {
_this.permissions[permissionPart + '.' + key] = state; _this.permissions[permissionPart + '.' + key] = state;
}); });
}, },
fetchPermissions: function fetchPermissions() { changeStateForAll: function changeStateForAll(state) {
var _this2 = this; var _this2 = this;
_.forEach(this.permissions, function (index, permission) {
_this2.permissions[permission] = state;
});
},
fetchPermissions: function fetchPermissions() {
var _this3 = this;
_axios2.default.get(route('api.user.permissions.index')).then(function (response) { _axios2.default.get(route('api.user.permissions.index')).then(function (response) {
_this2.loading = false; _this3.loading = false;
_this2.allPermissions = response.data.permissions; _this3.allPermissions = response.data.permissions;
}); });
} }
}, },
...@@ -106645,211 +106667,278 @@ var render = function() { ...@@ -106645,211 +106667,278 @@ var render = function() {
var _c = _vm._self._c || _h var _c = _vm._self._c || _h
return _c( return _c(
"div", "div",
_vm._l(_vm.allPermissions, function(value, name) { [
return _c( _c(
"div", "p",
{ key: name }, { staticClass: "pull-right" },
[ [
_c("h3", [_vm._v(_vm._s(name))]), _c(
"el-button",
{
attrs: { type: "text" },
on: {
click: function($event) {
_vm.changeStateForAll(1)
}
}
},
[
_vm._v(
"\n " +
_vm._s(_vm.trans("roles.allow all")) +
"\n "
)
]
),
_vm._v(" "), _vm._v(" "),
_vm._l(value, function(permissionActions, subPermissionTitle) { _c(
return _c("div", { key: subPermissionTitle }, [ "el-button",
_c("div", { staticClass: "row" }, [ {
_c("div", { staticClass: "col-md-12" }, [ attrs: { type: "text", disabled: _vm.isRole },
_c("div", { staticClass: "row" }, [ on: {
_c("div", { staticClass: "col-md-3" }, [ click: function($event) {
_c("h4", { staticClass: "pull-left" }, [ _vm.changeStateForAll(0)
_vm._v(_vm._s(_vm.ucfirst(subPermissionTitle))) }
]) }
]), },
_vm._v(" "), [
_c("div", { staticClass: "col-md-9" }, [ _vm._v(
_c( "\n " +
"p", _vm._s(_vm.trans("roles.inherit all")) +
{ staticStyle: { "margin-top": "10px" } }, "\n "
[ )
_c( ]
"el-button", ),
{ _vm._v(" "),
attrs: { type: "text" }, _c(
on: { "el-button",
click: function($event) { {
_vm.changeState( attrs: { type: "text" },
subPermissionTitle, on: {
permissionActions, click: function($event) {
1 _vm.changeStateForAll(-1)
) }
} }
} },
}, [
[ _vm._v(
_vm._v( "\n " +
"\n " + _vm._s(_vm.trans("roles.deny all")) +
_vm._s(_vm.trans("roles.allow all")) + "\n "
"\n " )
) ]
] )
), ],
_vm._v(" "), 1
_c( ),
"el-button", _vm._v(" "),
{ _vm._l(_vm.allPermissions, function(value, name) {
attrs: { type: "text", disabled: _vm.isRole }, return _c(
on: { "div",
click: function($event) { { key: name },
_vm.changeState( [
subPermissionTitle, _c("h3", [_vm._v(_vm._s(name))]),
permissionActions, _vm._v(" "),
0 _vm._l(value, function(permissionActions, subPermissionTitle) {
) return _c("div", { key: subPermissionTitle }, [
} _c("div", { staticClass: "row" }, [
} _c("div", { staticClass: "col-md-12" }, [
}, _c("div", { staticClass: "row" }, [
[ _c("div", { staticClass: "col-md-3" }, [
_vm._v( _c("h4", { staticClass: "pull-left" }, [
"\n " + _vm._v(_vm._s(_vm.ucfirst(subPermissionTitle)))
_vm._s(_vm.trans("roles.inherit all")) + ])
"\n " ]),
) _vm._v(" "),
] _c("div", { staticClass: "col-md-9" }, [
),
_vm._v(" "),
_c(
"el-button",
{
attrs: { type: "text" },
on: {
click: function($event) {
_vm.changeState(
subPermissionTitle,
permissionActions,
-1
)
}
}
},
[
_vm._v(
"\n " +
_vm._s(_vm.trans("roles.deny all")) +
"\n "
)
]
)
],
1
)
])
])
])
]),
_vm._v(" "),
_c(
"div",
{ staticClass: "row" },
_vm._l(permissionActions, function(label, permissionAction) {
return _c(
"div",
{ key: permissionAction, staticClass: "col-md-12" },
[
_c("div", { staticClass: "row" }, [
_c("div", { staticClass: "col-md-3" }, [
_c(
"div",
{
staticClass:
"visible-sm-block visible-md-block visible-lg-block"
},
[
_c(
"label",
{
staticClass: "control-label text-right",
staticStyle: { display: "block" }
},
[_vm._v(_vm._s(_vm.parseTranslation(label)))]
)
]
),
_vm._v(" "),
_c("div", { staticClass: "visible-xs-block" }, [
_c("label", { staticClass: "control-label" }, [
_vm._v(_vm._s(_vm.parseTranslation(label)))
])
])
]),
_vm._v(" "),
_c( _c(
"div", "p",
{ staticClass: "col-md-9" }, { staticStyle: { "margin-top": "10px" } },
[ [
_c( _c(
"el-radio-group", "el-button",
{ {
model: { attrs: { type: "text" },
value: on: {
_vm.permissions[ click: function($event) {
subPermissionTitle + _vm.changeState(
"." + subPermissionTitle,
permissionAction permissionActions,
], 1
callback: function($$v) {
_vm.$set(
_vm.permissions,
subPermissionTitle +
"." +
permissionAction,
$$v
) )
}, }
expression:
"permissions[`${subPermissionTitle}.${permissionAction}`]"
} }
}, },
[ [
_c( _vm._v(
"el-radio-button", "\n " +
{ _vm._s(_vm.trans("roles.allow all")) +
attrs: { label: 1 }, "\n "
on: { click: _vm.triggerEvent }
},
[_vm._v(_vm._s(_vm.trans("roles.allow")))]
),
_vm._v(" "),
_c(
"el-radio-button",
{
attrs: { label: 0, disabled: _vm.isRole },
on: { click: _vm.triggerEvent }
},
[_vm._v(_vm._s(_vm.trans("roles.inherit")))]
),
_vm._v(" "),
_c(
"el-radio-button",
{
attrs: { label: -1 },
on: { click: _vm.triggerEvent }
},
[_vm._v(_vm._s(_vm.trans("roles.deny")))]
) )
], ]
1 ),
_vm._v(" "),
_c(
"el-button",
{
attrs: { type: "text", disabled: _vm.isRole },
on: {
click: function($event) {
_vm.changeState(
subPermissionTitle,
permissionActions,
0
)
}
}
},
[
_vm._v(
"\n " +
_vm._s(_vm.trans("roles.inherit all")) +
"\n "
)
]
),
_vm._v(" "),
_c(
"el-button",
{
attrs: { type: "text" },
on: {
click: function($event) {
_vm.changeState(
subPermissionTitle,
permissionActions,
-1
)
}
}
},
[
_vm._v(
"\n " +
_vm._s(_vm.trans("roles.deny all")) +
"\n "
)
]
) )
], ],
1 1
) )
]) ])
] ])
) ])
}) ]),
) _vm._v(" "),
]) _c(
}) "div",
], { staticClass: "row" },
2 _vm._l(permissionActions, function(label, permissionAction) {
) return _c(
}) "div",
{ key: permissionAction, staticClass: "col-md-12" },
[
_c("div", { staticClass: "row" }, [
_c("div", { staticClass: "col-md-3" }, [
_c(
"div",
{
staticClass:
"visible-sm-block visible-md-block visible-lg-block"
},
[
_c(
"label",
{
staticClass: "control-label text-right",
staticStyle: { display: "block" }
},
[_vm._v(_vm._s(_vm.parseTranslation(label)))]
)
]
),
_vm._v(" "),
_c("div", { staticClass: "visible-xs-block" }, [
_c("label", { staticClass: "control-label" }, [
_vm._v(_vm._s(_vm.parseTranslation(label)))
])
])
]),
_vm._v(" "),
_c(
"div",
{ staticClass: "col-md-9" },
[
_c(
"el-radio-group",
{
model: {
value:
_vm.permissions[
subPermissionTitle +
"." +
permissionAction
],
callback: function($$v) {
_vm.$set(
_vm.permissions,
subPermissionTitle +
"." +
permissionAction,
$$v
)
},
expression:
"permissions[`${subPermissionTitle}.${permissionAction}`]"
}
},
[
_c(
"el-radio-button",
{
attrs: { label: 1 },
on: { click: _vm.triggerEvent }
},
[_vm._v(_vm._s(_vm.trans("roles.allow")))]
),
_vm._v(" "),
_c(
"el-radio-button",
{
attrs: { label: 0, disabled: _vm.isRole },
on: { click: _vm.triggerEvent }
},
[_vm._v(_vm._s(_vm.trans("roles.inherit")))]
),
_vm._v(" "),
_c(
"el-radio-button",
{
attrs: { label: -1 },
on: { click: _vm.triggerEvent }
},
[_vm._v(_vm._s(_vm.trans("roles.deny")))]
)
],
1
)
],
1
)
])
]
)
})
)
])
})
],
2
)
})
],
2
) )
} }
var staticRenderFns = [] var staticRenderFns = []
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