Browse Source

added rooms calendar

tags/1.0.0
Robin Thoni 8 years ago
parent
commit
a5310747b3

+ 7
- 0
app/app.js View File

21
             controller:'HomeController'
21
             controller:'HomeController'
22
         });
22
         });
23
 
23
 
24
+        $stateProvider.state('rooms',{
25
+            url:'/rooms?group',
26
+            reloadOnSearch: false,
27
+            templateUrl:'views/home.html',
28
+            controller:'HomeController'
29
+        });
30
+
24
         $stateProvider.state('freeroom',{
31
         $stateProvider.state('freeroom',{
25
             url:'/freeroom',
32
             url:'/freeroom',
26
             templateUrl:'views/freeroom.html',
33
             templateUrl:'views/freeroom.html',

+ 13
- 6
app/controllers/home.controller.js View File

18
             $scope.selectedDate = new Date();
18
             $scope.selectedDate = new Date();
19
             $scope.selectedDate.setHours(0, 0, 0, 0);
19
             $scope.selectedDate.setHours(0, 0, 0, 0);
20
 
20
 
21
+            DataShareBusiness.EntitiesType = ($state.current.name == "rooms" ? "Rooms" : "Groups");
22
+
21
             for (var i = 0; i < 48; ++i) {
23
             for (var i = 0; i < 48; ++i) {
22
                 var d = new Date();
24
                 var d = new Date();
23
                 d.setHours(i / 2, 30 * (i % 2), 0, 0);
25
                 d.setHours(i / 2, 30 * (i % 2), 0, 0);
35
             {
37
             {
36
                 var sheetCount = function(group)
38
                 var sheetCount = function(group)
37
                 {
39
                 {
38
-                    var c = (group.Groups == null || group.Groups.length == 0) ? 1 : 0;
39
-                    if (group.Groups != null) {
40
-                        group.Groups.forEach(function (group) {
40
+                    var c = (group[DataShareBusiness.EntitiesType] == null || group[DataShareBusiness.EntitiesType].length == 0) ? 1 : 0;
41
+                    if (group[DataShareBusiness.EntitiesType] != null) {
42
+                        group[DataShareBusiness.EntitiesType].forEach(function (group) {
41
                             c += sheetCount(group);
43
                             c += sheetCount(group);
42
                         });
44
                         });
43
                     }
45
                     }
44
                     return c;
46
                     return c;
45
                 };
47
                 };
46
-                return sheetCount(DataShareBusiness.getCurrentGroupOrRoot())
48
+                var g = DataShareBusiness.getCurrentGroup();
49
+                if (g == null) {
50
+                    g = {};
51
+                    g[DataShareBusiness.EntitiesType] = DataShareBusiness[DataShareBusiness.EntitiesType];
52
+                }
53
+                return sheetCount(g)
47
             };
54
             };
48
 
55
 
49
             $scope.getMonday = function(d)
56
             $scope.getMonday = function(d)
141
                 return Math.round(($scope.getMonday(date1) - $scope.getMonday(date2)) / 604800000)
148
                 return Math.round(($scope.getMonday(date1) - $scope.getMonday(date2)) / 604800000)
142
             };
149
             };
143
 
150
 
144
-            $scope.$watch(function(){return DataShareBusiness.Groups}, function()
151
+            $scope.$watch(function(){return DataShareBusiness[DataShareBusiness.EntitiesType]}, function()
145
             {
152
             {
146
                 DataShareBusiness.setFromSearchString($state.params.group);
153
                 DataShareBusiness.setFromSearchString($state.params.group);
147
             });
154
             });
160
             });
167
             });
161
 
168
 
162
             $scope.$watch(function(){ return $state.params.group }, function(){
169
             $scope.$watch(function(){ return $state.params.group }, function(){
163
-                if (DataShareBusiness.Groups != null) {
170
+                if (DataShareBusiness[DataShareBusiness.EntitiesType] != null) {
164
                     DataShareBusiness.setFromSearchString($state.params.group);
171
                     DataShareBusiness.setFromSearchString($state.params.group);
165
                 }
172
                 }
166
             });
173
             });

+ 15
- 7
app/controllers/sidebar.controller.js View File

13
                 selected: null
13
                 selected: null
14
             };
14
             };
15
 
15
 
16
+            $scope.getStateName = function()
17
+            {
18
+                if ($state.current.name.length == 0) {
19
+                    return "home";
20
+                }
21
+                return $state.current.name;
22
+            };
23
+
16
             $scope.getCurrentGroups = function()
24
             $scope.getCurrentGroups = function()
