transaction details (using code copied from TransactionListCtrl)
This commit is contained in:
@@ -211,14 +211,55 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
|
|||||||
} ]);
|
} ]);
|
||||||
|
|
||||||
transactionControllers.controller('TransactionDetailCtrl', [ '$scope', '$routeParams', '$resource', '$location', function($scope, $routeParams, $resource, $location) {
|
transactionControllers.controller('TransactionDetailCtrl', [ '$scope', '$routeParams', '$resource', '$location', function($scope, $routeParams, $resource, $location) {
|
||||||
var transaction = $resource($routeParams.transactionURI).get();
|
|
||||||
transaction.$promise.then(function(data) {
|
|
||||||
transaction.category = $resource(transaction._links.category.href).get();
|
|
||||||
transaction.creditor = $resource(transaction._links.creditor.href).get();
|
|
||||||
transaction.account = $resource(transaction._links.account.href).get();
|
|
||||||
});
|
|
||||||
|
|
||||||
$scope.transaction = transaction;
|
$scope.initDetails = function() {
|
||||||
|
console.log('initDetails()');
|
||||||
|
|
||||||
|
var transaction = $resource($routeParams.transactionURI).get();
|
||||||
|
transaction.$promise.then(function(data) {
|
||||||
|
transaction.date = new Date(transaction.date);
|
||||||
|
transaction.category = $resource(transaction._links.category.href).get();
|
||||||
|
transaction.creditor = $resource(transaction._links.creditor.href).get();
|
||||||
|
transaction.account = $resource(transaction._links.account.href).get();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
$scope.transaction = transaction;
|
||||||
|
|
||||||
|
// FIXME
|
||||||
|
// TODO The rest of this function is *copied code* from TransactionListCtrl and desperately needs to be moved into a service
|
||||||
|
|
||||||
|
var userinfo = $resource('/user').get();
|
||||||
|
userinfo.$promise.then(function(data) {
|
||||||
|
$scope.userid = userinfo.name;
|
||||||
|
|
||||||
|
userinfo = $resource('/users/search/findByUsername', { username: $scope.userid }).get();
|
||||||
|
userinfo.$promise.then(function(data) {
|
||||||
|
$scope.userinfo = userinfo;
|
||||||
|
});
|
||||||
|
|
||||||
|
var accountInfo = $resource('/accounts/search/findByUserName', { username: $scope.userid }).get();
|
||||||
|
accountInfo.$promise.then(function(data) {
|
||||||
|
$scope.accounts = accountInfo._embedded.accounts;
|
||||||
|
$scope.account = $scope.accounts[0];
|
||||||
|
|
||||||
|
var categories = $resource('/categories/search/listForAccount', { accountId: $scope.accounts[0].id }).get();
|
||||||
|
categories.$promise.then(function(data) {
|
||||||
|
$scope.categories = categories._embedded.categories;
|
||||||
|
|
||||||
|
//$scope.categories.push({id: -1, name: '────────────────', position: 9999, disabled: true});
|
||||||
|
$scope.categories.push({id: -1, name: 'private Entnahme', position: 10000, _links: { self: {href: 'withdrawal'}}});
|
||||||
|
|
||||||
|
// FIXME Code from TransactionListCtrl.refreshList()
|
||||||
|
var accountUsers = $resource($scope.account._links.users.href).get();
|
||||||
|
accountUsers.$promise.then(function(data) {
|
||||||
|
$scope.accountUsers = accountUsers._embedded.users;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$scope.deleteTransaction = function(transaction) {
|
$scope.deleteTransaction = function(transaction) {
|
||||||
/*console.log(angular.toJson(transaction, false));*/
|
/*console.log(angular.toJson(transaction, false));*/
|
||||||
@@ -228,6 +269,8 @@ transactionControllers.controller('TransactionDetailCtrl', [ '$scope', '$routePa
|
|||||||
$location.path('/');
|
$location.path('/');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.initDetails();
|
||||||
|
|
||||||
} ]);
|
} ]);
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,44 @@
|
|||||||
|
<form name="form" ng-submit="updateTransaction()">
|
||||||
|
<table border='0' cellpadding='1' style='margin: auto;'>
|
||||||
|
<tr>
|
||||||
|
<td align='right'>Betrag:</td>
|
||||||
|
<td><input name="amount" ng-model='transaction.amount' type='text' required autofocus="autofocus"
|
||||||
|
ng-pattern="/^[+-]?(?:\d+(?:[\.,]\d{0,2})?|[\.,]\d{1,2})$/" /><span ng-show="form.amount.$error.pattern"><br/>The value
|
||||||
|
is not valid!</span></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align='right'>Kategorie:</td>
|
||||||
|
<td><select ng-model='transaction.category' size='1'
|
||||||
|
ng-options="category.name for category in categories track by category._links.self.href" ng-change='checkCategory()'>
|
||||||
|
</select></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align='right'>Datum:</td>
|
||||||
|
<td><input ng-model='transaction.date' type='date' placeholder="yyyy-MM-dd" required /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align='right'>Notiz:</td>
|
||||||
|
<td><input ng-model='transaction.description' type='text' size='20' /></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align='right'>Auslage:</td>
|
||||||
|
<td>
|
||||||
|
<!-- label class='userLabel'><input name='expenseBy' ng-model='transaction.creditor' ng-value='none' type='radio' checked='checked' />Keine</label -->
|
||||||
|
<!-- label ng-repeat="user in accountUsers" class='userLabel'><input name='expenseBy' ng-model='$parent.transaction.creditor' ng-value='{{user.name}}' type='radio' />{{user.name}}</label -->
|
||||||
|
|
||||||
|
<label class='userLabel'><input id='noCreditorRadioButton' name='expenseBy' ng-model='transaction.creditor' type='radio' value='' checked='checked' />Keine</label>
|
||||||
|
<label class='userLabel' ng-repeat="user in accountUsers"><input name='expenseBy' ng-model='$parent.transaction.creditor' type='radio' value="{{user._links.self.href}}" />{{user.name}}</label>
|
||||||
|
</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td align='center' colspan='2'><input type="submit" ng-disabled="form.amount.$error.pattern" /></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
<!--
|
||||||
<table class="listing">
|
<table class="listing">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Datum</th>
|
<th>Datum</th>
|
||||||
@@ -14,6 +55,8 @@
|
|||||||
</table>
|
</table>
|
||||||
|
|
||||||
<div ng-if="transaction.creditor.name">Auslage: {{transaction.creditor.name}}</div>
|
<div ng-if="transaction.creditor.name">Auslage: {{transaction.creditor.name}}</div>
|
||||||
|
-->
|
||||||
|
|
||||||
|
|
||||||
<div style="margin: auto; width: 20%; border: 1px dotted lightgray;">
|
<div style="margin: auto; width: 20%; border: 1px dotted lightgray;">
|
||||||
<a class="btn btn-danger" ng-click="deleteTransaction(transaction)">Delete</a>
|
<a class="btn btn-danger" ng-click="deleteTransaction(transaction)">Delete</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user