From 55163a01b366b5e022865b79dfa836adb00c2a9a Mon Sep 17 00:00:00 2001 From: Tilman Liero Date: Thu, 7 Jul 2016 17:31:20 +0200 Subject: [PATCH] Edit form, pt. 2 --- src/main/resources/static/css/app.css | 8 ++ src/main/resources/static/js/controllers.js | 28 ++++--- .../static/partials/transaction-list.html | 73 ++++++++++++++++--- 3 files changed, 88 insertions(+), 21 deletions(-) diff --git a/src/main/resources/static/css/app.css b/src/main/resources/static/css/app.css index afd487e..12d7dff 100644 --- a/src/main/resources/static/css/app.css +++ b/src/main/resources/static/css/app.css @@ -10,6 +10,14 @@ label { color: #eee; } +.modal-body label { + color: #aaa; +} + +.userLabel { + color: white; +} + .row-margin { padding: 5 ex; margin: 20 px; diff --git a/src/main/resources/static/js/controllers.js b/src/main/resources/static/js/controllers.js index eabfb87..c7e0cc3 100644 --- a/src/main/resources/static/js/controllers.js +++ b/src/main/resources/static/js/controllers.js @@ -4,8 +4,6 @@ transactionControllers.controller('TransactionListCtrl', [ '$http', '$scope', '$ $scope.refreshList = function() { - console.log('refreshList()'); - // reset form if ($scope.form) { $scope.form.$setPristine(); @@ -108,8 +106,6 @@ transactionControllers.controller('TransactionListCtrl', [ '$http', '$scope', '$ } $scope.initList = function() { - console.log('initList()'); - $scope.pageSize = 20; var userinfo = $resource('/user').get(); @@ -230,7 +226,10 @@ transactionControllers.controller('TransactionListCtrl', [ '$http', '$scope', '$ templateUrl: 'detailsTemplate.html', controller: 'DetailsModalCtrl', resolve: { - transaction: transaction + transaction: transaction, + categories: function () { + return $scope.categories; + } } }); @@ -246,12 +245,23 @@ transactionControllers.controller('TransactionListCtrl', [ '$http', '$scope', '$ } ]); -transactionControllers.controller('DetailsModalCtrl', [ '$scope', '$uibModalInstance', 'transaction', function($scope, $uibModalInstance, transaction) { - +transactionControllers.controller('DetailsModalCtrl', [ '$scope', '$uibModalInstance', 'transaction', 'categories', function($scope, $uibModalInstance, transaction, categories) { + + transaction.date = new Date(transaction.date); + $scope.transaction = transaction; - + $scope.categories = categories; + + for (i = 0; i < $scope.categories.length; i++) { + if ($scope.categories[i].name == $scope.transaction.category.name) { + $scope.transaction.category = $scope.categories[i]; + break; + } + } + $scope.ok = function () { - $uibModalInstance.close($scope.selected.item); + console.log($scope.transaction); + $uibModalInstance.close($scope.transaction); }; $scope.cancel = function () { diff --git a/src/main/resources/static/partials/transaction-list.html b/src/main/resources/static/partials/transaction-list.html index 5ae5115..68e3398 100644 --- a/src/main/resources/static/partials/transaction-list.html +++ b/src/main/resources/static/partials/transaction-list.html @@ -22,7 +22,8 @@
-