menuCtrl.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. app.controller('menuCtrl',
  2. function ($scope,$http,$cookies, $location, $route, $timeout, $mdSidenav, $mdMedia, $window, $cookies, utilsSvc, userService, UserManager, menuService) {
  3. $scope.appVersion = '1.7.9.2';
  4. $scope.currentMenu = '';
  5. $scope.isUserLoggedIn = function(){
  6. return userService.getCurrentUser() != null;
  7. }
  8. $scope.isAmbienteTest = function(){
  9. return ($location.$$host.toLowerCase().indexOf('tamtest')>=0) || ($location.$$host.toLowerCase().indexOf('localhost')>=0)
  10. }
  11. $scope.forcedClose = false;
  12. $window.addEventListener('resize', onResize);
  13. function onResize() {
  14. $scope.$digest();
  15. }
  16. $scope.$on('$destroy', function() {
  17. $window.removeEventListener('resize', onResize);
  18. });
  19. $scope.shouldLockOpen = function() {
  20. if ($scope.forcedClose)
  21. return false;
  22. else
  23. return $mdMedia('gt-sm');
  24. }
  25. $scope.isCurrentMenu=function(url) {
  26. return $scope.currentMenu==url;//($location.path().indexOf(url)>=0);
  27. }
  28. $scope.toggleMenu = function() {
  29. $scope.forcedClose = !$scope.forcedClose;
  30. if ($scope.forcedClose)
  31. $mdSidenav('menuSidenav').close();
  32. else
  33. $mdSidenav('menuSidenav').open();
  34. }
  35. $scope.showMenu = function(){
  36. $mdSidenav('menuSidenav').open();
  37. }
  38. $scope.largeScreen =function(){
  39. return utilsSvc.largeScreen();
  40. }
  41. $scope.notSmallScreen =function(){
  42. console.log($mdMedia('gt-sm'));
  43. return $mdMedia('gt-sm');
  44. }
  45. $scope.closeSideNav = function(){
  46. if ($mdMedia('sm')||$mdMedia('xs')||$scope.forcedClose)
  47. $mdSidenav('menuSidenav').close();
  48. }
  49. $scope.forceSidenavOpen = function() {
  50. return $mdMedia('gt-sm') || ($scope.requestMenuOpen && $mdMedia('gt-sm'));
  51. }
  52. $scope.appVariables = {};
  53. $scope.checkUserPermission = function() {
  54. if ($scope.isUserLoggedIn()) {
  55. UserManager.AppVariables().$promise.then(function(data){
  56. $scope.appVariables = data;
  57. if ($scope.appVariables.profiloLocale=='UO' || $scope.appVariables.profiloLocale=='UR') {
  58. if (!$scope.appVariables.abilitaBonifici) {
  59. $('#BONIFICI').css('display','none');
  60. $('#SBBONIFICI').css('display','none');
  61. }
  62. if (!$scope.appVariables.abilitaAEA) {
  63. $('#AEA').css('display','none');
  64. $('#SBAEA').css('display','none');
  65. }
  66. if (!$scope.appVariables.abilitaRID) {
  67. $('#RID').css('display','none');
  68. $('#SBRID').css('display','none');
  69. }
  70. $('#DistinteBanca').css('display','none');
  71. $('#SBDistinteBanca').css('display','none');
  72. $('#TabellaBanche').css('display','none');
  73. $('#SBTabellaBanche').css('display','none');
  74. $('#RemunerationSeda').css('display','none');
  75. $('#SBRemunerationSeda').css('display','none');
  76. if ($scope.appVariables.abilitaAEA ==false && $scope.appVariables.abilitaRID==false) {
  77. $('#AcquisizioneFlussiDispositivi').css('display','none');
  78. $('#SBAcquisizioneFlussiDispositivi').css('display','none');
  79. }
  80. }
  81. if ($scope.appVariables.profiloLocale=='UO' || $scope.appVariables.profiloLocale=='UR' || $scope.appVariables.profiloLocale=='VI' ) {
  82. if (!$scope.appVariables.abilitaAccessoAnagrafica){
  83. $('#AnagraficaOrdinanti').css('display','none');
  84. $('#SBAnagraficaOrdinanti').css('display','none');
  85. }
  86. }
  87. });
  88. }
  89. }
  90. $scope.visibleToProfile = function(menu){
  91. if (typeof menu!="undefined" && typeof menu.visible != "undefined" && $scope.getCurrentUser()!=null)
  92. return menu.visible.indexOf($scope.getCurrentUser().userProfile)>=0;
  93. return false;
  94. }
  95. $scope.getCurrentUser = function(){
  96. return userService.getCurrentUser();
  97. }
  98. $scope.logout = function() {
  99. userService.logout();
  100. }
  101. $scope.menu = function(){
  102. return menuService.getMenu().mainMenu;
  103. }
  104. $scope.go = function(url, tipoChiamata) {
  105. if (tipoChiamata!='') {
  106. $scope.currentMenu = url;
  107. var filtro = userService.getFiltroIncassiSDD();
  108. filtro.tipoChiamata = tipoChiamata;
  109. filtro.idDistintaBanca = 0;
  110. filtro.idDistintaFlusso = 0;
  111. filtro.codiceClienteDebitore='';
  112. userService.setFiltroIncassiSDD(filtro);
  113. if (url.indexOf("distinteBanca")==-1) {
  114. localStorage.removeItem("filterDistinte");
  115. localStorage.removeItem("filterDistinteAttivo");
  116. localStorage.removeItem("filterDistinteSelectedIndex");
  117. }
  118. $route.reload();
  119. }
  120. $location.path(url);
  121. }
  122. $scope.closeOnClick = function() {
  123. if (!$mdMedia('gt-sm')){
  124. $mdSidenav('menuSidenav').close();
  125. }
  126. }
  127. $scope.isMenuSelected = function(menuId) {
  128. return menuService.isMenuSelected(menuId);
  129. }
  130. $scope.setSelectedMenu = function (menu) {
  131. return menuService.setSelectedMenu(menu)
  132. }
  133. $scope.isSubMenuSelected = function(subMenuId) {
  134. return menuService.isSubMenuSelected(subMenuId);
  135. }
  136. $scope.setSelectedSubMenu = function (subMenuId) {
  137. return menuService.setSelectedSubMenu(subMenuId)
  138. }
  139. $scope.hasSubMenu = function(menu) {
  140. return menuService.hasSubMenu(menu);
  141. }
  142. });