set account form in a popup.
This commit is contained in:
1 parent
ffc5ede6ca
commit
68c6884fad
4 files changed
+101
-48
No files matched your search
@@ -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
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
Reference in new issue
Block a user