diff --git a/src/main/resources/static/js/controllers.js b/src/main/resources/static/js/controllers.js index 86e6fa4..ee48014 100644 --- a/src/main/resources/static/js/controllers.js +++ b/src/main/resources/static/js/controllers.js @@ -1,6 +1,6 @@ var transactionControllers = angular.module('transactionControllers', ['ngResource']); -transactionControllers.controller('TransactionListCtrl', [ '$http', '$scope', '$location', '$resource', '$q', function($http, $scope, $location, $resource, $q) { +transactionControllers.controller('TransactionListCtrl', [ '$http', '$scope', '$location', '$resource', '$q', '$uibModal', '$log', function($http, $scope, $location, $resource, $q, $uibModal, $log) { $scope.refreshList = function() { @@ -227,13 +227,52 @@ transactionControllers.controller('TransactionListCtrl', [ '$http', '$scope', '$ } return newSuggestions; }); - }; + }; + + $scope.items = ['item1', 'item2', 'item3']; + + $scope.openDetails = function() { + var modalInstance = $uibModal.open({ + templateUrl: 'detailsTemplate.html', + controller: 'DetailsModalCtrl', + resolve: { + items: function () { + return $scope.items; + } + } + }); + + modalInstance.result.then(function (selectedItem) { + $scope.selected = selectedItem; + }, function () { + $log.info('Modal dismissed at: ' + new Date()); + }); + }; // initialize (http://stackoverflow.com/a/25662066/3761783) $scope.initList(); } ]); +transactionControllers.controller('DetailsModalCtrl', [ '$scope', '$uibModalInstance', 'items', function($scope, $uibModalInstance, items) { + + $scope.items = items; + $scope.selected = { + item: $scope.items[0] + }; + + $scope.ok = function () { + $uibModalInstance.close($scope.selected.item); + }; + + $scope.cancel = function () { + $uibModalInstance.dismiss('cancel'); + }; +} ]); + + + + transactionControllers.controller('TransactionDetailCtrl', [ '$scope', '$routeParams', '$resource', '$location', function($scope, $routeParams, $resource, $location) { $scope.initDetails = function() { @@ -286,8 +325,6 @@ transactionControllers.controller('TransactionDetailCtrl', [ '$scope', '$routePa } $scope.deleteTransaction = function(transaction) { - /*console.log(angular.toJson(transaction, false));*/ - // TODO auf return code reagieren $resource(transaction._links.self.href).remove().$promise.then(function() { $location.path('/'); @@ -297,56 +334,3 @@ transactionControllers.controller('TransactionDetailCtrl', [ '$scope', '$routePa $scope.initDetails(); } ]); - - - - -transactionControllers.controller('ModalDemoCtrl', function ($scope, $uibModal, $log) { - - $scope.items = ['item1', 'item2', 'item3']; - $scope.animationsEnabled = true; - - $scope.open = function (size) { - var modalInstance = $uibModal.open({ - animation: $scope.animationsEnabled, - templateUrl: 'myModalContent.html', - controller: 'ModalInstanceCtrl', - size: size, - resolve: { - items: function () { - return $scope.items; - } - } - }); - - modalInstance.result.then(function (selectedItem) { - $scope.selected = selectedItem; - }, function () { - $log.info('Modal dismissed at: ' + new Date()); - }); - }; - - $scope.toggleAnimation = function () { - $scope.animationsEnabled = !$scope.animationsEnabled; - }; - -}); - -// Please note that $uibModalInstance represents a modal window (instance) dependency. -// It is not the same as the $uibModal service used above. - -transactionControllers.controller('ModalInstanceCtrl', function ($scope, $uibModalInstance, items) { - - $scope.items = items; - $scope.selected = { - item: $scope.items[0] - }; - - $scope.ok = function () { - $uibModalInstance.close($scope.selected.item); - }; - - $scope.cancel = function () { - $uibModalInstance.dismiss('cancel'); - }; -}); diff --git a/src/main/resources/static/partials/transaction-list.html b/src/main/resources/static/partials/transaction-list.html index e5c4362..413838e 100644 --- a/src/main/resources/static/partials/transaction-list.html +++ b/src/main/resources/static/partials/transaction-list.html @@ -102,10 +102,15 @@