diversen opmerkingen

This commit is contained in:
2018-07-29 10:11:02 +02:00
parent cecbfd83fb
commit 30535f7048
34 changed files with 11883 additions and 82 deletions
@@ -9,6 +9,7 @@ dbo.authorisationInit = function () {
if ( dbo.authorisationModel !== undefined ) {
dbo.authorisationModel.refreshPageAuthorisations();
} else {
dbo.authorisationModel = {
@@ -22,10 +23,53 @@ dbo.authorisationInit = function () {
},
refreshPageAuthorisations: function () {
var vm = dbo.authorisationModel;
vm.initPages = true;
vm.roles.removeAll();
dbo.authorisationDataService.getRoleAuthorisations( function ( data ) {
console.log( data );
_.each( data, function ( p ) {
vm.roles.push( new vm.Role( p ) );
} )
} );
},
Role: function ( data ) {
var vm = dbo.authorisationModel;
var self = this;
self.roleID = data.id;
self.rolename = data.rolename;
self.pages = ko.observableArray( [] );
_.each( data.pagesAccess, function ( p ) {
self.pages.push( new vm.Page( p, self.pages() ) );
} );
vm.initPages = false;
},
Page: function ( data, pages ) {
var vm = dbo.authorisationModel;
var self = this;
if ( vm.initPages ) {
self.pageID = data.id;
self.pagename = data.pagename;
self.typePage = data.typepage;
self.pageAccess = ko.observableArray( [] );
self.pageAccess.push( {access: ko.observable( data.pageaccess == 'T' ? true : false )} );
}else{
_.each(pages, function(p){
console.log( pages );
console.log( data.id, '- -', p.pageID );
if( data.id == p.pageID) {
p.pageAccess.push( {access: ko.observable( data.pageaccess == 'T' ? true : false )} );
}
})
}
}
};
@@ -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;
}
}