Blame view

src/app/components/navigation/navigation.service.js 1.38 KB
66ee5529f   Palak Handa   initial commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
  (function(){
  
    'use strict';
  
    angular.module('sbAdminApp').factory('navService', [ '$location', '$rootScope', function ($location, $rootScope) {
  
        
        var section = [];
  
          section.push({
            name: 'Recommend a Startup',
            type: 'link',
            sref: '.user',
            role: ['user'],  
          });
  
          section.push({
            name: 'Apply Late as Startup',
            type: 'link',
            sref: '.startUp',
            role: ['user'],  
          });
  
        var sections = [];
        for(var i = 0; i < section.length; i++) {
          if(section[i].role.indexOf($rootScope.userDetails.role) !== -1){
            sections.push(section[i]);
          }
        } 
  
          var self;
  
          return self = {
            sections: sections,
  
            toggleSelectSection: function (section) {
              self.openedSection = (self.openedSection === section ? null : section);
            },
            isSectionSelected: function (section) {
              return self.openedSection === section;
            },
  
            selectPage: function (section, page) {
              page && page.url && $location.path(page.url);
              self.currentSection = section;
              self.currentPage = page;
            }
          };
  
          function sortByHumanName(a, b) {
            return (a.humanName < b.humanName) ? -1 :
              (a.humanName > b.humanName) ? 1 : 0;
          }
  
        }])
  
  })();