diversen opmerkingen
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* Created by Pensare Software.
|
||||
* User: Theo Weijmer
|
||||
* Date: 15/07/2018
|
||||
* Time: 10:50
|
||||
*/
|
||||
|
||||
|
||||
dbo.authorisationInit = function() {
|
||||
new Vue( {
|
||||
el : "#AUTHORISATION",
|
||||
data : {
|
||||
roles: [],
|
||||
pages: []
|
||||
},
|
||||
created: function () {
|
||||
var self = this;
|
||||
var srv = dbo.autorisationService;
|
||||
|
||||
srv.createRoles( function ( data ) {
|
||||
console.log( data.pages );
|
||||
self.roles = data.roles;
|
||||
self.pages = data.pages;
|
||||
} );
|
||||
},
|
||||
methods: {
|
||||
toggleAccess: function ( pageIndex, roleIndex ) {
|
||||
var page = this.pages[pageIndex];
|
||||
var access = page.accessPages[roleIndex];
|
||||
|
||||
page.accessPages[roleIndex].access = !page.accessPages[roleIndex].access;
|
||||
|
||||
var submitDATA = {
|
||||
pageID : page.pageID,
|
||||
roleLevel: access.roleLevel,
|
||||
access : page.accessPages[roleIndex].access ? 'T' : 'F'
|
||||
}
|
||||
|
||||
dbo.authorisationDataService.toggleAuhorisation( submitDATA );
|
||||
}
|
||||
}
|
||||
|
||||
} );
|
||||
};
|
||||
|
||||
dbo.autorisationService = {
|
||||
|
||||
roles : [],
|
||||
pages : [],
|
||||
initPages: true,
|
||||
|
||||
createRoles: function ( callback ) {
|
||||
var srv = dbo.autorisationService;
|
||||
|
||||
dbo.authorisationDataService.getRoleAuthorisations( function ( data ) {
|
||||
_.each( data, function ( p ) {
|
||||
srv.roles.push( new srv.Role( p ) );
|
||||
} );
|
||||
|
||||
_.each( data, function ( p ) {
|
||||
_.each( p.pagesAccess, function ( q ) {
|
||||
if ( srv.initPages ) {
|
||||
srv.pages.push( new srv.Page( q ) );
|
||||
} else {
|
||||
_.each( srv.pages, function ( s ) {
|
||||
if ( s.pageID == q.id ) {
|
||||
s.accessPages.push( new srv.Access( q ) )
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
||||
} );
|
||||
srv.initPages = false;
|
||||
} );
|
||||
|
||||
} );
|
||||
|
||||
callback( srv );
|
||||
},
|
||||
|
||||
Role: function ( data ) {
|
||||
this.roleID = data.id;
|
||||
this.rolename = data.rolename;
|
||||
},
|
||||
|
||||
Page: function ( data ) {
|
||||
var srv = dbo.autorisationService;
|
||||
|
||||
if ( srv.initPages ) {
|
||||
this.pageID = data.id;
|
||||
this.pagename = data.pagename;
|
||||
this.typePage = data.typepage;
|
||||
|
||||
this.accessPages = [];
|
||||
this.accessPages.push( new srv.Access( data ) );
|
||||
}
|
||||
},
|
||||
|
||||
Access: function ( data ) {
|
||||
this.access = data.pageaccess == 'T' ? true : false;
|
||||
this.roleLevel = data.rolelevel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user