Issue #348 fixed

This commit is contained in:
jitendra 2018-12-20 16:24:30 +05:30
parent a1c7e4c73a
commit 9654748f1f
7 changed files with 86 additions and 12 deletions

View File

@ -35,6 +35,8 @@ class AdminServiceProvider extends ServiceProvider
$this->composeView();
$this->registerACL();
$this->app->register(EventServiceProvider::class);
$this->app->bind(
@ -87,17 +89,44 @@ class AdminServiceProvider extends ServiceProvider
});
view()->composer(['admin::users.roles.create', 'admin::users.roles.edit'], function ($view) {
$tree = Tree::create();
foreach(config('acl') as $item) {
$tree->add($item);
}
$tree->items = core()->sortItems($tree->items);
$view->with('acl', $tree);
$view->with('acl', $this->createACL());
});
}
/**
* Registers acl to entire application
*
* @return void
*/
public function registerACL()
{
$this->app->singleton('acl', function () {
return $this->createACL();
});
}
/**
* Create acl tree
*
* @return mixed
*/
public function createACL()
{
static $tree;
if($tree)
return $tree;
$tree = Tree::create();
foreach(config('acl') as $item) {
$tree->add($item, 'acl');
}
$tree->items = core()->sortItems($tree->items);
return $tree;
}
/**
* Register package config.

View File

@ -19,6 +19,13 @@ class Tree {
*/
public $items = [];
/**
* Contains acl roles
*
* @var array
*/
public $roles = [];
/**
* Contains current item route
*
@ -74,11 +81,14 @@ class Tree {
if (strpos($this->current, $item['url']) !== false) {
$this->currentKey = $item['key'];
}
} else if ($type == 'acl') {
$this->roles[$item['route']] = $item['key'];
}
$children = str_replace('.', '.children.', $item['key']);
core()->array_set($this->items, $children, $item);
}
/**

View File

@ -61,6 +61,26 @@ return [
'type' => 'textarea',
'channel_based' => true,
'locale_based' => false
], [
'name' => 'default_rate',
'title' => 'Rate',
'type' => 'text',
'channel_based' => true,
'locale_based' => false
], [
'name' => 'type',
'title' => 'Type',
'type' => 'select',
'options' => [
[
'title' => 'Per Unit',
'value' => 'Per Order'
], [
'title' => 'Inactive',
'value' => 'per_order'
]
],
'validation' => 'required'
], [
'name' => 'active',
'title' => 'Status',

View File

@ -17,6 +17,10 @@ $(document).ready(function () {
const app = new Vue({
el: "#app",
data: {
modalIds: {}
},
mounted: function () {
this.addServerErrors();
this.addFlashMessages();
@ -79,7 +83,11 @@ $(document).ready(function () {
}, this);
},
responsiveHeader: function () { }
responsiveHeader: function () { },
showModal(id) {
this.$set(this.modalIds, id, true);
}
}
});
});

View File

@ -101,6 +101,8 @@
{!! view_render_event('bagisto.shop.layout.body.after') !!}
<div class="modal-overlay"></div>
</body>
</html>

View File

@ -709,6 +709,11 @@ h2 {
}
}
modal {
display: none;
}
.modal-open {
overflow: hidden;
}

View File

@ -29,10 +29,10 @@ class Bouncer
public function checkIfAuthorized($request)
{
if(!$role = auth()->guard('admin')->user()->role)
if (!$role = auth()->guard('admin')->user()->role)
abort(401, 'This action is unauthorized.');
if($role->permission_type == 'all'){
if ($role->permission_type == 'all') {
return;
} else {
$acl = app('acl');