(js) Fix auto-completion of list members

Fixes #3870
This commit is contained in:
Francis Lachapelle
2016-10-26 15:48:40 -04:00
parent 1d09a980da
commit 7310834ac6
4 changed files with 10 additions and 12 deletions
@@ -7,9 +7,9 @@
* Controller to view and edit a card
* @ngInject
*/
CardController.$inject = ['$scope', '$timeout', '$window', '$mdDialog', 'AddressBook', 'Card', 'Dialog', 'sgHotkeys', 'sgFocus', '$state', '$stateParams', 'stateCard'];
function CardController($scope, $timeout, $window, $mdDialog, AddressBook, Card, Dialog, sgHotkeys, focus, $state, $stateParams, stateCard) {
var vm = this, hotkeys = [], minSearchLength;
CardController.$inject = ['$scope', '$timeout', '$window', '$mdDialog', 'sgSettings', 'AddressBook', 'Card', 'Dialog', 'sgHotkeys', 'sgFocus', '$state', '$stateParams', 'stateCard'];
function CardController($scope, $timeout, $window, $mdDialog, sgSettings, AddressBook, Card, Dialog, sgHotkeys, focus, $state, $stateParams, stateCard) {
var vm = this, hotkeys = [];
vm.card = stateCard;
@@ -37,8 +37,6 @@
vm.toggleRawSource = toggleRawSource;
vm.showRawSource = false;
minSearchLength = angular.isNumber($window.minimumSearchLength)? $window.minimumSearchLength : 2;
_registerHotkeys(hotkeys);
@@ -100,11 +98,12 @@
focus('address_' + i);
}
function userFilter($query, excludedCards) {
if ($query.length < minSearchLength)
if ($query.length < sgSettings.minimumSearchLength())
return [];
AddressBook.selectedFolder.$filter($query, {dry: true, excludeLists: true}, excludedCards);
return AddressBook.selectedFolder.$$cards;
return AddressBook.selectedFolder.$filter($query, {dry: true, excludeLists: true}, excludedCards).then(function(cards) {
return cards;
});
}
function save(form) {
if (form.$valid) {