1
1
/*!
2
2
* ui-select
3
3
* http://github.com/angular-ui/ui-select
4
- * Version: 0.13.0 - 2015-09-29T17:48:20.967Z
4
+ * Version: 0.13.1 - 2015-09-30T05:39:26.655Z
5
5
* License: MIT
6
6
*/
7
7
@@ -394,7 +394,7 @@ uis.controller('uiSelectCtrl',
394
394
$scope . $uisSource = Object . keys ( originalSource ( $scope ) ) . map ( function ( v ) {
395
395
var result = { } ;
396
396
result [ ctrl . parserResult . keyName ] = v ;
397
- result . value = $scope [ ctrl . parserResult . sourceName ] [ v ] ;
397
+ result . value = $scope . peopleObj [ v ] ;
398
398
return result ;
399
399
} ) ;
400
400
} ;
@@ -408,7 +408,6 @@ uis.controller('uiSelectCtrl',
408
408
}
409
409
410
410
ctrl . refreshItems = function ( data ) {
411
- $scope . calculateDropdownPos ( ) ;
412
411
data = data || ctrl . parserResult . source ( $scope ) ;
413
412
var selectedItems = ctrl . selected ;
414
413
//TODO should implement for single mode removeSelected
@@ -420,6 +419,9 @@ uis.controller('uiSelectCtrl',
420
419
ctrl . setItemsFn ( filteredItems ) ;
421
420
}
422
421
}
422
+ if ( ctrl . dropdownPosition === 'auto' || ctrl . dropdownPosition === 'up' ) {
423
+ $scope . calculateDropdownPos ( ) ;
424
+ }
423
425
} ;
424
426
425
427
// See https://github.com/angular/angular.js/blob/v1.2.15/src/ng/directive/ngRepeat.js#L259
@@ -1853,21 +1855,39 @@ uis.service('uisRepeatParser', ['uiSelectMinErr','$parse', function(uiSelectMinE
1853
1855
self . parse = function ( expression ) {
1854
1856
1855
1857
1856
- //0000000000000000000000000000000000011111111100000000000000022222222222222003333333333333333333333000044444444444444444400000000000000005555500000666666666666600000000000000000000007777777770000000
1857
- var match = expression . match ( / ^ \s * (?: ( [ \s \S ] + ?) \s + a s \s + ) ? (?: ( [ \$ \w ] [ \$ \w ] * ) | (?: \( \s * ( [ \$ \w ] [ \$ \w ] * ) \s * , \s * ( [ \$ \w ] [ \$ \w ] * ) \s * \) ) ) \s + i n \s + ( [ \w ] + ) \s * ( | \s * [ \s \S ] + ?) ? (?: \s + t r a c k \s + b y \s + ( [ \s \S ] + ?) ) ? \s * $ / ) ;
1858
+ var match ;
1859
+ var isObjectCollection = / \( \s * ( [ \$ \w ] [ \$ \w ] * ) \s * , \s * ( [ \$ \w ] [ \$ \w ] * ) \s * \) / . test ( expression ) ;
1860
+ // If an array is used as collection
1861
+
1862
+ // if (isObjectCollection){
1863
+ //00000000000000000000000000000111111111000000000000000222222222222220033333333333333333333330000444444444444444444000000000000000556666660000077777777777755000000000000000000000088888880000000
1864
+ match = expression . match ( / ^ \s * (?: ( [ \s \S ] + ?) \s + a s \s + ) ? (?: ( [ \$ \w ] [ \$ \w ] * ) | (?: \( \s * ( [ \$ \w ] [ \$ \w ] * ) \s * , \s * ( [ \$ \w ] [ \$ \w ] * ) \s * \) ) ) \s + i n \s + ( ( [ \w ] + ) ? \s * ( | \s * [ \s \S ] + ?) ) ? (?: \s + t r a c k \s + b y \s + ( [ \s \S ] + ?) ) ? \s * $ / ) ;
1865
+
1866
+ // 1 Alias
1867
+ // 2 Item
1868
+ // 3 Key on (key,value)
1869
+ // 4 Value on (key,value)
1870
+ // 5 Collection expresion (only used when using an array collection)
1871
+ // 6 Object that will be converted to Array when using (key,value) syntax
1872
+ // 7 Filters that will be applied to #6 when using (key,value) syntax
1873
+ // 8 Track by
1858
1874
1859
1875
if ( ! match ) {
1860
1876
throw uiSelectMinErr ( 'iexp' , "Expected expression in form of '_item_ in _collection_[ track by _id_]' but got '{0}'." ,
1861
1877
expression ) ;
1862
1878
}
1879
+ if ( ! match [ 6 ] && isObjectCollection ) {
1880
+ throw uiSelectMinErr ( 'iexp' , "Expected expression in form of '_item_ as (_key_, _item_) in _ObjCollection_ [ track by _id_]' but got '{0}'." ,
1881
+ expression ) ;
1882
+ }
1863
1883
1864
1884
return {
1865
1885
itemName : match [ 4 ] || match [ 2 ] , // (lhs) Left-hand side,
1866
1886
keyName : match [ 3 ] , //for (key, value) syntax
1867
- source : $parse ( ! match [ 3 ] ? match [ 5 ] + ( match [ 6 ] || '' ) : match [ 5 ] ) , //concat source with filters if its an array
1868
- sourceName : match [ 5 ] ,
1869
- filters : match [ 6 ] ,
1870
- trackByExp : match [ 7 ] ,
1887
+ source : $parse ( ! match [ 3 ] ? match [ 5 ] : match [ 6 ] ) ,
1888
+ sourceName : match [ 6 ] ,
1889
+ filters : match [ 7 ] ,
1890
+ trackByExp : match [ 8 ] ,
1871
1891
modelMapper : $parse ( match [ 1 ] || match [ 4 ] || match [ 2 ] ) ,
1872
1892
repeatExpression : function ( grouped ) {
1873
1893
var expression = this . itemName + ' in ' + ( grouped ? '$group.items' : '$select.items' ) ;
0 commit comments