From 85655497cfbe4bbe72998909597071400fe4fad1 Mon Sep 17 00:00:00 2001 From: Tilman Liero Date: Sun, 31 Jul 2016 00:34:52 +0200 Subject: [PATCH] bugfix for description suggestions --- pom.xml | 2 +- src/main/resources/static/app/controllers.js | 14 +++++++++++--- .../resources/static/app/transaction-list.html | 3 ++- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 5bbcefa..9a522f6 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 de.tilman next-transactions - 1.5.2 + 1.5.3 org.springframework.boot diff --git a/src/main/resources/static/app/controllers.js b/src/main/resources/static/app/controllers.js index 05b3182..dc115fc 100644 --- a/src/main/resources/static/app/controllers.js +++ b/src/main/resources/static/app/controllers.js @@ -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; }); }; diff --git a/src/main/resources/static/app/transaction-list.html b/src/main/resources/static/app/transaction-list.html index 0fc3a04..79641a6 100644 --- a/src/main/resources/static/app/transaction-list.html +++ b/src/main/resources/static/app/transaction-list.html @@ -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">