user interface for withdrawals

This commit is contained in:
2016-04-17 13:56:37 +02:00
parent 64b971e4ac
commit 51f70c3b45
3 changed files with 79 additions and 51 deletions
+32 -10
View File
@@ -34,28 +34,50 @@ transactionControllers.controller('TransactionListCtrl', [ '$scope', '$location'
});
console.log('$scope.account.links.users:');
console.log($scope.account._links.users);
// HIER GEHT'S WEITER
// URL des aktuell selektierten Account ermitteln, dann /accounts/id/users abrufen, Liste für Radiobuttons bereitstellen
var accountUsers = $resource($scope.account._links.users.href).get();
accountUsers.$promise.then(function(data) {
console.log('accountUsers');
console.log(accountUsers);
$scope.accountUsers = accountUsers._embedded.users;
});
}
$scope.checkCategory = function() {
var radioButtons = document.getElementsByName('expenseBy');
var userLabels = document.getElementsByClassName('userLabel');
// if this is selected to be a withdrawal, preselect the current user and lock the radio buttons
if ($scope.transaction.category.id == -1) {
for (i = 0; i < userLabels.length; i++) {
if (userLabels[i].innerHTML.substr(-$scope.userinfo.name.length) === $scope.userinfo.name) {
userLabels[i].getElementsByTagName('INPUT')[0].checked = true;
}
}
for (i = 0; i < radioButtons.length; i++) {
radioButtons[i].disabled = true;
}
}
else {
for (i = 0; i < radioButtons.length; i++) {
radioButtons[i].disabled = false;
}
radioButtons[0].checked = true;
}
}
$scope.initList = function() {
console.log('initList()');
var userinfo = $resource('/user').get();
userinfo.$promise.then(function(data) {
$scope.username = userinfo.name;
$scope.userid = userinfo.name;
var accountInfo = $resource('/accounts/search/findByUserName', { username: userinfo.name }).get();
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];