Browse Source

fixed search/params

tags/1.0.0
Robin Thoni 8 years ago
parent
commit
2d865d2c4b

+ 5
- 7
app/app.js View File

11
     'appSdk'
11
     'appSdk'
12
 ]);
12
 ]);
13
 
13
 
14
-app.config(['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider',
15
-    function($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider) {
16
-
17
-        //$locationProvider.html5Mode(true);
14
+app.config(['$stateProvider', '$urlRouterProvider',
15
+    function($stateProvider, $urlRouterProvider) {
18
 
16
 
19
         $stateProvider.state('home',{
17
         $stateProvider.state('home',{
20
-            url:'/',
18
+            url:'/?group',
21
             reloadOnSearch: false,
19
             reloadOnSearch: false,
22
             templateUrl:'views/home.html',
20
             templateUrl:'views/home.html',
23
             controller:'HomeController'
21
             controller:'HomeController'
39
             }
37
             }
40
         };
38
         };
41
     }])
39
     }])
42
-    .run(['$rootScope', '$state', '$location', 'DataShareBusiness', 'GroupsBusiness', '$mdDateLocale', '$filter',
43
-        function ($rootScope, $state, $location, DataShareBusiness, GroupsBusiness, $mdDateLocale, $filter) {
40
+    .run(['$rootScope', '$state', 'DataShareBusiness', 'GroupsBusiness', '$mdDateLocale', '$filter',
41
+        function ($rootScope, $state, DataShareBusiness, GroupsBusiness, $mdDateLocale, $filter) {
44
 
42
 
45
 
43
 
46
             var promiseLoadGroups = {
44
             var promiseLoadGroups = {

+ 7
- 5
app/controllers/home.controller.js View File

1
 angular.module('app')
1
 angular.module('app')
2
-    .controller('HomeController', ['$scope', '$state', 'DataShareBusiness', 'WeeksBusiness', '$mdDialog', '$location',
3
-        function($scope, $state, DataShareBusiness, WeeksBusiness, $mdDialog, $location) {
2
+    .controller('HomeController', ['$scope', '$state', 'DataShareBusiness', 'WeeksBusiness', '$mdDialog',
3
+        function($scope, $state, DataShareBusiness, WeeksBusiness, $mdDialog) {
4
 
4
 
5
             $scope.DataShareBusiness = DataShareBusiness;
5
             $scope.DataShareBusiness = DataShareBusiness;
6
             $scope.dateFormat = DataShareBusiness.DateFormat;
6
             $scope.dateFormat = DataShareBusiness.DateFormat;
142
 
142
 
143
             $scope.$watch(function(){return DataShareBusiness.Groups}, function()
143
             $scope.$watch(function(){return DataShareBusiness.Groups}, function()
144
             {
144
             {
145
-                DataShareBusiness.setFromSearchString(Object.keys($location.search())[0]);
145
+                console.log($state.params.group);
146
+                DataShareBusiness.setFromSearchString($state.params.group);
146
             });
147
             });
147
 
148
 
148
             $scope.$watch(function(){return DataShareBusiness.CurrentGroups}, $scope.loadWeeks);
149
             $scope.$watch(function(){return DataShareBusiness.CurrentGroups}, $scope.loadWeeks);
158
                 }
159
                 }
159
             });
160
             });
160
 
161
 
161
-            $scope.$watch(function(){ return $location.search().group }, function(){
162
+            $scope.$watch(function(){ return $state.params.group }, function(){
162
                 if (DataShareBusiness.Groups != null) {
163
                 if (DataShareBusiness.Groups != null) {
163
-                    DataShareBusiness.setFromSearchString($location.search().group);
164
+                    console.log($state.params.group);
165
+                    DataShareBusiness.setFromSearchString($state.params.group);
164
                 }
166
                 }
165
             });
167
             });
166
 
168
 

+ 1
- 2
app/controllers/sidebar.controller.js View File

45
             {
45
             {
46
                 if (group != null) {
46
                 if (group != null) {
47
                     $scope.Search.value = "";
47
                     $scope.Search.value = "";
48
-                    console.log(group);
49
-                    DataShareBusiness.setCurrentGroup(group);
48
+                    DataShareBusiness.goToGroup(group);
50
                 }
49
                 }
51
             };
50
             };
52
 
51
 

+ 2
- 2
app/views/sidebar.html View File

30
             <ul class="col-sm-12 sidebar-group-list">
30
             <ul class="col-sm-12 sidebar-group-list">
31
                 <li ng-show="DataShareBusiness.CurrentGroups.length != 0" class="col-xs-12">
31
                 <li ng-show="DataShareBusiness.CurrentGroups.length != 0" class="col-xs-12">
32
                     <md-button class="md-primary md-hue-1 md-group-button col-xs-12"
32
                     <md-button class="md-primary md-hue-1 md-group-button col-xs-12"
33
-                               ng-href="{{DataShareBusiness.getGroupUrl(DataShareBusiness.getCurrentGroup().Parent)}}">
33
+                               ui-sref="home({group: DataShareBusiness.getSearchString(DataShareBusiness.getCurrentGroup().Parent)})">
34
                         ..
34
                         ..
35
                     </md-button>
35
                     </md-button>
36
                 </li>
36
                 </li>
37
                 <li ng-repeat="group in getCurrentGroups()" class="col-xs-12">
37
                 <li ng-repeat="group in getCurrentGroups()" class="col-xs-12">
38
                     <md-button class="md-primary md-hue-1 md-group-button col-xs-12"
38
                     <md-button class="md-primary md-hue-1 md-group-button col-xs-12"
39
                                ng-class="{'md-group-button-checked': DataShareBusiness.getCurrentGroup().Id == group.Id}"
39
                                ng-class="{'md-group-button-checked': DataShareBusiness.getCurrentGroup().Id == group.Id}"
40
-                               ng-href="{{DataShareBusiness.getGroupUrl(group)}}">
40
+                               ui-sref="home({group: DataShareBusiness.getSearchString(group)})">
41
                         {{ group.Name }}
41
                         {{ group.Name }}
42
                     </md-button>
42
                     </md-button>
43
                 </li>
43
                 </li>

+ 13
- 10
sdk/Business/DataShareBusiness.js View File

14
 
14
 
15
                 TimeFormat: "HH'h'mm",
15
                 TimeFormat: "HH'h'mm",
16
 
16
 
17
+                DateTimeFormat: "dd MMM yyyy HH'h'mm",
18
+
19
+                goToGroup: function(group)
20
+                {
21
+                    var search = data.getSearchString(group);
22
+                    $state.go('home', {group: search.length == 0 ? undefined : search});
23
+                },
24
+
17
                 setCurrentGroup: function(group)
25
                 setCurrentGroup: function(group)
18
                 {
26
                 {
19
-                    var g = group;
20
                     data.CurrentGroups = [];
27
                     data.CurrentGroups = [];
21
                     while (group != null) {
28
                     while (group != null) {
22
                         data.CurrentGroups.push(group);
29
                         data.CurrentGroups.push(group);
23
                         group = group.Parent;
30
                         group = group.Parent;
24
                     }
31
                     }
25
                     data.CurrentGroups.reverse();
32
                     data.CurrentGroups.reverse();
26
-
27
-                    $state.go('home').then(function() {
28
-                        var search = data.getSearchString(-1);
29
-                        $location.search({group: search.length == 0 ? undefined : search});
30
-                    });
31
                 },
33
                 },
32
 
34
 
33
                 getCurrentGroup: function()
35
                 getCurrentGroup: function()
66
                         search.push(group.Name);
68
                         search.push(group.Name);
67
                         group = group.Parent;
69
                         group = group.Parent;
68
                     }
70
                     }
69
-                    return search.reverse().join(data.SearchSeparator);
71
+                    var str = search.reverse().join(data.SearchSeparator);
72
+                    return str;
70
                 },
73
                 },
71
 
74
 
72
                 getGroupUrl: function(group)
75
                 getGroupUrl: function(group)
73
                 {
76
                 {
74
                     var search = data.getSearchString(group);
77
                     var search = data.getSearchString(group);
75
-                    return $state.href('home') + $location.hash() + (search.length != 0 ? "?group=" + search : "");
78
+                    return $state.href('home', {group:  (search.length != 0 ? search : undefined)});
76
                 },
79
                 },
77
 
80
 
78
                 setFromSearchString: function(string)
81
                 setFromSearchString: function(string)
84
                         data.setCurrentGroup(null);
87
                         data.setCurrentGroup(null);
85
                         return;
88
                         return;
86
                     }
89
                     }
87
-                    var group = {Groups: data.Groups};
90
+                    var group = null;
88
                     var names = string.split(data.SearchSeparator);
91
                     var names = string.split(data.SearchSeparator);
89
                     names.forEach(function(name)
92
                     names.forEach(function(name)
90
                     {
93
                     {
91
-                        var g = group.Groups.find(function(g)
94
+                        var g = (group || data).Groups.find(function(g)
92
                         {
95
                         {
93
                             return g.Name == name;
96
                             return g.Name == name;
94
                         });
97
                         });

Loading…
Cancel
Save