Bladeren bron

group navigation

tags/1.0.0
Robin Thoni 8 jaren geleden
bovenliggende
commit
90985bc8cd

+ 9
- 4
app/controllers/sidebar.controller.js Bestand weergeven

@@ -6,13 +6,18 @@ angular.module('app')
6 6
     .controller('SideBarController', ['$scope', '$state', 'DataShareBusiness', 'GroupsBusiness',
7 7
         function($scope, $state, DataShareBusiness, GroupsBusiness) {
8 8
 
9
-            $scope.groups = [];
9
+            $scope.DataShareBusiness = DataShareBusiness;
10 10
 
11
-            $scope.setCurrentGroups = function(groups)
11
+            $scope.getCurrentGroups = function()
12 12
             {
13
-                if (groups != null) {
14
-                    $scope.groups = groups;
13
+                if (DataShareBusiness.CurrentGroups.length != 0) {
14
+                    var e = DataShareBusiness.CurrentGroups[DataShareBusiness.CurrentGroups.length - 1];
15
+                    if (e.Groups.length == 0) {
16
+                        return e.Parent.Groups;
17
+                    }
18
+                    return e.Groups;
15 19
                 }
20
+                return DataShareBusiness.Groups;
16 21
             };
17 22
 
18 23
             var promiseLoadGroups = {

+ 2
- 0
app/controllers/toolbar.controller.js Bestand weergeven

@@ -6,6 +6,8 @@ angular.module('app')
6 6
     .controller('ToolBarController', ['$scope', '$state', '$mdSidenav', 'DataShareBusiness',
7 7
         function($scope, $state, $mdSidenav, DataShareBusiness) {
8 8
 
9
+                $scope.DataShareBusiness = DataShareBusiness;
10
+
9 11
                 $scope.toggleSideBar = function()
10 12
                 {
11 13
                     $mdSidenav('left').toggle();

+ 7
- 2
app/views/sidebar.html Bestand weergeven

@@ -11,8 +11,13 @@
11 11
             narrow your display.
12 12
         </p>-->
13 13
         <ul class="col-sm-12" lu-busy="sidebar">
14
-            <li ng-repeat="group in groups">
15
-                <md-button class="md-primary md-hue-1 md-group-button col-xs-12" ng-click="setCurrentGroups(group.Groups)">
14
+            <li ng-show="DataShareBusiness.CurrentGroups.length != 0">
15
+                <md-button class="md-primary md-hue-1 md-group-button col-xs-12" ng-click="DataShareBusiness.upCurrentGroup()">
16
+                    ..
17
+                </md-button>
18
+            </li>
19
+            <li ng-repeat="group in getCurrentGroups()">
20
+                <md-button class="md-primary md-hue-1 md-group-button col-xs-12" ng-click="DataShareBusiness.setCurrentGroup(group)">
16 21
                     {{ group.Name }}
17 22
                 </md-button>
18 23
             </li>

+ 2
- 1
app/views/toolbar.html Bestand weergeven

@@ -4,7 +4,8 @@
4 4
             <md-icon md-svg-icon="img/menu.svg"></md-icon>
5 5
         </md-button>
6 6
         <h2>
7
-            <span>Toolbar with Icon Buttons</span>
7
+            <span ng-click="DataShareBusiness.setCurrentGroup(null)">/ </span>
8
+            <a href="" ng-click="DataShareBusiness.setCurrentGroup(group)" ng-repeat="group in DataShareBusiness.CurrentGroups">{{ group.Name }}{{ $last ? "" : " / " }}</a>
8 9
         </h2>
9 10
         <span flex></span>
10 11
         <!--<md-button class="md-icon-button" aria-label="Favorite">

+ 20
- 2
sdk/Business/DataShareBusiness.js Bestand weergeven

@@ -1,11 +1,29 @@
1 1
 (function()
2 2
 {
3 3
     angular.module('appSdk')
4
-        .factory('DataShareBusiness', ['$q', function ($q) {
4
+        .factory('DataShareBusiness', [function () {
5 5
 
6 6
             var data = {
7 7
                 Groups: null,
8
-                CurrentGroup: null
8
+                CurrentGroups: [],
9
+                setCurrentGroup: function(group)
10
+                {
11
+                    data.CurrentGroups = [];
12
+                    while (group != null) {
13
+                        data.CurrentGroups.push(group);
14
+                        group = group.Parent;
15
+                    }
16
+                    data.CurrentGroups.reverse();
17
+                },
18
+                upCurrentGroup: function()
19
+                {
20
+                    if (data.CurrentGroups.length > 1) {
21
+                        data.setCurrentGroup(data.CurrentGroups[data.CurrentGroups.length - 2]);
22
+                    }
23
+                    else if (data.CurrentGroups.length == 1) {
24
+                        data.setCurrentGroup(null);
25
+                    }
26
+                }
9 27
             };
10 28
 
11 29
             return data;

+ 26
- 1
sdk/Business/GroupsBusiness.js Bestand weergeven

@@ -5,7 +5,32 @@
5 5
 
6 6
             var Business = {};
7 7
 
8
-            Business.getAll = GroupsDataAccess.getAll;
8
+            Business.makeParents = function(group)
9
+            {
10
+                if (group.Groups != null) {
11
+                    group.Groups.forEach(function (g) {
12
+                        g.Parent = group;
13
+                        Business.makeParents(g);
14
+                    });
15
+                }
16
+            };
17
+
18
+            Business.getAll = function(promise)
19
+            {
20
+                var defer = $q.defer();
21
+
22
+                GroupsDataAccess.getAll(promise).then(function(data)
23
+                {
24
+                    data.forEach(function(group)
25
+                    {
26
+                        Business.makeParents(group);
27
+                        group.parent = null;
28
+                    });
29
+                    defer.resolve(data);
30
+                }, defer.reject);
31
+
32
+                return defer.promise;
33
+            };
9 34
 
10 35
             Business.loadAll = function(promise)
11 36
             {

Laden…
Annuleren
Opslaan