Skip to content

Commit a52cb99

Browse files
author
Ben TORFS
committed
Extra tests + error message in case of missing configuration
1 parent 6c2be61 commit a52cb99

11 files changed

+441
-14
lines changed

dist/angular-bootstrap-multiselect-templates.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ angular.module("multiselect.html", []).run(["$templateCache", function($template
3939
"\n" +
4040
" <li ng-show=\"showSearch\" class=\"divider\"></li>\n" +
4141
" <li role=\"presentation\" ng-repeat=\"option in unselectedOptions | filter:search() | limitTo: searchLimit\"\n" +
42-
" ng-if=\"!isSelected(option)\" ng-class=\"{disabled : selectedOptions.length >= selectionLimit}\">\n" +
42+
" ng-if=\"!isSelected(option)\" ng-class=\"{disabled : selectionLimit && selectedOptions.length >= selectionLimit}\">\n" +
4343
" <a class=\"item-unselected\" href=\"\" ng-click=\"toggleItem(option); $event.stopPropagation()\">\n" +
4444
" {{getDisplay(option)}}\n" +
4545
" </a>\n" +

dist/angular-bootstrap-multiselect.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
}, object)
1414
};
1515

16-
multiselect.directive('multiselect', ['$filter', '$document', function ($filter, $document) {
16+
multiselect.directive('multiselect', ['$filter', '$document', '$log', function ($filter, $document, $log) {
1717
return {
1818
restrict: 'AE',
1919
scope: {
@@ -145,7 +145,12 @@
145145
if (angular.isString(item)) {
146146
return item;
147147
} else if (angular.isObject(item)) {
148-
return multiselect.getRecursiveProperty(item, $scope.idProp);
148+
if ($scope.idProp) {
149+
return multiselect.getRecursiveProperty(item, $scope.idProp);
150+
} else {
151+
$log.error('Multiselect: when using objects as model, a idProp value is mandatory.');
152+
return '';
153+
}
149154
} else {
150155
return item;
151156
}
@@ -155,7 +160,12 @@
155160
if (angular.isString(item)) {
156161
return item;
157162
} else if (angular.isObject(item)) {
158-
return multiselect.getRecursiveProperty(item, $scope.displayProp);
163+
if ($scope.displayProp) {
164+
return multiselect.getRecursiveProperty(item, $scope.displayProp);
165+
} else {
166+
$log.error('Multiselect: when using objects as model, a displayProp value is mandatory.');
167+
return '';
168+
}
159169
} else {
160170
return item;
161171
}
@@ -242,7 +252,7 @@ angular.module("multiselect.html", []).run(["$templateCache", function($template
242252
"\n" +
243253
" <li ng-show=\"showSearch\" class=\"divider\"></li>\n" +
244254
" <li role=\"presentation\" ng-repeat=\"option in unselectedOptions | filter:search() | limitTo: searchLimit\"\n" +
245-
" ng-if=\"!isSelected(option)\" ng-class=\"{disabled : selectedOptions.length >= selectionLimit}\">\n" +
255+
" ng-if=\"!isSelected(option)\" ng-class=\"{disabled : selectionLimit && selectedOptions.length >= selectionLimit}\">\n" +
246256
" <a class=\"item-unselected\" href=\"\" ng-click=\"toggleItem(option); $event.stopPropagation()\">\n" +
247257
" {{getDisplay(option)}}\n" +
248258
" </a>\n" +

dist/angular-bootstrap-multiselect.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/multiselect.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
<li ng-show="showSearch" class="divider"></li>
3737
<li role="presentation" ng-repeat="option in unselectedOptions | filter:search() | limitTo: searchLimit"
38-
ng-if="!isSelected(option)" ng-class="{disabled : selectedOptions.length >= selectionLimit}">
38+
ng-if="!isSelected(option)" ng-class="{disabled : selectionLimit && selectedOptions.length >= selectionLimit}">
3939
<a class="item-unselected" href="" ng-click="toggleItem(option); $event.stopPropagation()">
4040
{{getDisplay(option)}}
4141
</a>

src/multiselect.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
}, object)
1414
};
1515

16-
multiselect.directive('multiselect', function ($filter, $document) {
16+
multiselect.directive('multiselect', function ($filter, $document, $log) {
1717
return {
1818
restrict: 'AE',
1919
scope: {
@@ -145,7 +145,12 @@
145145
if (angular.isString(item)) {
146146
return item;
147147
} else if (angular.isObject(item)) {
148-
return multiselect.getRecursiveProperty(item, $scope.idProp);
148+
if ($scope.idProp) {
149+
return multiselect.getRecursiveProperty(item, $scope.idProp);
150+
} else {
151+
$log.error('Multiselect: when using objects as model, a idProp value is mandatory.');
152+
return '';
153+
}
149154
} else {
150155
return item;
151156
}
@@ -155,7 +160,12 @@
155160
if (angular.isString(item)) {
156161
return item;
157162
} else if (angular.isObject(item)) {
158-
return multiselect.getRecursiveProperty(item, $scope.displayProp);
163+
if ($scope.displayProp) {
164+
return multiselect.getRecursiveProperty(item, $scope.displayProp);
165+
} else {
166+
$log.error('Multiselect: when using objects as model, a displayProp value is mandatory.');
167+
return '';
168+
}
159169
} else {
160170
return item;
161171
}

0 commit comments

Comments
 (0)