diff --git a/accountant-ui/js/operations.js b/accountant-ui/js/operations.js index 72b2f4b..5e2722d 100644 --- a/accountant-ui/js/operations.js +++ b/accountant-ui/js/operations.js @@ -463,4 +463,56 @@ angular.module('accountant.operations', [ $rootScope.$on('rangeSelectedEvent', function(e, args) { $scope.load(args.begin, args.end); }); -}]); +}]) + +.directive( + 'operationFormDialog', function($ngBootbox) { + return { + restrict: 'A', + scope: { + operation: '=ngModel' + }, + link: function(scope, element) { + var title = 'Operation'; + + if(scope.operation && scope.operation.id) { + title = title + ' #' + scope.operation.id; + } + + scope.form = {}; + + element.on('click', function() { + //angular.copy(scope.operation, scope.form); + + // Open dialog with form. + $ngBootbox.customDialog({ + scope: scope, + title: title, + templateUrl: 'views/operation.form.tmpl.html', + onEscape: true, + buttons: { + save: { + label: 'Save', + className: 'btn-success', + callback: function() { + // Validate form + console.log(scope.form); + + // Save operation + console.log(scope.operation); + + // TODO Alexis Lahouze 2016-05-24 Save operation, handle return. + return false; + } + }, + cancel: { + label: 'Cancel', + className: 'btn-default', + callback: true + } + } + }); + }); + } + }; +}); diff --git a/accountant-ui/views/operation.form.tmpl.html b/accountant-ui/views/operation.form.tmpl.html new file mode 100644 index 0000000..289362e --- /dev/null +++ b/accountant-ui/views/operation.form.tmpl.html @@ -0,0 +1,43 @@ + +
+ diff --git a/accountant-ui/views/operations.html b/accountant-ui/views/operations.html index fdf1fdd..a7b8c08 100644 --- a/accountant-ui/views/operations.html +++ b/accountant-ui/views/operations.html @@ -55,30 +55,15 @@ ng-class="{stroke: operation.canceled, italic: !operation.confirmed, warning: operation.sold < 0, danger: operation.sold < account.authorized_overdraft}" ng-repeat="operation in operations | orderBy:['-operation_date', '-value', 'label']">