2014-04-16 17:07:14 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
angular.module('copay.setup').controller('SetupController',
|
2014-04-17 11:46:49 -03:00
|
|
|
function($scope, $rootScope, $location, walletFactory, controllerUtils) {
|
2014-04-16 17:07:14 -03:00
|
|
|
|
|
|
|
|
$scope.loading = false;
|
|
|
|
|
|
|
|
|
|
$scope.totalCopayers = config.wallet.totalCopayers;
|
|
|
|
|
$scope.TCValues = [];
|
|
|
|
|
for (var n = 1; n <= config.limits.totalCopayers; n++)
|
|
|
|
|
$scope.TCValues.push(n);
|
|
|
|
|
|
|
|
|
|
var updateRCSelect = function(n) {
|
|
|
|
|
$scope.requiredCopayers = parseInt(Math.min(n / 2 + 1, config.limits.mPlusN-n));
|
|
|
|
|
$scope.RCValues = [];
|
|
|
|
|
for (var m = 1; m <= n; m++) {
|
|
|
|
|
if (n + m <= config.limits.mPlusN) {
|
|
|
|
|
$scope.RCValues.push(m);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2014-04-18 15:22:02 -03:00
|
|
|
|
2014-04-16 17:07:14 -03:00
|
|
|
updateRCSelect($scope.totalCopayers);
|
|
|
|
|
|
|
|
|
|
$scope.$watch('totalCopayers', function(tc) {
|
|
|
|
|
updateRCSelect(tc);
|
2014-04-18 19:08:01 -03:00
|
|
|
});
|
2014-04-16 17:07:14 -03:00
|
|
|
|
2014-04-24 16:35:52 -03:00
|
|
|
$scope.create = function(totalCopayers, requiredCopayers, walletName) {
|
2014-04-16 19:05:04 -03:00
|
|
|
$scope.loading = true;
|
|
|
|
|
var opts = {
|
|
|
|
|
requiredCopayers: requiredCopayers,
|
2014-04-24 16:35:52 -03:00
|
|
|
totalCopayers: totalCopayers,
|
|
|
|
|
name: walletName,
|
2014-04-16 19:05:04 -03:00
|
|
|
};
|
2014-04-16 19:45:22 -03:00
|
|
|
var w = walletFactory.create(opts);
|
2014-04-17 11:46:49 -03:00
|
|
|
controllerUtils.setupUxHandlers(w);
|
2014-04-16 17:07:14 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
});
|