From 1660c7a6355517dcc6eaba95fbf893199dfac6b4 Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Tue, 24 May 2016 08:49:55 +0200 Subject: [PATCH] Set operation edition in form dialog. --- accountant-ui/js/operations.js | 54 ++++++++++- accountant-ui/views/operation.form.tmpl.html | 43 +++++++++ accountant-ui/views/operations.html | 94 ++++++-------------- 3 files changed, 124 insertions(+), 67 deletions(-) create mode 100644 accountant-ui/views/operation.form.tmpl.html 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']"> - {{ operation.operation_date | date:"yyyy-MM-dd" }} - - {{ operation.label }} - - {{ operation.value | currency:"€" }} - @@ -86,64 +71,41 @@ - {{ operation.category }} - -
-
- - +
+ + - - + + - - + + - - - - - - - - -
- + + +