Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit 2c7d3fe

Browse files
committed
Merge commit 'a67131e2d8b77f4d3e825e382819d8708e9055de'
Conflicts: dist/select.css dist/select.css.min.css dist/select.js dist/select.min.js src/select.js
2 parents afe56df + a67131e commit 2c7d3fe

File tree

10 files changed

+69
-37
lines changed

10 files changed

+69
-37
lines changed

bower.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ui-select",
3-
"version": "0.7.0",
3+
"version": "0.8.0",
44
"homepage": "https://github.com/angular-ui/ui-select",
55
"authors": [
66
"AngularUI"
@@ -13,7 +13,10 @@
1313
"node_modules",
1414
"bower_components",
1515
"src",
16-
"test"
16+
"test",
17+
"gulpfile.js",
18+
"karma.conf.js",
19+
"examples"
1720
],
1821
"dependencies": {
1922
"angular": "~1.2"

dist/select.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* ui-select
33
* http://github.com/angular-ui/ui-select
4-
* Version: 0.7.0 - 2014-10-06T12:31:14.676Z
4+
* Version: 0.8.0 - 2014-10-07T13:28:21.748Z
55
* License: MIT
66
*/
77

@@ -121,6 +121,10 @@
121121
line-height: 0.75;
122122
}
123123

124+
.ui-select-multiple.ui-select-bootstrap .ui-select-match-item{
125+
outline: 0;
126+
}
127+
124128
.ui-select-bootstrap .ui-select-choices-row>a {
125129
display: block;
126130
padding: 3px 20px;

dist/select.css.min.css

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/select.js

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* ui-select
33
* http://github.com/angular-ui/ui-select
4-
* Version: 0.7.0 - 2014-10-06T12:31:14.673Z
4+
* Version: 0.8.0 - 2014-10-07T13:28:21.745Z
55
* License: MIT
66
*/
77

@@ -269,11 +269,12 @@
269269
if (ctrl.multiple){
270270
//Remove already selected items
271271
$scope.$watchCollection('$select.selected', function(selectedItems){
272-
if (!selectedItems) return;
272+
if (!selectedItems.length) return;
273273
var data = ctrl.parserResult.source($scope);
274274
if (!data) return;
275275
var filteredItems = data.filter(function(i) {return selectedItems.indexOf(i) < 0;});
276276
setItemsFn(filteredItems);
277+
ctrl.sizeSearchInput();
277278
});
278279
}
279280

@@ -592,13 +593,11 @@
592593
result;
593594
if ($select.multiple){
594595
var resultMultiple = [];
595-
if (inputValue) {
596-
for (var j = inputValue.length - 1; j >= 0; j--) {
597-
locals = {};
598-
locals[$select.parserResult.itemName] = inputValue[j];
599-
result = $select.parserResult.modelMapper(scope, locals);
600-
resultMultiple.unshift(result);
601-
}
596+
for (var j = $select.selected.length - 1; j >= 0; j--) {
597+
locals = {};
598+
locals[$select.parserResult.itemName] = $select.selected[j];
599+
result = $select.parserResult.modelMapper(scope, locals);
600+
resultMultiple.unshift(result);
602601
}
603602
return resultMultiple;
604603
}else{
@@ -758,10 +757,8 @@
758757
});
759758

760759
if ($select.multiple){
761-
scope.$watchCollection('$select.selected', function(newValue) {
762-
//On v1.2.19 the 2nd and 3rd parameteres are ignored
763-
//On v1.3.0-beta+ 3rd parameter (revalidate) is true, to force $parsers to recreate model
764-
ngModel.$setViewValue(newValue, null, true);
760+
scope.$watchCollection('$select.selected', function() {
761+
ngModel.$setViewValue(Date.now()); //Set timestamp as a unique string to force changes
765762
});
766763
focusser.prop('disabled', true); //Focusser isn't needed if multiple
767764
}else{
@@ -955,7 +952,7 @@
955952
}());
956953

957954
angular.module("ui.select").run(["$templateCache", function($templateCache) {$templateCache.put("bootstrap/choices.tpl.html","<ul class=\"ui-select-choices ui-select-choices-content dropdown-menu\" role=\"menu\" aria-labelledby=\"dLabel\" ng-show=\"$select.items.length > 0\"><li class=\"ui-select-choices-group\"><div class=\"divider\" ng-show=\"$select.isGrouped && $index > 0\"></div><div ng-show=\"$select.isGrouped\" class=\"ui-select-choices-group-label dropdown-header\">{{$group.name}}</div><div class=\"ui-select-choices-row\" ng-class=\"{active: $select.isActive(this), disabled: $select.isDisabled(this)}\"><a href=\"javascript:void(0)\" class=\"ui-select-choices-row-inner\"></a></div></li></ul>");
958-
$templateCache.put("bootstrap/match-multiple.tpl.html","<span class=\"ui-select-match\"><span ng-repeat=\"$item in $select.selected\"><button style=\"margin-right: 3px;\" class=\"ui-select-match-item btn btn-default btn-xs\" tabindex=\"-1\" type=\"button\" ng-disabled=\"$select.disabled\" ng-click=\"$select.activeMatchIndex = $index;\" ng-class=\"{\'btn-primary\':$select.activeMatchIndex === $index}\"><span class=\"close ui-select-match-close\" ng-hide=\"$select.disabled\" ng-click=\"$select.removeChoice($index)\">&nbsp;&times;</span> <span uis-transclude-append=\"\"></span></button></span></span>");
955+
$templateCache.put("bootstrap/match-multiple.tpl.html","<span class=\"ui-select-match\"><span ng-repeat=\"$item in $select.selected\"><span style=\"margin-right: 3px;\" class=\"ui-select-match-item btn btn-default btn-xs\" tabindex=\"-1\" type=\"button\" ng-disabled=\"$select.disabled\" ng-click=\"$select.activeMatchIndex = $index;\" ng-class=\"{\'btn-primary\':$select.activeMatchIndex === $index}\"><span class=\"close ui-select-match-close\" ng-hide=\"$select.disabled\" ng-click=\"$select.removeChoice($index)\">&nbsp;&times;</span> <span uis-transclude-append=\"\"></span></span></span></span>");
959956
$templateCache.put("bootstrap/match.tpl.html","<button type=\"button\" class=\"btn btn-default form-control ui-select-match\" tabindex=\"-1\" ng-hide=\"$select.open\" ng-disabled=\"$select.disabled\" ng-class=\"{\'btn-default-focus\':$select.focus}\" ;=\"\" ng-click=\"$select.activate()\"><span ng-show=\"$select.searchEnabled && $select.isEmpty()\" class=\"text-muted\">{{$select.placeholder}}</span> <span ng-hide=\"$select.isEmpty()\" ng-transclude=\"\"></span> <span class=\"caret ui-select-toggle\" ng-click=\"$select.toggle($event)\"></span></button>");
960957
$templateCache.put("bootstrap/select-multiple.tpl.html","<div class=\"ui-select-multiple ui-select-bootstrap dropdown form-control\" ng-class=\"{open: $select.open}\"><div><div class=\"ui-select-match\"></div><input type=\"text\" autocomplete=\"off\" autocorrect=\"off\" autocapitalize=\"off\" spellcheck=\"false\" class=\"ui-select-search input-xs\" placeholder=\"{{$select.getPlaceholder()}}\" ng-disabled=\"$select.disabled\" ng-hide=\"$select.disabled\" ng-click=\"$select.activate()\" ng-model=\"$select.search\"></div><div class=\"ui-select-choices\"></div></div>");
961958
$templateCache.put("bootstrap/select.tpl.html","<div class=\"ui-select-bootstrap dropdown\" ng-class=\"{open: $select.open}\"><div class=\"ui-select-match\"></div><input type=\"text\" autocomplete=\"off\" tabindex=\"-1\" class=\"form-control ui-select-search\" placeholder=\"{{$select.placeholder}}\" ng-model=\"$select.search\" ng-show=\"$select.searchEnabled && $select.open\"><div class=\"ui-select-choices\"></div></div>");

dist/select.js.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"name": "ui-select",
3+
"main": "dist/select.js",
34
"author": "http://github.com/angular-ui/ui-select/graphs/contributors",
45
"homepage": "http://github.com/angular-ui/ui-select",
56
"repository": {
67
"url": "git://github.com/angular-ui/ui-select.git"
78
},
8-
"version": "0.7.0",
9+
"version": "0.8.0",
910
"devDependencies": {
1011
"bower": "~1.3",
1112
"del": "~0.1.1",

src/bootstrap/match-multiple.tpl.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<span class="ui-select-match">
22
<span ng-repeat="$item in $select.selected">
3-
<button
3+
<span
44
style="margin-right: 3px;"
55
class="ui-select-match-item btn btn-default btn-xs"
66
tabindex="-1"
@@ -10,6 +10,6 @@
1010
ng-class="{'btn-primary':$select.activeMatchIndex === $index}">
1111
<span class="close ui-select-match-close" ng-hide="$select.disabled" ng-click="$select.removeChoice($index)">&nbsp;&times;</span>
1212
<span uis-transclude-append></span>
13-
</button>
13+
</span>
1414
</span>
15-
</span>
15+
</span>

src/select.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@
113113
line-height: 0.75;
114114
}
115115

116+
.ui-select-multiple.ui-select-bootstrap .ui-select-match-item{
117+
outline: 0;
118+
}
119+
116120
.ui-select-bootstrap .ui-select-choices-row>a {
117121
display: block;
118122
padding: 3px 20px;

src/select.js

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -261,11 +261,12 @@
261261
if (ctrl.multiple){
262262
//Remove already selected items
263263
$scope.$watchCollection('$select.selected', function(selectedItems){
264-
if (!selectedItems) return;
264+
if (!selectedItems.length) return;
265265
var data = ctrl.parserResult.source($scope);
266266
if (!data) return;
267267
var filteredItems = data.filter(function(i) {return selectedItems.indexOf(i) < 0;});
268268
setItemsFn(filteredItems);
269+
ctrl.sizeSearchInput();
269270
});
270271
}
271272

@@ -584,13 +585,11 @@
584585
result;
585586
if ($select.multiple){
586587
var resultMultiple = [];
587-
if (inputValue) {
588-
for (var j = inputValue.length - 1; j >= 0; j--) {
589-
locals = {};
590-
locals[$select.parserResult.itemName] = inputValue[j];
591-
result = $select.parserResult.modelMapper(scope, locals);
592-
resultMultiple.unshift(result);
593-
}
588+
for (var j = $select.selected.length - 1; j >= 0; j--) {
589+
locals = {};
590+
locals[$select.parserResult.itemName] = $select.selected[j];
591+
result = $select.parserResult.modelMapper(scope, locals);
592+
resultMultiple.unshift(result);
594593
}
595594
return resultMultiple;
596595
}else{
@@ -750,10 +749,8 @@
750749
});
751750

752751
if ($select.multiple){
753-
scope.$watchCollection('$select.selected', function(newValue) {
754-
//On v1.2.19 the 2nd and 3rd parameteres are ignored
755-
//On v1.3.0-beta+ 3rd parameter (revalidate) is true, to force $parsers to recreate model
756-
ngModel.$setViewValue(newValue, null, true);
752+
scope.$watchCollection('$select.selected', function() {
753+
ngModel.$setViewValue(Date.now()); //Set timestamp as a unique string to force changes
757754
});
758755
focusser.prop('disabled', true); //Focusser isn't needed if multiple
759756
}else{

test/select.spec.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1371,6 +1371,32 @@ describe('ui-select tests', function() {
13711371

13721372
});
13731373

1374+
it('should change viewvalue only once when updating modelvalue', function () {
1375+
1376+
scope.selection.selectedMultiple = ['[email protected]', '[email protected]'];
1377+
1378+
var el = compileTemplate(
1379+
'<ui-select ng-change="onlyOnce()" multiple ng-model="selection.selectedMultiple" theme="bootstrap" style="width: 800px;"> \
1380+
<ui-select-match placeholder="Pick one...">{{$item.name}} &lt;{{$item.email}}&gt;</ui-select-match> \
1381+
<ui-select-choices repeat="person.email as person in people | filter: $select.search"> \
1382+
<div ng-bind-html="person.name | highlight: $select.search"></div> \
1383+
<div ng-bind-html="person.email | highlight: $select.search"></div> \
1384+
</ui-select-choices> \
1385+
</ui-select> \
1386+
'
1387+
);
1388+
1389+
scope.counter = 0;
1390+
scope.onlyOnce = function(){
1391+
scope.counter++;
1392+
}
1393+
1394+
clickItem(el, 'Nicole');
1395+
1396+
expect(scope.counter).toBe(1);
1397+
1398+
});
1399+
13741400
});
13751401

13761402

0 commit comments

Comments
 (0)