Don't autosuggest items that are already in the list of selected items

develop
Sven Slootweg 11 years ago
parent 92ee987760
commit 09e7b98ed8

@ -197,7 +197,9 @@ module.directive("searchList", function(){
if (scope.listQuery !== "") if (scope.listQuery !== "")
{ {
scope.listItems = util.objectToArray(scope.source).filter(function(item){ scope.listItems = util.objectToArray(scope.source).filter(function(item){
return (item.key.toLowerCase().indexOf(scope.listQuery.toLowerCase()) !== -1 || item.value.toLowerCase().indexOf(scope.listQuery.toLowerCase()) !== -1); var matches = (item.key.toLowerCase().indexOf(scope.listQuery.toLowerCase()) !== -1 || item.value.toLowerCase().indexOf(scope.listQuery.toLowerCase()) !== -1);
var selected = (scope.ngModelItems.filter(function(selected_item){ return item.key == selected_item.key; }).length > 0);
return matches && !selected;
}).sort(function(a, b){ }).sort(function(a, b){
index_a = a.value.indexOf(scope.listQuery); index_a = a.value.indexOf(scope.listQuery);

Loading…
Cancel
Save