bugfix for description suggestions

This commit is contained in:
2016-07-31 00:34:52 +02:00
parent eb11238bb6
commit 85655497cf
3 changed files with 14 additions and 5 deletions
+11 -3
View File
@@ -207,10 +207,18 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$routePara
$scope.updateSuggestions = function(val) {
var suggestions = $resource('/api/transactions/search/descriptions', { accountId: $scope.account.id, prefix: val.toLowerCase() }).get();
return suggestions.$promise.then(function(data) {
var newSuggestions = new Array(suggestions._embedded.transactions.length);
for (i = 0; i < suggestions._embedded.transactions.length; i++) {
newSuggestions[i] = suggestions._embedded.transactions[i].description;
var newSuggestions = new Array();
var numSuggestions = 0;
var idx = 0;
while (numSuggestions < 6 && idx < suggestions._embedded.transactions.length) {
if (newSuggestions.indexOf(suggestions._embedded.transactions[idx].description) < 0) {
newSuggestions[numSuggestions] = suggestions._embedded.transactions[idx].description;
numSuggestions++;
}
idx++;
}
return newSuggestions;
});
};
@@ -62,7 +62,8 @@
id="descriptionInput"
ng-model="transaction.description"
uib-typeahead="suggestion for suggestion in updateSuggestions($viewValue)"
class="form-control">
class="form-control"
autocomplete="off">
</div>
<div class="row form-group" ng-show="accountUsers.length > 1">