2014-04-16 13:07:14 -07:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
angular.module('copay.setup').controller('SetupController',
|
2014-04-17 07:46:49 -07:00
|
|
|
function($scope, $rootScope, $location, walletFactory, controllerUtils) {
|
2014-04-16 13:07:14 -07: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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
updateRCSelect($scope.totalCopayers);
|
|
|
|
|
|
|
|
$scope.$watch('totalCopayers', function(tc) {
|
|
|
|
updateRCSelect(tc);
|
|
|
|
})
|
|
|
|
|
|
|
|
$scope.create = function(totalCopayers, requiredCopayers) {
|
2014-04-16 15:05:04 -07:00
|
|
|
$scope.loading = true;
|
|
|
|
var opts = {
|
|
|
|
requiredCopayers: requiredCopayers,
|
|
|
|
totalCopayers: totalCopayers
|
|
|
|
};
|
2014-04-16 15:45:22 -07:00
|
|
|
var w = walletFactory.create(opts);
|
2014-04-17 07:46:49 -07:00
|
|
|
controllerUtils.setupUxHandlers(w);
|
2014-04-16 15:05:04 -07:00
|
|
|
w.netStart();
|
2014-04-16 13:07:14 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
});
|