浏览代码

group search

tags/1.0.0
Robin Thoni 9 年前
父节点
当前提交
c65c36b203
共有 3 个文件被更改,包括 63 次插入17 次删除
  1. 28
    0
      app/controllers/sidebar.controller.js
  2. 2
    2
      app/less/app.less
  3. 33
    15
      app/views/sidebar.html

+ 28
- 0
app/controllers/sidebar.controller.js 查看文件

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

+ 2
- 2
app/less/app.less 查看文件

35
   background-color: rgba(0, 0, 0, 0.12);
35
   background-color: rgba(0, 0, 0, 0.12);
36
 }
36
 }
37
 
37
 
38
-.md-sidebar {
38
+.md-sidebar md-content {
39
   height: 100%;
39
   height: 100%;
40
   min-height: 150px;
40
   min-height: 150px;
41
 }
41
 }
143
 .sidebar-group-list {
143
 .sidebar-group-list {
144
   height: 100%;
144
   height: 100%;
145
   min-height: 75px;
145
   min-height: 75px;
146
-}
146
+}

+ 33
- 15
app/views/sidebar.html 查看文件

10
             This sidenav is locked open on your device. To go back to the default behavior,
10
             This sidenav is locked open on your device. To go back to the default behavior,
11
             narrow your display.
11
             narrow your display.
12
         </p>-->
12
         </p>-->
13
-        <ul class="col-sm-12 sidebar-group-list" lu-busy="sidebar">
14
-            <li ng-show="DataShareBusiness.CurrentGroups.length != 0" class="col-xs-12">
15
-                <md-button class="md-primary md-hue-1 md-group-button col-xs-12"
16
-                           ng-href="{{DataShareBusiness.getGroupUrl(DataShareBusiness.getCurrentGroup().Parent)}}">
17
-                    ..
18
-                </md-button>
19
-            </li>
20
-            <li ng-repeat="group in getCurrentGroups()" class="col-xs-12">
21
-                <md-button class="md-primary md-hue-1 md-group-button col-xs-12"
22
-                           ng-class="{'md-group-button-checked': DataShareBusiness.getCurrentGroup().Id == group.Id}"
23
-                           ng-href="{{DataShareBusiness.getGroupUrl(group)}}">
24
-                    {{ group.Name }}
25
-                </md-button>
26
-            </li>
27
-        </ul>
13
+        <div lu-busy="sidebar">
14
+            <md-autocomplete
15
+                    md-selected-item="Search.selected"
16
+                    md-search-text="Search.value"
17
+                    md-selected-item-change="goTo(item)"
18
+                    md-items="item in search(ctrl.searchText)"
19
+                    md-item-text="item.Name"
20
+                    md-min-length="1"
21
+                    placeholder="Type a group name...">
22
+                <md-item-template>
23
+                    <span md-highlight-text="ctrl.searchText" md-highlight-flags="^i">{{item.Name}}</span>
24
+                </md-item-template>
25
+                <md-not-found>
26
+                    No groups matching "{{Search.value}}" were found.
27
+                </md-not-found>
28
+            </md-autocomplete>
29
+
30
+            <ul class="col-sm-12 sidebar-group-list">
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"
33
+                               ng-href="{{DataShareBusiness.getGroupUrl(DataShareBusiness.getCurrentGroup().Parent)}}">
34
+                        ..
35
+                    </md-button>
36
+                </li>
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"
39
+                               ng-class="{'md-group-button-checked': DataShareBusiness.getCurrentGroup().Id == group.Id}"
40
+                               ng-href="{{DataShareBusiness.getGroupUrl(group)}}">
41
+                        {{ group.Name }}
42
+                    </md-button>
43
+                </li>
44
+            </ul>
45
+        </div>
28
     </md-content>
46
     </md-content>
29
 </md-sidenav>
47
 </md-sidenav>

正在加载...
取消
保存