From c4be7c991a0c7b667e6dc97be4d9a166ec411c52 Mon Sep 17 00:00:00 2001 From: Kadir Sekha Date: Thu, 14 Dec 2017 17:56:47 +0900 Subject: [PATCH] shapeshift orderid and back button --- src/js/controllers/amount.js | 19 +++++++++++++++++-- src/js/directives/shapeshiftCoinTrader.js | 3 ++- src/js/routes.js | 2 +- src/js/services/incomingData.js | 1 + www/views/amount.html | 2 +- 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/js/controllers/amount.js b/src/js/controllers/amount.js index d5ac39001..7b19c87d8 100644 --- a/src/js/controllers/amount.js +++ b/src/js/controllers/amount.js @@ -26,9 +26,11 @@ angular.module('copayApp.controllers').controller('amountController', function($ $scope.$on("$ionicView.beforeEnter", function(event, data) { - if (data.stateParams.minShapeshiftAmount.length > 0 && data.stateParams.maxShapeshiftAmount.length > 0) { + if (data.stateParams.shapeshiftOrderId.length > 0) { $scope.minShapeshiftAmount = parseFloat(data.stateParams.minShapeshiftAmount); $scope.maxShapeshiftAmount = parseFloat(data.stateParams.maxShapeshiftAmount); + $scope.shapeshiftOrderId = data.stateParams.shapeshiftOrderId; + console.log($scope.shapeshiftOrderId); } var config = configService.getSync().wallet.settings; @@ -174,6 +176,19 @@ angular.module('copayApp.controllers').controller('amountController', function($ }, 10); }); + $scope.goBack = function() { + if ($scope.shapeshiftOrderId) { + $state.go('tabs.send').then(function() { + $ionicHistory.clearHistory(); + $state.go('tabs.home').then(function() { + $state.transitionTo('tabs.shapeshift'); + }); + }); + } else { + $ionicHistory.goBack(); + } + } + function paste(value) { $scope.amount = value; processAmount(); @@ -304,7 +319,7 @@ angular.module('copayApp.controllers').controller('amountController', function($ function processAmount() { var formatedValue = format($scope.amount); var result = evaluate(formatedValue); - $scope.allowSend = lodash.isNumber(result) && +result > 0 + $scope.allowSend = lodash.isNumber(result) && +result > 0 && ((!$scope.minShapeshiftAmount && !$scope.maxShapeshiftAmount) || ($scope.minShapeshiftAmount && $scope.maxShapeshiftAmount && result >= $scope.minShapeshiftAmount && result <= $scope.maxShapeshiftAmount)); diff --git a/src/js/directives/shapeshiftCoinTrader.js b/src/js/directives/shapeshiftCoinTrader.js index fd5ca55e3..40184ab5a 100644 --- a/src/js/directives/shapeshiftCoinTrader.js +++ b/src/js/directives/shapeshiftCoinTrader.js @@ -100,7 +100,8 @@ angular.module('copayApp.directives').directive('shapeshiftCoinTrader', function var shapeshiftData = { minAmount: $scope.marketData.minimum, - maxAmount: $scope.marketData.maxLimit + maxAmount: $scope.marketData.maxLimit, + orderId: $scope.depositInfo.orderId }; if (incomingData.redir(sendAddress, shapeshiftData)) { diff --git a/src/js/routes.js b/src/js/routes.js index a9ce5e8bc..c39f3b66b 100644 --- a/src/js/routes.js +++ b/src/js/routes.js @@ -287,7 +287,7 @@ angular.module('copayApp').config(function(historicLogProvider, $provide, $logPr */ .state('tabs.send.amount', { - url: '/amount/:recipientType/:toAddress/:toName/:toEmail/:toColor/:coin/:fixedUnit/:minShapeshiftAmount/:maxShapeshiftAmount', + url: '/amount/:recipientType/:toAddress/:toName/:toEmail/:toColor/:coin/:fixedUnit/:minShapeshiftAmount/:maxShapeshiftAmount/:shapeshiftOrderId', views: { 'tab-send@tabs': { controller: 'amountController', diff --git a/src/js/services/incomingData.js b/src/js/services/incomingData.js index 53efba66d..373bffd3b 100644 --- a/src/js/services/incomingData.js +++ b/src/js/services/incomingData.js @@ -65,6 +65,7 @@ angular.module('copayApp.services').factory('incomingData', function($log, $stat if (shapeshiftData) { params['minShapeshiftAmount'] = shapeshiftData.minAmount; params['maxShapeshiftAmount'] = shapeshiftData.maxAmount; + params['shapeshiftOrderId'] = shapeshiftData.orderId; } $state.transitionTo('tabs.send.amount', params); } diff --git a/www/views/amount.html b/www/views/amount.html index 8ff3baad4..d2ecd76f4 100644 --- a/www/views/amount.html +++ b/www/views/amount.html @@ -3,7 +3,7 @@ {{'Enter amount' | translate}} - +