set account form in a popup.

This commit is contained in:
Alexis Lahouze committed 2016-05-22 21:47:33 +02:00
1 parent ffc5ede6ca
commit 68c6884fad
4 files changed
+101 -48

No files matched your search

+53 -1
View File
@@ -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
}
}
});
});
}
};
});