resetForm
This commit is contained in:
@@ -21,7 +21,8 @@ public class SpringDataRestEventHandler {
|
|||||||
@HandleBeforeCreate
|
@HandleBeforeCreate
|
||||||
@HandleBeforeSave
|
@HandleBeforeSave
|
||||||
public void applyUserInformationUsingSecurityContext(Transaction transaction) {
|
public void applyUserInformationUsingSecurityContext(Transaction transaction) {
|
||||||
log.info("Setting date on new transaction: " + transaction.getDescription());
|
Date timestamp = new Date();
|
||||||
transaction.setLastChange(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);
|
// Page<Transaction> findAll(Pageable pageable);
|
||||||
|
|
||||||
@RestResource(path = "last10")
|
@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
|
// 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
|
// http://localhost:8080/transactions/search/descriptions?accountId=1&prefix=Kan
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
body {
|
body {
|
||||||
|
font-family: "Open Sans", sans-serif;
|
||||||
padding-top: 20px;
|
padding-top: 20px;
|
||||||
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.inputTable {
|
.inputTable {
|
||||||
|
|||||||
@@ -6,15 +6,25 @@
|
|||||||
|
|
||||||
<title>Transactions</title>
|
<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">
|
<link rel="stylesheet" href="css/app.css">
|
||||||
|
|
||||||
<script src="js/angular.min.js"></script>
|
<script src="js/angular.min.js"></script>
|
||||||
<script src="js/angular-route.min.js"></script>
|
<script src="js/angular-route.min.js"></script>
|
||||||
<script src="js/angular-resource.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/app.js"></script>
|
||||||
<script src="js/controllers.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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,19 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
|
|||||||
|
|
||||||
console.log('refreshList()');
|
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();
|
var transactions = $resource('/transactions/search/last10', { accountId: $scope.accountId }).get();
|
||||||
|
|
||||||
transactions.$promise.then(function(data) {
|
transactions.$promise.then(function(data) {
|
||||||
@@ -27,7 +40,7 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
|
|||||||
|
|
||||||
console.log('initList()');
|
console.log('initList()');
|
||||||
|
|
||||||
$scope.date = new Date();
|
//$scope.transaction.date = new Date();
|
||||||
|
|
||||||
$scope.refreshList();
|
$scope.refreshList();
|
||||||
|
|
||||||
@@ -37,7 +50,7 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
|
|||||||
$scope.categories = categories._embedded.categories;
|
$scope.categories = categories._embedded.categories;
|
||||||
|
|
||||||
// select the first entry as default
|
// 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({
|
var newTransaction = new Transaction({
|
||||||
"account" : $scope.account,
|
"account" : $scope.account,
|
||||||
"amount" : $scope.amount,
|
"amount" : $scope.transaction.amount,
|
||||||
"date" : $scope.date,
|
"date" : $scope.transaction.date,
|
||||||
"description" : $scope.description,
|
"description" : $scope.transaction.description,
|
||||||
"category" : $scope.category._links.self.href,
|
"category" : $scope.category._links.self.href,
|
||||||
"creditor" : $scope.creditor
|
"creditor" : $scope.creditor
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,18 +3,18 @@
|
|||||||
<div>
|
<div>
|
||||||
<form role="form" ng-submit="postTransaction()">
|
<form role="form" ng-submit="postTransaction()">
|
||||||
<div>
|
<div>
|
||||||
Betrag: <input ng-model='amount' type='number' />
|
Betrag: <input ng-model='transaction.amount' type='number' />
|
||||||
</div>
|
</div>
|
||||||
<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">
|
ng-options="category.name for category in categories track by category._links.self.href">
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<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>
|
||||||
<div>
|
<div>
|
||||||
Notiz: <input ng-model='description' type='text' size='10' />
|
Notiz: <input ng-model='transaction.description' type='text' size='10' />
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<input type="submit" />
|
<input type="submit" />
|
||||||
|
|||||||
Reference in New Issue
Block a user