resetForm
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ public interface TransactionRepository extends PagingAndSortingRepository<Transa
|
||||
// Page<Transaction> findAll(Pageable pageable);
|
||||
|
||||
@RestResource(path = "last10")
|
||||
List<Transaction> findFirst10ByAccountIdOrderByDateDesc(@Param("accountId") Long accountId);
|
||||
List<Transaction> 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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
body {
|
||||
font-family: "Open Sans", sans-serif;
|
||||
padding-top: 20px;
|
||||
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
|
||||
}
|
||||
|
||||
.inputTable {
|
||||
|
||||
@@ -6,15 +6,25 @@
|
||||
|
||||
<title>Transactions</title>
|
||||
|
||||
<!-- link rel="stylesheet" href="css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="css/bootstrap-theme.min.css" -->
|
||||
<link rel="stylesheet" href="css/app.css">
|
||||
|
||||
<script src="js/angular.min.js"></script>
|
||||
<script src="js/angular-route.min.js"></script>
|
||||
<script src="js/angular-resource.min.js"></script>
|
||||
<!-- script src="js/jquery-2.1.4.min.js"></script>
|
||||
<script src="js/bootstrap.min.js"></script -->
|
||||
|
||||
<script src="js/app.js"></script>
|
||||
<script src="js/controllers.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
|
||||
<!-- link href='https://fonts.googleapis.com/css?family=Lato' rel='stylesheet' type='text/css'>
|
||||
<link href='http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:400,300,700' rel='stylesheet' type='text/css'-->
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
@@ -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
|
||||
});
|
||||
|
||||
@@ -3,18 +3,18 @@
|
||||
<div>
|
||||
<form role="form" ng-submit="postTransaction()">
|
||||
<div>
|
||||
Betrag: <input ng-model='amount' type='number' />
|
||||
Betrag: <input ng-model='transaction.amount' type='number' />
|
||||
</div>
|
||||
<div>
|
||||
Kategorie: <select ng-model='category' size='1'
|
||||
Kategorie: <select ng-model='transaction.category' size='1'
|
||||
ng-options="category.name for category in categories track by category._links.self.href">
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
Datum: <input ng-model='date' type='date' placeholder="yyyy-MM-dd" required />
|
||||
Datum: <input ng-model='transaction.date' type='date' placeholder="yyyy-MM-dd" required />
|
||||
</div>
|
||||
<div>
|
||||
Notiz: <input ng-model='description' type='text' size='10' />
|
||||
Notiz: <input ng-model='transaction.description' type='text' size='10' />
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" />
|
||||
|
||||
Reference in New Issue
Block a user