17
             {
25
             {
18
                 if (DataShareBusiness.CurrentGroups.length != 0) {
26
                 if (DataShareBusiness.CurrentGroups.length != 0) {
19
                     var e = DataShareBusiness.CurrentGroups[DataShareBusiness.CurrentGroups.length - 1];
27
                     var e = DataShareBusiness.CurrentGroups[DataShareBusiness.CurrentGroups.length - 1];
20
-                    if (e.Groups == null || e.Groups.length == 0) {
21
-                        return e.Parent.Groups;
28
+                    if (e[DataShareBusiness.EntitiesType] == null || e[DataShareBusiness.EntitiesType].length == 0) {
29
+                        return e.Parent[DataShareBusiness.EntitiesType];
22
                     }
30
                     }
23
-                    return e.Groups;
31
+                    return e[DataShareBusiness.EntitiesType];
24
                 }
32
                 }
25
-                return DataShareBusiness.Groups;
33
+                return DataShareBusiness[DataShareBusiness.EntitiesType];
26
             };
34
             };
27
 
35
 
28
             $scope.search = function()
36
             $scope.search = function()
33
                     if (group.Name.toLowerCase().indexOf($scope.Search.value.toLowerCase()) > -1) {
41
                     if (group.Name.toLowerCase().indexOf($scope.Search.value.toLowerCase()) > -1) {
34
                         groups.push(group);
42
                         groups.push(group);
35
                     }
43
                     }
36
-                    if (group.Groups != null) {
37
-                        group.Groups.forEach(searchRec);
44
+                    if (group[DataShareBusiness.EntitiesType] != null) {
45
+                        group[DataShareBusiness.EntitiesType].forEach(searchRec);
38
                     }
46
                     }
39
                 }
47
                 }
40
-                DataShareBusiness.Groups.forEach(searchRec);
48
+                DataShareBusiness[DataShareBusiness.EntitiesType].forEach(searchRec);
41
                 return groups;
49
                 return groups;
42
             };
50
             };
43
 
51
 

+ 8
- 0
app/controllers/toolbar.controller.js View File

17
                 {
17
                 {
18
                         return $state.current.name == state;
18
                         return $state.current.name == state;
19
                 };
19
                 };
20
+
21
+                $scope.getStateName = function()
22
+                {
23
+                        if ($state.current.name.length == 0) {
24
+                                return "home";
25
+                        }
26
+                        return $state.current.name;
27
+                };
20
         }]);
28
         }]);

+ 49
- 33
app/views/sidebar.html View File

4
     </md-toolbar>
4
     </md-toolbar>
5
     <md-content layout-padding ng-controller="SideBarController">
5
     <md-content layout-padding ng-controller="SideBarController">
6
         <div lu-busy="sidebar">
6
         <div lu-busy="sidebar">
7
-            <form ng-submit="goToFirstMatch()">
8
-                <md-autocomplete
9
-                        md-selected-item="Search.selected"
10
-                        md-search-text="Search.value"
11
-                        md-selected-item-change="goTo(item)"
12
-                        md-items="item in search(ctrl.searchText)"
13
-                        md-item-text="item.Name"
14
-                        md-min-length="1"
15
-                        placeholder="Type a group name...">
16
-                    <md-item-template>
17
-                        <span md-highlight-text="ctrl.searchText" md-highlight-flags="^i">{{item.Name}}</span>
18
-                    </md-item-template>
19
-                    <md-not-found>
20
-                        No groups matching "{{Search.value}}" were found.
21
-                    </md-not-found>
22
-                </md-autocomplete>
23
-            </form>
7
+            <div ng-show="isInState('home') || isInState('rooms')">
8
+                <form ng-submit="goToFirstMatch()">
9
+                    <md-autocomplete
10
+                            md-selected-item="Search.selected"
11
+                            md-search-text="Search.value"
12
+                            md-selected-item-change="goTo(item)"
13
+                            md-items="item in search(ctrl.searchText)"
14
+                            md-item-text="item.Name"
15
+                            md-min-length="1"
16
+                            placeholder="Type a name...">
17
+                        <md-item-template>
18
+                            <span md-highlight-text="ctrl.searchText" md-highlight-flags="^i">{{item.Name}}</span>
19
+                        </md-item-template>
20
+                        <md-not-found>
21
+                            No groups matching "{{Search.value}}" were found.
22
+                        </md-not-found>
23
+                    </md-autocomplete>
24
+                </form>
24
 
25
 
