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
+1 -1
View File
@@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>de.tilman</groupId> <groupId>de.tilman</groupId>
<artifactId>next-transactions</artifactId> <artifactId>next-transactions</artifactId>
<version>1.5.2</version> <version>1.5.3</version>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
+11 -3
View File
@@ -207,10 +207,18 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$routePara
$scope.updateSuggestions = function(val) { $scope.updateSuggestions = function(val) {
var suggestions = $resource('/api/transactions/search/descriptions', { accountId: $scope.account.id, prefix: val.toLowerCase() }).get(); var suggestions = $resource('/api/transactions/search/descriptions', { accountId: $scope.account.id, prefix: val.toLowerCase() }).get();
return suggestions.$promise.then(function(data) { return suggestions.$promise.then(function(data) {
var newSuggestions = new Array(suggestions._embedded.transactions.length); var newSuggestions = new Array();
for (i = 0; i < suggestions._embedded.transactions.length; i++) { var numSuggestions = 0;
newSuggestions[i] = suggestions._embedded.transactions[i].description; 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; return newSuggestions;
}); });
}; };
@@ -62,7 +62,8 @@
id="descriptionInput" id="descriptionInput"
ng-model="transaction.description" ng-model="transaction.description"
uib-typeahead="suggestion for suggestion in updateSuggestions($viewValue)" uib-typeahead="suggestion for suggestion in updateSuggestions($viewValue)"
class="form-control"> class="form-control"
autocomplete="off">
</div> </div>
<div class="row form-group" ng-show="accountUsers.length > 1"> <div class="row form-group" ng-show="accountUsers.length > 1">