From 68c6884fad8aab2b875b095b28e80cb6f2e9683e Mon Sep 17 00:00:00 2001 From: Alexis Lahouze Date: Sun, 22 May 2016 21:47:33 +0200 Subject: [PATCH] set account form in a popup. --- accountant-ui/js/accounts.js | 54 +++++++++++++++- accountant-ui/views/account.form.tmpl.html | 22 +++++++ accountant-ui/views/accounts.html | 72 ++++++++-------------- accountant-ui/views/login.tmpl.html | 1 + 4 files changed, 101 insertions(+), 48 deletions(-) create mode 100644 accountant-ui/views/account.form.tmpl.html diff --git a/accountant-ui/js/accounts.js b/accountant-ui/js/accounts.js index 515211d..3a622a8 100644 --- a/accountant-ui/js/accounts.js +++ b/accountant-ui/js/accounts.js @@ -156,4 +156,56 @@ angular.module('accountant.accounts', [ // Load accounts. $scope.accounts = Account.query(); -}]); + +}]) + +.directive( + 'accountFormDialog', function($ngBootbox) { + return { + restrict: 'A', + scope: { + account: '=ngModel' + }, + link: function(scope, element) { + var title = 'Account'; + + if(scope.account && scope.account.id) { + title = title + ' #' + scope.account.id; + } + + scope.form = {}; + + element.on('click', function() { + //angular.copy(scope.account, scope.form); + + // Open dialog with form. + $ngBootbox.customDialog({ + scope: scope, + title: title, + templateUrl: 'views/account.form.tmpl.html', + onEscape: true, + buttons: { + save: { + label: 'Save', + className: 'btn-success', + callback: function() { + // Validate form + console.log(scope.form); + + // Save account + console.log(scope.account); + + return false; + } + }, + cancel: { + label: 'Cancel', + className: 'btn-default', + callback: true + } + } + }); + }); + } + }; +}); diff --git a/accountant-ui/views/account.form.tmpl.html b/accountant-ui/views/account.form.tmpl.html new file mode 100644 index 0000000..7883047 --- /dev/null +++ b/accountant-ui/views/account.form.tmpl.html @@ -0,0 +1,22 @@ + +
+
+ +
+ + +
+
+ +
+ +
+ + +
+
+
diff --git a/accountant-ui/views/accounts.html b/accountant-ui/views/accounts.html index 9920458..6d25b74 100644 --- a/accountant-ui/views/accounts.html +++ b/accountant-ui/views/accounts.html @@ -39,12 +39,7 @@ class="form-inline" ng-class="rowClass(account)" ng-repeat="account in accounts | orderBy:'name'" ng-init="account.getSolds()"> - - {{ account.name }} - + {{ account.name }} @@ -60,53 +55,36 @@ - - {{ account.authorized_overdraft | currency : "€" }} - + {{ account.authorized_overdraft | currency : "€" }} -
-
- - +
+ + - - + + - - + + - - - - - - - -
- + + + + +
diff --git a/accountant-ui/views/login.tmpl.html b/accountant-ui/views/login.tmpl.html index a381d06..bab0153 100644 --- a/accountant-ui/views/login.tmpl.html +++ b/accountant-ui/views/login.tmpl.html @@ -7,6 +7,7 @@ placeholder="Nom d'utilisateur"> +