Skip to content

Commit

Permalink
Merge branch 'release/v0.4.4'
Browse files Browse the repository at this point in the history
  • Loading branch information
themodernpk committed Mar 26, 2020
2 parents d007792 + 9737135 commit e5c41e5
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 115 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"keywords": ["laravel", "cms"],
"homepage": "https://www.webreinvent.com",
"license": "MIT",
"version": "0.4.3",
"version": "0.4.4",
"authors": [
{
"name": "WebReinvent",
Expand Down
5 changes: 4 additions & 1 deletion src/Entities/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,10 @@ public static function syncRolesWithUsers()

//enable all roles for admin users
$admin_role = Role::slug('admin')->first();
$admin_users = $admin_role->users()->get()->pluck('id')->toArray();
$admin_users = $admin_role->users()->wherePivot('is_active', 1)
->get()
->pluck('id')
->toArray();
$pivotData = array_fill(0, count($admin_users), ['is_active' => 1]);
$syncData = array_combine($admin_users, $pivotData);
$admin_role->users()->syncWithoutDetaching($syncData);
Expand Down
5 changes: 4 additions & 1 deletion src/Http/Controllers/Admin/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,10 @@ public function actions(Request $request)
}

$item = User::find($inputs['inputs']['id']);
$item->roles()->updateExistingPivot($inputs['inputs']['user_id'], array('is_active' => $inputs['data']['is_active']));
$role = Role::find($inputs['inputs']['role_id']);

$item->roles()->updateExistingPivot($role, array('is_active' => $inputs['data']['is_active']), false);

Role::recountRelations();
$response['messages'] = [];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/assets/admin/default/builds/app-login.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Resources/assets/admin/default/builds/app-setup.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/Resources/assets/admin/default/builds/app.js

Large diffs are not rendered by default.

219 changes: 110 additions & 109 deletions src/Resources/assets/admin/default/vue/users/RolesJs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,126 +2,127 @@ import pagination from 'laravel-vue-pagination';
import TableLoader from "./../reusable/TableLoader";


export default {
export default {

props: ['urls', 'id'],
computed:{
ajax_url(){
let ajax_url = this.$store.state.urls.users;
return ajax_url;
}
},
components:{
't-loader': TableLoader,
'pagination': pagination,
},
data()
{
let obj = {
list: null,
item: null,
page: 1,
filters: {
q: null,
},
permission: null,
};
return obj;
},
watch: {

id: function (newVal, oldVal) {
this.getList();
},
'$route' (to, from) {
this.list = null;
props: ['urls', 'id'],
computed:{
ajax_url(){
let ajax_url = this.$store.state.urls.users;
return ajax_url;
}
},
components:{
't-loader': TableLoader,
'pagination': pagination,
},
data()
{
let obj = {
list: null,
item: null,
page: 1,
filters: {
q: null,
},
},
mounted() {
permission: null,
};
return obj;
},
watch: {

//---------------------------------------------------------------------
id: function (newVal, oldVal) {
this.getList();
//---------------------------------------------------------------------
//---------------------------------------------------------------------
//---------------------------------------------------------------------
//---------------------------------------------------------------------

},
methods: {
//---------------------------------------------------------------------
getList: function (page) {

var url = this.ajax_url+"/roles/"+this.id;

if(!page)
{
page = this.page;
}

this.$vaahcms.console(page, 'page');
url = url+"?page="+page;
if(this.filters.q)
{
url = url+"&q="+this.filters.q;
}
var params = {};
this.$vaahcms.ajax(url, params, this.getListAfter);
},
//---------------------------------------------------------------------
getListAfter: function (data) {
'$route' (to, from) {
this.list = null;
},
},
mounted() {

//---------------------------------------------------------------------
this.getList();
//---------------------------------------------------------------------
//---------------------------------------------------------------------
//---------------------------------------------------------------------
//---------------------------------------------------------------------

},
methods: {
//---------------------------------------------------------------------
getList: function (page) {

var url = this.ajax_url+"/roles/"+this.id;

if(!page)
{
page = this.page;
}

this.$vaahcms.console(data);
this.$vaahcms.console(page, 'page');
url = url+"?page="+page;
if(this.filters.q)
{
url = url+"&q="+this.filters.q;
}
var params = {};
this.$vaahcms.ajax(url, params, this.getListAfter);
},
//---------------------------------------------------------------------
getListAfter: function (data) {

this.list = data.list;
this.page = data.list.current_page;
this.item = data.item;
this.$vaahcms.console(data);

this.$vaahcms.stopNprogress();
},
this.list = data.list;
this.page = data.list.current_page;
this.item = data.item;

//---------------------------------------------------------------------
actions: function (e, action, inputs, data) {
if(e)
{
e.preventDefault();
}

var url = this.ajax_url+"/actions";
var params = {
action: action,
inputs: inputs,
data: data,
};

this.$vaahcms.ajax(url, params, this.actionsAfter);
},
//---------------------------------------------------------------------
actionsAfter: function (data) {
this.getList(this.page);
this.emitListReload();
},
//---------------------------------------------------------------------
toggleActiveStatus: function (item) {
var inputs = {id: this.id, user_id: item.id};
var data = {};
this.$vaahcms.stopNprogress();
},

if(item.pivot.is_active)
{
data.is_active = 0;
} else
{
data.is_active = 1;
}
//---------------------------------------------------------------------
actions: function (e, action, inputs, data) {
if(e)
{
e.preventDefault();
}

this.actions(false, 'toggle_role_active_status', inputs, data)
var url = this.ajax_url+"/actions";
var params = {
action: action,
inputs: inputs,
data: data,
};

},
//---------------------------------------------------------------------
emitListReload: function () {
this.$root.$emit('eListReload');
this.$vaahcms.ajax(url, params, this.actionsAfter);
},
//---------------------------------------------------------------------
actionsAfter: function (data) {
this.getList(this.page);
this.emitListReload();
},
//---------------------------------------------------------------------
toggleActiveStatus: function (item) {

var inputs = {id: this.id, role_id: item.pivot.vh_role_id};
var data = {};

if(item.pivot.is_active)
{
data.is_active = 0;
} else
{
data.is_active = 1;
}
//---------------------------------------------------------------------
//---------------------------------------------------------------------
//---------------------------------------------------------------------

this.actions(false, 'toggle_role_active_status', inputs, data)

},
//---------------------------------------------------------------------
emitListReload: function () {
this.$root.$emit('eListReload');
}
}
//---------------------------------------------------------------------
//---------------------------------------------------------------------
//---------------------------------------------------------------------
}
}

0 comments on commit e5c41e5

Please sign in to comment.