From 7100805189f8b9da272da21eb09b2565e1f0cc7d Mon Sep 17 00:00:00 2001 From: Tilman Liero Date: Sun, 12 Jun 2016 14:00:12 +0200 Subject: [PATCH] angular-ui --- src/main/resources/static/index.html | 2 - src/main/resources/static/js/app.js | 2 +- .../resources/static/js/autocomplete.min.js | 1 - src/main/resources/static/js/controllers.js | 19 +------ .../static/partials/transaction-list.html | 50 ++++++++++--------- 5 files changed, 28 insertions(+), 46 deletions(-) delete mode 100644 src/main/resources/static/js/autocomplete.min.js diff --git a/src/main/resources/static/index.html b/src/main/resources/static/index.html index 543548d..3065d27 100644 --- a/src/main/resources/static/index.html +++ b/src/main/resources/static/index.html @@ -17,8 +17,6 @@ - - diff --git a/src/main/resources/static/js/app.js b/src/main/resources/static/js/app.js index 14b86d1..af1c908 100644 --- a/src/main/resources/static/js/app.js +++ b/src/main/resources/static/js/app.js @@ -1,4 +1,4 @@ -var transactionsApp = angular.module('transactionsApp', ['ui.bootstrap', 'ngRoute', 'transactionControllers', 'autocomplete' ]); +var transactionsApp = angular.module('transactionsApp', ['ui.bootstrap', 'ngRoute', 'transactionControllers' ]); transactionsApp.config([ '$routeProvider', function($routeProvider) { $routeProvider.when('/list', { diff --git a/src/main/resources/static/js/autocomplete.min.js b/src/main/resources/static/js/autocomplete.min.js deleted file mode 100644 index 3371156..0000000 --- a/src/main/resources/static/js/autocomplete.min.js +++ /dev/null @@ -1 +0,0 @@ -var app=angular.module("autocomplete",[]);app.directive("autocomplete",function(){var e=-1;return{restrict:"E",scope:{searchParam:"=ngModel",suggestions:"=data",onType:"=onType",onSelect:"=onSelect",autocompleteRequired:"="},controller:["$scope",function(e){e.selectedIndex=-1,e.initLock=!0,e.setIndex=function(t){e.selectedIndex=parseInt(t)},this.setIndex=function(t){e.setIndex(t),e.$apply()},e.getIndex=function(t){return e.selectedIndex};var t=!0;e.completing=!1,e.$watch("searchParam",function(n,i){i===n||!i&&e.initLock||(t&&"undefined"!=typeof e.searchParam&&null!==e.searchParam&&(e.completing=!0,e.searchFilter=e.searchParam,e.selectedIndex=-1),e.onType&&e.onType(e.searchParam))}),this.preSelect=function(n){t=!1,e.$apply(),t=!0},e.preSelect=this.preSelect,this.preSelectOff=function(){t=!0},e.preSelectOff=this.preSelectOff,e.select=function(n){n&&(e.searchParam=n,e.searchFilter=n,e.onSelect&&e.onSelect(n)),t=!1,e.completing=!1,setTimeout(function(){t=!0},1e3),e.setIndex(-1)}}],link:function(t,n,i){setTimeout(function(){t.initLock=!1,t.$apply()},250);var a="";t.attrs={placeholder:"start typing...","class":"",id:"",inputclass:"",inputid:""};for(var r in i)a=r.replace("attr","").toLowerCase(),0===r.indexOf("attr")&&(t.attrs[a]=i[r]);i.clickActivation&&(n[0].onclick=function(e){t.searchParam||setTimeout(function(){t.completing=!0,t.$apply()},200)});var l={left:37,up:38,right:39,down:40,enter:13,esc:27,tab:9};document.addEventListener("keydown",function(e){var n=e.keyCode||e.which;switch(n){case l.esc:t.select(),t.setIndex(-1),t.$apply(),e.preventDefault()}},!0),document.addEventListener("blur",function(e){setTimeout(function(){t.select(),t.setIndex(-1),t.$apply()},150)},!0),n[0].addEventListener("keydown",function(n){var i=n.keyCode||n.which,a=angular.element(this).find("li").length;if(t.completing&&0!=a)switch(i){case l.up:if(e=t.getIndex()-1,-1>e)e=a-1;else if(e>=a){e=-1,t.setIndex(e),t.preSelectOff();break}t.setIndex(e),-1!==e&&t.preSelect(angular.element(angular.element(this).find("li")[e]).text()),t.$apply();break;case l.down:if(e=t.getIndex()+1,-1>e)e=a-1;else if(e>=a){e=-1,t.setIndex(e),t.preSelectOff(),t.$apply();break}t.setIndex(e),-1!==e&&t.preSelect(angular.element(angular.element(this).find("li")[e]).text());break;case l.left:break;case l.right:case l.enter:case l.tab:e=t.getIndex(),-1!==e?(t.select(angular.element(angular.element(this).find("li")[e]).text()),i==l.enter&&n.preventDefault()):i==l.enter&&t.select(),t.setIndex(-1),t.$apply();break;case l.esc:t.select(),t.setIndex(-1),t.$apply(),n.preventDefault();break;default:return}})},template:'
'}}),app.filter("highlight",["$sce",function(e){return function(t,n){if("function"==typeof t)return"";if(n){var i="("+n.split(/\ /).join(" |")+"|"+n.split(/\ /).join("|")+")",a=new RegExp(i,"gi");i.length&&(t=t.replace(a,'$1'))}return e.trustAsHtml(t)}}]),app.directive("suggestion",function(){return{restrict:"A",require:"^autocomplete",link:function(e,t,n,i){t.bind("mouseenter",function(){i.preSelect(n.val),i.setIndex(n.index)}),t.bind("mouseleave",function(){i.preSelectOff()})}}}); \ No newline at end of file diff --git a/src/main/resources/static/js/controllers.js b/src/main/resources/static/js/controllers.js index aefe847..8ee83df 100644 --- a/src/main/resources/static/js/controllers.js +++ b/src/main/resources/static/js/controllers.js @@ -218,30 +218,13 @@ transactionControllers.controller('TransactionListCtrl', [ '$http', '$scope', '$ } }; - $scope.updateSuggestions = function(typed) { - var suggestions = $resource('http://localhost:8080/transactions/search/descriptions', { accountId: $scope.account.id, prefix: typed.toLowerCase() }).get(); - suggestions.$promise.then(function(data) { - console.log(suggestions); - - var newSuggestions = new Array(suggestions._embedded.transactions.length); - for (i = 0; i < suggestions._embedded.transactions.length; i++) { - newSuggestions[i] = suggestions._embedded.transactions[i].description; - } - - $scope.descriptionSuggestions = newSuggestions; - }); - } - - $scope.getLocation = function(val) { + $scope.updateSuggestions = function(val) { var suggestions = $resource('http://localhost:8080/transactions/search/descriptions', { accountId: $scope.account.id, prefix: val.toLowerCase() }).get(); return suggestions.$promise.then(function(data) { - console.log(suggestions); - var newSuggestions = new Array(suggestions._embedded.transactions.length); for (i = 0; i < suggestions._embedded.transactions.length; i++) { newSuggestions[i] = suggestions._embedded.transactions[i].description; } - return newSuggestions; }); }; diff --git a/src/main/resources/static/partials/transaction-list.html b/src/main/resources/static/partials/transaction-list.html index 9f89083..9837148 100644 --- a/src/main/resources/static/partials/transaction-list.html +++ b/src/main/resources/static/partials/transaction-list.html @@ -19,13 +19,17 @@
-
-
Betrag:
-
-
The value - is not valid!
-
+
+ + +
The value is not valid!

@@ -33,7 +37,11 @@
Kategorie:
- +
@@ -42,7 +50,11 @@
Datum:
- +
@@ -51,20 +63,10 @@
Notiz:
- - -
-
- -
-

Asynchronous results

-
Model: {{asyncSelected | json}}
- -
- No Results Found +
@@ -115,7 +117,7 @@
{{user.name}} {{user.outstandings | number : 2}} €
- +