25
-            <ul class="col-sm-12 sidebar-group-list">
26
-                <li ng-show="DataShareBusiness.CurrentGroups.length != 0" class="col-xs-12">
27
-                    <md-button class="md-primary md-hue-1 md-group-button col-xs-12"
28
-                               ui-sref="home({group: DataShareBusiness.getSearchString(DataShareBusiness.getCurrentGroup().Parent)})">
29
-                        ..
30
-                    </md-button>
31
-                </li>
32
-                <li ng-repeat="group in getCurrentGroups()" class="col-xs-12">
33
-                    <md-button class="md-primary md-hue-1 md-group-button col-xs-12"
34
-                               ng-class="{'md-group-button-checked': DataShareBusiness.getCurrentGroup().Id == group.Id}"
35
-                               ui-sref="home({group: DataShareBusiness.getSearchString(group)})">
36
-                        {{ group.Name }}
37
-                    </md-button>
38
-                </li>
39
-            </ul>
26
+                <ul class="col-sm-12 sidebar-group-list">
27
+                    <li ng-show="DataShareBusiness.CurrentGroups.length != 0" class="col-xs-12">
28
+                        <md-button class="md-primary md-hue-1 md-group-button col-xs-12"
29
+                                   ui-sref="{{getStateName()}}({group: DataShareBusiness.getSearchString(DataShareBusiness.getCurrentGroup().Parent)})">
30
+                            ..
31
+                        </md-button>
32
+                    </li>
33
+                    <li ng-repeat="group in getCurrentGroups()" class="col-xs-12">
34
+                        <md-button class="md-primary md-hue-1 md-group-button col-xs-12"
35
+                                   ng-class="{'md-group-button-checked': DataShareBusiness.getCurrentGroup().Id == group.Id}"
36
+                                   ui-sref="{{getStateName()}}({group: DataShareBusiness.getSearchString(group)})">
37
+                            {{ group.Name }}
38
+                        </md-button>
39
+                    </li>
40
+                </ul>
41
+            </div>
40
 
42
 
41
             <div ng-hide="isInState('freeroom')">
43
             <div ng-hide="isInState('freeroom')">
42
-                <span>Need a room ?</span>
44
+                <span>Need a room?</span>
43
                 <md-button class="md-primary md-group-button col-xs-12" ui-sref="freeroom">
45
                 <md-button class="md-primary md-group-button col-xs-12" ui-sref="freeroom">
44
                     Find a free room!
46
                     Find a free room!
45
                 </md-button>
47
                 </md-button>
46
             </div>
48
             </div>
49
+
50
+            <div ng-hide="isInState('home')">
51
+                <span>Want your courses?</span>
52
+                <md-button class="md-primary md-group-button col-xs-12" ui-sref="home">
53
+                    Go to your courses
54
+                </md-button>
55
+            </div>
56
+
57
+            <div ng-hide="isInState('rooms')">
58
+                <span>Is there people here?</span>
59
+                <md-button class="md-primary md-group-button col-xs-12" ui-sref="rooms">
60
+                    Show all rooms
61
+                </md-button>
62
+            </div>
47
         </div>
63
         </div>
48
     </md-content>
64
     </md-content>
49
 </md-sidenav>
65
 </md-sidenav>

+ 3
- 3
app/views/toolbar.html View File

3
         <md-button class="md-icon-button" aria-label="Groupes" ng-click="toggleSideBar()" hide-gt-md>
3
         <md-button class="md-icon-button" aria-label="Groupes" ng-click="toggleSideBar()" hide-gt-md>
4
             <md-icon md-svg-icon="img/menu.svg"></md-icon>
4
             <md-icon md-svg-icon="img/menu.svg"></md-icon>
5
         </md-button>
5
         </md-button>
6
-        <h2 ng-show="isInState('home')">
7
-            <a ng-href="{{DataShareBusiness.getGroupUrl(null)}}">{{ DataShareBusiness.SearchSeparator }} </a>
8
-            <a ng-href="{{DataShareBusiness.getGroupUrl(group)}}" ng-repeat="group in DataShareBusiness.CurrentGroups">
6
+        <h2 ng-show="isInState('home') || isInState('rooms')">
7
+            <a ui-sref="{{getStateName()}}">{{ DataShareBusiness.SearchSeparator }} </a>
8
+            <a ui-sref="{{getStateName()}}({group: DataShareBusiness.getSearchString(group)})" ng-repeat="group in DataShareBusiness.CurrentGroups">
9
                 {{ group.Name }}{{ $last ? "" : " " + DataShareBusiness.SearchSeparator + " " }}
9
                 {{ group.Name }}{{ $last ? "" : " " + DataShareBusiness.SearchSeparator + " " }}
10
             </a>
10
             </a>
11
         </h2>
11
         </h2>

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

10
 
10
 
11
                 Rooms: null,
