Use angular strap modal instead of angular-ui-bootstrap one.
This commit is contained in:
@ -23,7 +23,8 @@ var angular = require('angular');
|
||||
var ngResource = require('angular-resource'),
|
||||
ngMessages = require('angular-messages'),
|
||||
ngUiBootstrap = require('angular-ui-bootstrap'),
|
||||
ngUiNotification = require('angular-ui-notification');
|
||||
ngUiNotification = require('angular-ui-notification'),
|
||||
ngStrap = require('angular-strap');
|
||||
|
||||
var accountFormTmpl = require('./account.form.tmpl.html'),
|
||||
accountDeleteTmpl = require('./account.delete.tmpl.html');
|
||||
@ -32,7 +33,8 @@ module.exports = angular.module('accountant.accounts', [
|
||||
ngResource,
|
||||
ngMessages,
|
||||
ngUiBootstrap,
|
||||
ngUiNotification
|
||||
ngUiNotification,
|
||||
ngStrap,
|
||||
])
|
||||
|
||||
.config(function($resourceProvider) {
|
||||
@ -67,7 +69,7 @@ module.exports = angular.module('accountant.accounts', [
|
||||
return Account;
|
||||
})
|
||||
|
||||
.controller('AccountController', function(Account, Notification, $uibModal, $log, $q) {
|
||||
.controller('AccountController', function(Account, Notification, $log, $q, $modal) {
|
||||
var vm = this;
|
||||
|
||||
/*
|
||||
@ -138,55 +140,75 @@ module.exports = angular.module('accountant.accounts', [
|
||||
});
|
||||
};
|
||||
|
||||
vm.confirmDelete = function(account) {
|
||||
var title = "Delete account #" + account.id;
|
||||
|
||||
$modal({
|
||||
templateUrl: accountDeleteTmpl,
|
||||
controller: function($scope, title, account, $delete) {
|
||||
$scope.title = title;
|
||||
$scope.account = account;
|
||||
$scope.$delete = function() {
|
||||
$scope.$hide();
|
||||
$delete($scope.account);
|
||||
};
|
||||
},
|
||||
locals: {
|
||||
title: title,
|
||||
account: account,
|
||||
$delete: vm.delete
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
* Delete an account.
|
||||
*/
|
||||
vm.delete = function(account, $index) {
|
||||
vm.delete = function(account) {
|
||||
var id = account.id;
|
||||
|
||||
$uibModal.open({
|
||||
component: 'accountDeleteModalComponent',
|
||||
resolve: {
|
||||
account: function() {
|
||||
return account;
|
||||
}
|
||||
}
|
||||
}).result.then(function(account) {
|
||||
return account.$delete().then(function() {
|
||||
Notification.success('account #' + id + ' deleted.');
|
||||
return account.$delete().then(function() {
|
||||
Notification.success('account #' + id + ' deleted.');
|
||||
|
||||
vm.accounts = Account.query();
|
||||
vm.accounts = Account.query();
|
||||
|
||||
return account;
|
||||
}, function(result) {
|
||||
Notification.error(
|
||||
'An error occurred while trying to delete account #' +
|
||||
id + ':<br />' + result
|
||||
);
|
||||
|
||||
return $q.reject(result);
|
||||
});
|
||||
}, function() {
|
||||
return false;
|
||||
return account;
|
||||
}, function(result) {
|
||||
Notification.error(
|
||||
'An error occurred while trying to delete account #' +
|
||||
id + ':<br />' + result
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
/*
|
||||
* Open the popup to modify the account, save it on confirm.
|
||||
* @returns a promise.
|
||||
*/
|
||||
vm.modify = function(account) {
|
||||
return $uibModal.open({
|
||||
component: 'accountModifyModalComponent',
|
||||
resolve: {
|
||||
account: function() {
|
||||
return account;
|
||||
}
|
||||
// FIXME Alexis Lahouze 2017-06-15 i18n
|
||||
var title = "Account";
|
||||
|
||||
if (account.id) {
|
||||
title = title + " #" + account.id;
|
||||
}
|
||||
|
||||
$modal({
|
||||
templateUrl: accountFormTmpl,
|
||||
controller: function($scope, title, account, $save) {
|
||||
$scope.title = title;
|
||||
$scope.account = account;
|
||||
$scope.account.authorized_overdraft *= -1;
|
||||
$scope.$save = function() {
|
||||
$scope.$hide();
|
||||
$scope.account.authorized_overdraft *= -1;
|
||||
$save($scope.account);
|
||||
};
|
||||
},
|
||||
locals: {
|
||||
title: title,
|
||||
account: account,
|
||||
$save: vm.save
|
||||
}
|
||||
}).result.then(function(account) {
|
||||
return vm.save(account);
|
||||
}, function() {
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
@ -194,83 +216,4 @@ module.exports = angular.module('accountant.accounts', [
|
||||
vm.accounts = Account.query();
|
||||
})
|
||||
|
||||
.component('accountModifyModalComponent', {
|
||||
templateUrl: accountFormTmpl,
|
||||
bindings: {
|
||||
resolve: '<',
|
||||
close: '&',
|
||||
dismiss: '&'
|
||||
},
|
||||
controller: function() {
|
||||
var vm = this;
|
||||
|
||||
vm.$onInit = function() {
|
||||
vm.account = vm.resolve.account;
|
||||
vm.authorized_overdraft = - vm.account.authorized_overdraft;
|
||||
};
|
||||
|
||||
vm.authorizedOverdraftChange = function() {
|
||||
vm.account.authorized_overdraft = - vm.authorized_overdraft;
|
||||
};
|
||||
|
||||
vm.ok = function() {
|
||||
vm.close({
|
||||
$value: vm.account
|
||||
});
|
||||
};
|
||||
|
||||
vm.cancel = function() {
|
||||
vm.dismiss({
|
||||
$value: 'cancel'
|
||||
});
|
||||
};
|
||||
|
||||
vm.title = function() {
|
||||
// FIXME Alexis Lahouze 2017-06-15 i18n
|
||||
if (vm.account.id) {
|
||||
return "Account #" + vm.account.id;
|
||||
} else {
|
||||
return "Account";
|
||||
}
|
||||
};
|
||||
}
|
||||
})
|
||||
|
||||
.component('accountDeleteModalComponent', {
|
||||
templateUrl: accountDeleteTmpl,
|
||||
bindings: {
|
||||
resolve: '<',
|
||||
close: '&',
|
||||
dismiss: '&'
|
||||
},
|
||||
controller: function() {
|
||||
var vm = this;
|
||||
|
||||
vm.$onInit = function() {
|
||||
vm.account = vm.resolve.account;
|
||||
};
|
||||
|
||||
vm.ok = function() {
|
||||
vm.close({
|
||||
$value: vm.account
|
||||
});
|
||||
};
|
||||
|
||||
vm.cancel = function() {
|
||||
vm.dismiss({
|
||||
$value: 'cancel'
|
||||
});
|
||||
};
|
||||
|
||||
vm.title = function() {
|
||||
// FIXME Alexis Lahouze 2017-06-15 i18n
|
||||
if (vm.account.id) {
|
||||
return "Account #" + vm.account.id;
|
||||
} else {
|
||||
return "Account";
|
||||
}
|
||||
};
|
||||
}
|
||||
})
|
||||
|
||||
.name;
|
||||
|
Reference in New Issue
Block a user