From 8ee714a060893fa034301a24dd988579aebcdc6e Mon Sep 17 00:00:00 2001 From: Tilman Liero Date: Sun, 10 Apr 2016 13:51:00 +0200 Subject: [PATCH] resetForm --- .../SpringDataRestEventHandler.java | 5 ++-- .../repository/TransactionRepository.java | 2 +- src/main/resources/static/css/app.css | 2 +- src/main/resources/static/index.html | 10 ++++++++ src/main/resources/static/js/controllers.js | 23 +++++++++++++++---- .../static/partials/transaction-list.html | 8 +++---- 6 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/main/java/de/tilman/transactions/repository/SpringDataRestEventHandler.java b/src/main/java/de/tilman/transactions/repository/SpringDataRestEventHandler.java index 49f361a..5eeefa6 100644 --- a/src/main/java/de/tilman/transactions/repository/SpringDataRestEventHandler.java +++ b/src/main/java/de/tilman/transactions/repository/SpringDataRestEventHandler.java @@ -21,7 +21,8 @@ public class SpringDataRestEventHandler { @HandleBeforeCreate @HandleBeforeSave public void applyUserInformationUsingSecurityContext(Transaction transaction) { - log.info("Setting date on new transaction: " + transaction.getDescription()); - transaction.setLastChange(new Date()); + Date timestamp = new Date(); + log.info("Setting date '" + timestamp + "' on new transaction: " + transaction.getDescription()); + transaction.setLastChange(timestamp); } } \ No newline at end of file diff --git a/src/main/java/de/tilman/transactions/repository/TransactionRepository.java b/src/main/java/de/tilman/transactions/repository/TransactionRepository.java index 2202a0a..00393f4 100644 --- a/src/main/java/de/tilman/transactions/repository/TransactionRepository.java +++ b/src/main/java/de/tilman/transactions/repository/TransactionRepository.java @@ -17,7 +17,7 @@ public interface TransactionRepository extends PagingAndSortingRepository findAll(Pageable pageable); @RestResource(path = "last10") - List findFirst10ByAccountIdOrderByDateDesc(@Param("accountId") Long accountId); + List findFirst10ByAccountIdOrderByDateDescLastChangeDesc(@Param("accountId") Long accountId); // TODO How to prevent loading transactions from other user's accounts? --> Solution? http://stackoverflow.com/a/21577081/3761783 // http://localhost:8080/transactions/search/descriptions?accountId=1&prefix=Kan diff --git a/src/main/resources/static/css/app.css b/src/main/resources/static/css/app.css index 4074932..d1ffffb 100644 --- a/src/main/resources/static/css/app.css +++ b/src/main/resources/static/css/app.css @@ -1,6 +1,6 @@ body { + font-family: "Open Sans", sans-serif; padding-top: 20px; - font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; } .inputTable { diff --git a/src/main/resources/static/index.html b/src/main/resources/static/index.html index 688661e..92a684e 100644 --- a/src/main/resources/static/index.html +++ b/src/main/resources/static/index.html @@ -6,15 +6,25 @@ Transactions + + + + + + + diff --git a/src/main/resources/static/js/controllers.js b/src/main/resources/static/js/controllers.js index 836faed..de8ece7 100644 --- a/src/main/resources/static/js/controllers.js +++ b/src/main/resources/static/js/controllers.js @@ -6,6 +6,19 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location' console.log('refreshList()'); + // reset form + if ($scope.form) { + $scope.form.$setPristine(); + $scope.form.$setUntouched(); + } + + $scope.transaction = { + amount: 1, + date: new Date(), +// category: categories._embedded.categories[0] + }; + + // get recent transactions var transactions = $resource('/transactions/search/last10', { accountId: $scope.accountId }).get(); transactions.$promise.then(function(data) { @@ -27,7 +40,7 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location' console.log('initList()'); - $scope.date = new Date(); + //$scope.transaction.date = new Date(); $scope.refreshList(); @@ -37,7 +50,7 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location' $scope.categories = categories._embedded.categories; // select the first entry as default - $scope.category = categories._embedded.categories[0]; + $scope.transaction.category = categories._embedded.categories[0]; }); } @@ -49,9 +62,9 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location' var newTransaction = new Transaction({ "account" : $scope.account, - "amount" : $scope.amount, - "date" : $scope.date, - "description" : $scope.description, + "amount" : $scope.transaction.amount, + "date" : $scope.transaction.date, + "description" : $scope.transaction.description, "category" : $scope.category._links.self.href, "creditor" : $scope.creditor }); diff --git a/src/main/resources/static/partials/transaction-list.html b/src/main/resources/static/partials/transaction-list.html index f0d76e2..dc8415a 100644 --- a/src/main/resources/static/partials/transaction-list.html +++ b/src/main/resources/static/partials/transaction-list.html @@ -3,18 +3,18 @@
- Betrag: + Betrag:
- Kategorie:
- Datum: + Datum:
- Notiz: + Notiz: