sendflow service integrated into flow

This commit is contained in:
Sebastiaan Pasma 2018-08-08 17:27:15 +02:00
commit 2206102715
No known key found for this signature in database
GPG key ID: 9A2B0C8B95A1D26F
2 changed files with 20 additions and 2 deletions

View file

@ -191,6 +191,7 @@ angular.module('copayApp.controllers').controller('walletSelectorController', fu
};
$scope.goBack = function() {
sendFlowService.previousState();
$ionicHistory.goBack();
}

View file

@ -4,13 +4,15 @@ angular.module('copayApp.services').factory('sendFlowService', function ($log) {
var vm = this;
vm.amount = false;
vm.fromWalletId = false;
vm.previousStates = [];
vm.thirdParty = false;
vm.sendMax = false;
vm.toAddress = false;
vm.toWalletId = false;
vm.initialize = function() {
vm.clear = function() {
$log.debug("Reinitialize Send Flow variables");
vm.amount = false;
vm.fromWalletId = false;
@ -18,13 +20,28 @@ angular.module('copayApp.services').factory('sendFlowService', function ($log) {
vm.sendMax = false;
vm.toAddress = false;
vm.toWalletId = false;
vm.previousStates = [];
};
vm.map = function(params) {
var tempState = {};
Object.keys(vm).map(function(key, index) {
if (typeof vm[key] !== 'function' && key !== 'previousStates') {
tempState[key] = vm[key];
}
});
vm.previousStates.push(tempState);
Object.keys(params).map(function(key, index) {
vm[key] = params[key];
});
console.log(vm);
};
vm.previousState = function() {
if (vm.previousStates.length) {
vm.map(vm.previousStates.pop());
}
};
return vm;