11
                 Rooms: null,
12
 
12
 
13
-                SearchSeparator: "~",
13
+                SearchSeparator: "|",
14
 
14
 
15
                 CurrentGroups: [],
15
                 CurrentGroups: [],
16
 
16
 
20
 
20
 
21
                 DateTimeFormat: "DD MMM YYYY HH[h]mm",
21
                 DateTimeFormat: "DD MMM YYYY HH[h]mm",
22
 
22
 
23
-                makeParents: function(group)
23
+                EntitiesType: "Rooms",
24
+
25
+                makeParents: function(group, type)
24
                 {
26
                 {
25
-                    if (group.Groups != null) {
26
-                        group.Groups.forEach(function (g) {
27
+                    if (group[type] != null) {
28
+                        group[type].forEach(function (g) {
27
                             g.Parent = group;
29
                             g.Parent = group;
28
-                            data.makeParents(g);
30
+                            data.makeParents(g, type);
29
                         });
31
                         });
30
                     }
32
                     }
31
                 },
33
                 },
33
                 goToGroup: function(group)
35
                 goToGroup: function(group)
34
                 {
36
                 {
35
                     var search = data.getSearchString(group);
37
                     var search = data.getSearchString(group);
36
-                    $state.go('home', {group: search.length == 0 ? undefined : search});
38
+                    $state.go(data.EntitiesType == "Groups" ? 'home' : 'rooms', {group: search.length == 0 ? undefined : search});
37
                 },
39
                 },
38
 
40
 
39
                 setCurrentGroup: function(group)
41
                 setCurrentGroup: function(group)
54
                     return data.CurrentGroups[data.CurrentGroups.length - 1];
56
                     return data.CurrentGroups[data.CurrentGroups.length - 1];
55
                 },
57
                 },
56
 
58
 
57
-                getCurrentGroupOrRoot: function()
58
-                {
59
-                    var group = data.getCurrentGroup();
60
-                    if (group == null) {
61
-                        return {
62
-                            Id: null,
63
-                            Groups: data.Groups,
64
-                            Name: "Root",
65
-                            Type: 1,
66
-                            ParentId: -1
67
-                        }
68
-                    }
69
-                    return group;
70
-                },
71
-
72
                 getSearchString: function(group)
59
                 getSearchString: function(group)
73
                 {
60
                 {
74
                     if (group == -1 && data.CurrentGroups.length != 0) {
61
                     if (group == -1 && data.CurrentGroups.length != 0) {
86
                     return str;
73
                     return str;
87
                 },
74
                 },
88
 
75
 
89
-                getGroupUrl: function(group)
90
-                {
91
-                    var search = data.getSearchString(group);
92
-                    return $state.href('home', {group:  (search.length != 0 ? search : undefined)});
93
-                },
94
-
95
                 setFromSearchString: function(string)
76
                 setFromSearchString: function(string)
96
                 {
77
                 {
97
-                    if (data.Groups == null) {
78
+                    if (data[data.EntitiesType] == null) {
98
                         return;
79
                         return;
99
                     }
80
                     }
100
                     if (string == null) {
81
                     if (string == null) {
105
                     var names = string.split(data.SearchSeparator);
86
                     var names = string.split(data.SearchSeparator);
106
                     names.forEach(function(name)
87
                     names.forEach(function(name)
107
                     {
88
                     {
108
-                        var g = (group || data).Groups.find(function(g)
89
+                        var g = (group || data)[data.EntitiesType].find(function(g)
109
                         {
90
                         {
110
                             return g.Name == name;
91
                             return g.Name == name;
111
                         });
92
                         });

+ 1
- 1
sdk/Business/GroupsBusiness.js View File

14
                 {
14
                 {
15
                     data.forEach(function(group)
15
                     data.forEach(function(group)
16
                     {
16
                     {
17
-                        DataShareBusiness.makeParents(group);
17
+                        DataShareBusiness.makeParents(group, "Groups");
18
                         group.parent = null;
18
                         group.parent = null;
19
                     });
19
                     });
20
                     defer.resolve(data);
20
                     defer.resolve(data);

+ 1
- 1
sdk/Business/RoomsBusiness.js View File

17
                 {
17
                 {
18
                     data.forEach(function(group)
18
                     data.forEach(function(group)
19
                     {
19
                     {
20
-                        DataShareBusiness.makeParents(group);
20
+                        DataShareBusiness.makeParents(group, "Rooms");
21
                         group.parent = null;
21
                         group.parent = null;
22
                     });
22
                     });
23
                     defer.resolve(data);
23
                     defer.resolve(data);

Loading…
Cancel
Save