From fd3dd5654279f5855dace1f8e2ae549f7c212d6c Mon Sep 17 00:00:00 2001 From: Dani Herrero Date: Thu, 25 May 2017 11:52:53 +0200 Subject: [PATCH] Separado aclService en fichero propio --- client/salix/src/aclService.js | 28 ++++++++++++++++++++++++++ client/salix/src/app.js | 1 + client/salix/src/components/app/app.js | 26 +----------------------- 3 files changed, 30 insertions(+), 25 deletions(-) create mode 100644 client/salix/src/aclService.js diff --git a/client/salix/src/aclService.js b/client/salix/src/aclService.js new file mode 100644 index 000000000..aeb8b0129 --- /dev/null +++ b/client/salix/src/aclService.js @@ -0,0 +1,28 @@ +import ngModule from './module'; + +function aclService() { + this.roles = window.Salix.acl.roles; + this.routeHasPermission = function(route) { + let hasPermission; + if (!route.acl) + hasPermission = true; + else if (!this.roles || !Object.keys(this.roles).length) + hasPermission = false; + else + hasPermission = this.aclPermission(route.acl); + return hasPermission; + }; + this.aclPermission = function(aclCollection) { + let hasPermission = false; + let total = aclCollection.length; + for (let i = 0; i < total; i++) { + if (this.roles[aclCollection[i]]) { + hasPermission = true; + break; + } + } + return hasPermission; + }; +} + +ngModule.service('aclService', aclService); diff --git a/client/salix/src/app.js b/client/salix/src/app.js index 0f5d3edb5..8ec2c5df7 100644 --- a/client/salix/src/app.js +++ b/client/salix/src/app.js @@ -1,5 +1,6 @@ import './module'; import './spliting'; +import './aclService'; import './configroutes'; import './config'; import './run'; diff --git a/client/salix/src/components/app/app.js b/client/salix/src/components/app/app.js index 8e417a491..c20c448ee 100644 --- a/client/salix/src/components/app/app.js +++ b/client/salix/src/components/app/app.js @@ -76,28 +76,4 @@ function interceptorConfig($httpProvider) { } ngModule.config(interceptorConfig); -function aclService() { - this.roles = window.Salix.acl.roles; - this.routeHasPermission = function(route) { - let hasPermission; - if (!route.acl) - hasPermission = true; - else if (!this.roles || !Object.keys(this.roles).length) - hasPermission = false; - else - hasPermission = this.aclPermission(route.acl); - return hasPermission; - }; - this.aclPermission = function(aclCollection) { - let hasPermission = false; - let total = aclCollection.length; - for (let i = 0; i < total; i++) { - if (this.roles[aclCollection[i]]) { - hasPermission = true; - break; - } - } - return hasPermission; - }; -} -ngModule.service('aclService', aclService); +