@@ -168,6 +168,8 @@ describe('ui-select tests', function() {
168
168
if ( attrs . refresh !== undefined ) { choicesAttrsHtml += ' refresh="' + attrs . refresh + '"' ; }
169
169
if ( attrs . refreshDelay !== undefined ) { choicesAttrsHtml += ' refresh-delay="' + attrs . refreshDelay + '"' ; }
170
170
if ( attrs . backspaceReset !== undefined ) { attrsHtml += ' backspace-reset="' + attrs . backspaceReset + '"' ; }
171
+ if ( attrs . uiDisableChoice !== undefined ) { choicesAttrsHtml += ' ui-disable-choice="' + attrs . uiDisableChoice + '"' ; }
172
+ if ( attrs . removeSelected !== undefined ) { attrsHtml += ' remove-selected="' + attrs . removeSelected + '"' ; }
171
173
}
172
174
173
175
return compileTemplate (
@@ -1837,11 +1839,13 @@ describe('ui-select tests', function() {
1837
1839
if ( attrs . taggingLabel !== undefined ) { attrsHtml += ' tagging-label="' + attrs . taggingLabel + '"' ; }
1838
1840
if ( attrs . inputId !== undefined ) { attrsHtml += ' input-id="' + attrs . inputId + '"' ; }
1839
1841
if ( attrs . groupBy !== undefined ) { choicesAttrsHtml += ' group-by="' + attrs . groupBy + '"' ; }
1842
+ if ( attrs . uiDisableChoice !== undefined ) { choicesAttrsHtml += ' ui-disable-choice="' + attrs . uiDisableChoice + '"' ; }
1840
1843
if ( attrs . lockChoice !== undefined ) { matchesAttrsHtml += ' ui-lock-choice="' + attrs . lockChoice + '"' ; }
1841
1844
if ( attrs . removeSelected !== undefined ) { attrsHtml += ' remove-selected="' + attrs . removeSelected + '"' ; }
1842
1845
if ( attrs . resetSearchInput !== undefined ) { attrsHtml += ' reset-search-input="' + attrs . resetSearchInput + '"' ; }
1843
1846
if ( attrs . limit !== undefined ) { attrsHtml += ' limit="' + attrs . limit + '"' ; }
1844
1847
if ( attrs . onSelect !== undefined ) { attrsHtml += ' on-select="' + attrs . onSelect + '"' ; }
1848
+ if ( attrs . removeSelected !== undefined ) { attrsHtml += ' remove-selected="' + attrs . removeSelected + '"' ; }
1845
1849
}
1846
1850
1847
1851
return compileTemplate (
@@ -2832,6 +2836,61 @@ describe('ui-select tests', function() {
2832
2836
expect ( el . scope ( ) . $select . selected . length ) . toEqual ( 2 ) ;
2833
2837
} ) ;
2834
2838
2839
+ describe ( 'Test key down key up and activeIndex should skip disabled choice for uiMultipleSelect' , function ( ) {
2840
+ it ( 'should ignored disabled items going up' , function ( ) {
2841
+ var el = createUiSelect ( { uiDisableChoice :"person.age == 12" } ) ;
2842
+ openDropdown ( el ) ;
2843
+ var searchInput = el . find ( '.ui-select-search' ) ;
2844
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( 0 ) ;
2845
+ triggerKeydown ( searchInput , Key . Down ) ;
2846
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( 2 ) ;
2847
+ triggerKeydown ( searchInput , Key . Up ) ;
2848
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( 0 ) ;
2849
+ } ) ;
2850
+
2851
+ it ( 'should ignored disabled items going up with tagging on' , function ( ) {
2852
+ var el = createUiSelectMultiple ( { uiDisableChoice :"person.age == 12" , tagging :true } ) ;
2853
+ openDropdown ( el ) ;
2854
+ var searchInput = el . find ( '.ui-select-search' ) ;
2855
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( - 1 ) ;
2856
+ triggerKeydown ( searchInput , Key . Down ) ;
2857
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( 2 ) ;
2858
+ triggerKeydown ( searchInput , Key . Up ) ;
2859
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( - 1 ) ;
2860
+ } ) ;
2861
+
2862
+ it ( 'should ignored disabled items going down' , function ( ) {
2863
+ var el = createUiSelectMultiple ( { uiDisableChoice :"person.age == 12" } ) ;
2864
+ openDropdown ( el ) ;
2865
+ var searchInput = el . find ( '.ui-select-search' ) ;
2866
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( 0 ) ;
2867
+ triggerKeydown ( searchInput , Key . Down ) ;
2868
+ triggerKeydown ( searchInput , Key . Enter ) ;
2869
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( 2 ) ;
2870
+ } ) ;
2871
+
2872
+ it ( 'should ignored disabled items going down with tagging on' , function ( ) {
2873
+ var el = createUiSelectMultiple ( { uiDisableChoice :"person.age == 12" , tagging :true } ) ;
2874
+ openDropdown ( el ) ;
2875
+ var searchInput = el . find ( '.ui-select-search' ) ;
2876
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( - 1 ) ;
2877
+ triggerKeydown ( searchInput , Key . Down ) ;
2878
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( 2 ) ;
2879
+ triggerKeydown ( searchInput , Key . Up ) ;
2880
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( - 1 ) ;
2881
+ } ) ;
2882
+
2883
+ it ( 'should ignore disabled items, going down with remove-selected on false' , function ( ) {
2884
+ var el = createUiSelectMultiple ( { uiDisableChoice :"person.age == 12" , removeSelected :false } ) ;
2885
+ openDropdown ( el ) ;
2886
+ var searchInput = el . find ( '.ui-select-search' ) ;
2887
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( 0 ) ;
2888
+ triggerKeydown ( searchInput , Key . Down ) ;
2889
+ triggerKeydown ( searchInput , Key . Enter ) ;
2890
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( 2 ) ;
2891
+ } ) ;
2892
+ } ) ;
2893
+
2835
2894
describe ( 'resetSearchInput option multiple' , function ( ) {
2836
2895
it ( 'should be true by default' , function ( ) {
2837
2896
expect ( createUiSelectMultiple ( ) . scope ( ) . $select . resetSearchInput ) . toBe ( true ) ;
@@ -2842,6 +2901,7 @@ describe('ui-select tests', function() {
2842
2901
} ) ;
2843
2902
} ) ;
2844
2903
2904
+
2845
2905
describe ( 'Reset the search value' , function ( ) {
2846
2906
it ( 'should clear the search input when resetSearchInput is true' , function ( ) {
2847
2907
var el = createUiSelectMultiple ( ) ;
@@ -3107,7 +3167,7 @@ describe('ui-select tests', function() {
3107
3167
3108
3168
describe ( 'Test Spinner for promises' , function ( ) {
3109
3169
var deferred ;
3110
-
3170
+
3111
3171
function getFromServer ( ) {
3112
3172
deferred = $q . defer ( ) ;
3113
3173
return deferred . promise ;
@@ -3130,14 +3190,14 @@ describe('ui-select tests', function() {
3130
3190
it ( 'should have set a custom class value of randomclass' , function ( ) {
3131
3191
var control = createUiSelect ( { spinnerClass : 'randomclass' } ) ;
3132
3192
expect ( control . scope ( ) . $select . spinnerClass ) . toEqual ( 'randomclass' ) ;
3133
- } ) ;
3193
+ } ) ;
3134
3194
3135
3195
it ( 'should not display spinner when disabled' , function ( ) {
3136
3196
scope . getFromServer = getFromServer ;
3137
3197
var el = createUiSelect ( { theme : 'bootstrap' , refresh :"getFromServer($select.search)" , refreshDelay :0 } ) ;
3138
3198
openDropdown ( el ) ;
3139
3199
var spinner = el . find ( '.ui-select-refreshing' ) ;
3140
- expect ( spinner . hasClass ( 'ng-hide' ) ) . toBe ( true ) ;
3200
+ expect ( spinner . hasClass ( 'ng-hide' ) ) . toBe ( true ) ;
3141
3201
setSearchText ( el , 'a' ) ;
3142
3202
expect ( spinner . hasClass ( 'ng-hide' ) ) . toBe ( true ) ;
3143
3203
deferred . resolve ( ) ;
@@ -3150,7 +3210,7 @@ describe('ui-select tests', function() {
3150
3210
var el = createUiSelect ( { spinnerEnabled : true , theme : 'bootstrap' , refresh :"getFromServer($select.search)" , refreshDelay :0 } ) ;
3151
3211
openDropdown ( el ) ;
3152
3212
var spinner = el . find ( '.ui-select-refreshing' ) ;
3153
- expect ( spinner . hasClass ( 'ng-hide' ) ) . toBe ( true ) ;
3213
+ expect ( spinner . hasClass ( 'ng-hide' ) ) . toBe ( true ) ;
3154
3214
setSearchText ( el , 'a' ) ;
3155
3215
expect ( spinner . hasClass ( 'ng-hide' ) ) . toBe ( false ) ;
3156
3216
deferred . resolve ( ) ;
@@ -3167,4 +3227,68 @@ describe('ui-select tests', function() {
3167
3227
} ) ;
3168
3228
} ) ;
3169
3229
3230
+ describe ( 'Test key down key up and activeIndex should skip disabled choice' , function ( ) {
3231
+ it ( 'should ignore disabled items, going down' , function ( ) {
3232
+ var el = createUiSelect ( { uiDisableChoice :"person.age == 12" } ) ;
3233
+ openDropdown ( el ) ;
3234
+ var searchInput = el . find ( '.ui-select-search' ) ;
3235
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( 0 ) ;
3236
+ triggerKeydown ( searchInput , Key . Down ) ;
3237
+ triggerKeydown ( searchInput , Key . Enter ) ;
3238
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( 2 ) ;
3239
+ } ) ;
3240
+
3241
+ it ( 'should ignore disabled items, going up' , function ( ) {
3242
+ var el = createUiSelect ( { uiDisableChoice :"person.age == 12" } ) ;
3243
+ openDropdown ( el ) ;
3244
+ var searchInput = el . find ( '.ui-select-search' ) ;
3245
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( 0 ) ;
3246
+ triggerKeydown ( searchInput , Key . Down ) ;
3247
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( 2 ) ;
3248
+ triggerKeydown ( searchInput , Key . Up ) ;
3249
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( 0 ) ;
3250
+ } ) ;
3251
+
3252
+ it ( 'should ignored disabled items going up with tagging on' , function ( ) {
3253
+ var el = createUiSelect ( { uiDisableChoice :"person.age == 12" , tagging :true } ) ;
3254
+ openDropdown ( el ) ;
3255
+ var searchInput = el . find ( '.ui-select-search' ) ;
3256
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( - 1 ) ;
3257
+ triggerKeydown ( searchInput , Key . Down ) ;
3258
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( 2 ) ;
3259
+ triggerKeydown ( searchInput , Key . Up ) ;
3260
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( - 1 ) ;
3261
+ } ) ;
3262
+
3263
+ it ( 'should ignored disabled items in the down direction with tagging on' , function ( ) {
3264
+ var el = createUiSelect ( { uiDisableChoice :"person.age == 12" , tagging :true } ) ;
3265
+ openDropdown ( el ) ;
3266
+ var searchInput = el . find ( '.ui-select-search' ) ;
3267
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( - 1 ) ;
3268
+ triggerKeydown ( searchInput , Key . Down ) ;
3269
+ triggerKeydown ( searchInput , Key . Enter ) ;
3270
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( 2 ) ;
3271
+ } ) ;
3272
+
3273
+ it ( 'should ignored disabled items going up with tagging on and custom tag' , function ( ) {
3274
+ var el = createUiSelect ( { uiDisableChoice :"person.age == 12" , tagging :true , taggingLabel :'custom tag' } ) ;
3275
+ openDropdown ( el ) ;
3276
+ var searchInput = el . find ( '.ui-select-search' ) ;
3277
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( - 1 ) ;
3278
+ triggerKeydown ( searchInput , Key . Down ) ;
3279
+ triggerKeydown ( searchInput , Key . Enter ) ;
3280
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( 2 ) ;
3281
+ } ) ;
3282
+
3283
+ it ( 'should ignore disabled items, going down with remove-selected on false' , function ( ) {
3284
+ var el = createUiSelect ( { uiDisableChoice :"person.age == 12" , removeSelected :false } ) ;
3285
+ openDropdown ( el ) ;
3286
+ var searchInput = el . find ( '.ui-select-search' ) ;
3287
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( 0 ) ;
3288
+ triggerKeydown ( searchInput , Key . Down ) ;
3289
+ triggerKeydown ( searchInput , Key . Enter ) ;
3290
+ expect ( el . scope ( ) . $select . activeIndex ) . toBe ( 2 ) ;
3291
+ } ) ;
3292
+ } ) ;
3293
+
3170
3294
} ) ;
0 commit comments