This repository was archived by the owner on Oct 2, 2019. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +63
-2
lines changed Expand file tree Collapse file tree 3 files changed +63
-2
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,15 @@ body > .select2-container.open {
127
127
width : 0 ;
128
128
}
129
129
130
+ .ui-select-container [theme = "selectize" ] .ui-select-header-group-selectable : hover {
131
+ background-color : # f5f5f5 ;
132
+ }
133
+
134
+ .ui-select-container [theme = "selectize" ] .ui-select-header-group-selectable {
135
+ cursor : pointer;
136
+ padding-left : 15px ;
137
+ }
138
+
130
139
/* Bootstrap theme */
131
140
132
141
/* Helper class to show styles when focus */
@@ -253,6 +262,16 @@ body > .ui-select-bootstrap.open {
253
262
border-right : 1px solid # 428bca ;
254
263
}
255
264
265
+ .ui-select-bootstrap .ui-select-header-group-selectable : hover {
266
+ background-color : # f5f5f5 ;
267
+ }
268
+
269
+ .ui-select-bootstrap .ui-select-header-group-selectable {
270
+ color : black;
271
+ cursor : pointer;
272
+ padding : 3px 10px ;
273
+ }
274
+
256
275
.ui-select-bootstrap .ui-select-choices-row > span {
257
276
cursor : pointer;
258
277
display : block;
Original file line number Diff line number Diff line change @@ -166,9 +166,12 @@ uis.controller('uiSelectCtrl',
166
166
ctrl . searchInput [ 0 ] . focus ( ) ;
167
167
} ;
168
168
169
- ctrl . findGroupByName = function ( name ) {
169
+ ctrl . findGroupByName = function ( name , noStrict ) {
170
170
return ctrl . groups && ctrl . groups . filter ( function ( group ) {
171
- return group . name === name ;
171
+ if ( noStrict )
172
+ return group . name == name ;
173
+ else
174
+ return group . name === name ;
172
175
} ) [ 0 ] ;
173
176
} ;
174
177
Original file line number Diff line number Diff line change
1
+ uis . directive ( 'uiSelectHeaderGroupSelectable' , [ '$timeout' , function ( $timeout ) {
2
+ return {
3
+ restrict : 'EA' ,
4
+ require : [ '^uiSelect' ] ,
5
+ scope : true ,
6
+ link : function ( $scope , $element , attrs , select ) {
7
+ // TODO Why that???
8
+ var $select = select [ 0 ] ;
9
+
10
+ $scope . $watch ( '$select.groups' , function ( ) {
11
+ if ( $select . multiple && $select . groups ) {
12
+ var elements = $element . querySelectorAll ( '.ui-select-choices-group-label' ) ;
13
+
14
+ angular . forEach ( elements , function ( e ) {
15
+ var element = angular . element ( e ) ;
16
+
17
+ // Check the onClick event is not already listen
18
+ if ( ! element . hasClass ( 'ui-select-header-group-selectable' ) ) {
19
+ element . addClass ( 'ui-select-header-group-selectable' ) ;
20
+
21
+ element . on ( 'click' , function ( ) {
22
+ // TODO It's the good way?
23
+ var group = $select . findGroupByName ( element . text ( ) , true ) ;
24
+
25
+ angular . forEach ( group . items , function ( item ) {
26
+ $timeout ( function ( ) {
27
+ $select . select ( item , false , ' ' ) ;
28
+ } ) ;
29
+ } ) ;
30
+ } ) ;
31
+ }
32
+ } ) ;
33
+ } else {
34
+ console . error ( 'Use uiSelectHeaderGroupSelectable with no multiple uiSelect or without groupBy' ) ;
35
+ }
36
+ } ) ;
37
+ }
38
+ } ;
39
+ } ] ) ;
You can’t perform that action at this time.
0 commit comments