Skip to content
This repository has been archived by the owner on Sep 2, 2023. It is now read-only.

[FIX] Advanced Trade: remove one step (RT-3271) #2472

Merged
merged 2 commits into from
May 6, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions src/js/tabs/trade.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ TradeTab.prototype.angular = function(module)
popup, $anchorScroll, $timeout, $templateRequest)
{
var timer;
var cancelNotifTimeout = {};

$scope.priceTicker = {
bid: 'n/a',
Expand Down Expand Up @@ -108,6 +109,8 @@ TradeTab.prototype.angular = function(module)
sell_amount: null
};

$scope.notif = {};

var currencyPairChangedByNonUser = false;

//$scope.not_valid_pair = true;
Expand Down Expand Up @@ -581,6 +584,25 @@ TradeTab.prototype.angular = function(module)
$scope.editOrder.cancelOrderGone = false;
};

$scope.showNotification = function(type, status) {
if (typeof status !== 'string') {
console.log("You must pass in a string for the status");
return;
}

$scope.notif[type] = status;

if (cancelNotifTimeout[type]) {
$timeout.cancel(cancelNotifTimeout[type]);
cancelNotifTimeout[type] = null;
}
cancelNotifTimeout[type] = $timeout(function() {
$scope.notif[type] = 'clear';
}, 9000);
cancelNotifTimeout[type]['finally'](function() { cancelNotifTimeout[type] = null; });
}


/**
* Happens when user clicks 'Confirm' in order confirmation view.
*
Expand Down Expand Up @@ -612,7 +634,7 @@ TradeTab.prototype.angular = function(module)
tx.on('success', function(res) {
setEngineStatus(res, true, type);

if (!modifying) order.mode = 'done';
if (!modifying) $scope.reset_widget(type);

var tx = rewriter.processTxn(res, res.metadata, id.account);

Expand Down Expand Up @@ -642,9 +664,9 @@ TradeTab.prototype.angular = function(module)
}

var eventProp = {
'Status': 'success',
Status: 'success',
'Currency pair': ccyPair,
'Address': $scope.userBlob.data.account_id,
Address: $scope.userBlob.data.account_id,
'Transaction ID': res.tx_json.hash,
BuyAmount: order.buy_amount.to_number(false),
SellAmount: order.sell_amount.to_number(false)
Expand All @@ -657,7 +679,7 @@ TradeTab.prototype.angular = function(module)
tx.on('error', function (err) {
setEngineStatus(err, false, type);

if (!modifying) order.mode = 'done';
if (!modifying) $scope.reset_widget(type);;

if (errorCb) errorCb();

Expand All @@ -666,10 +688,10 @@ TradeTab.prototype.angular = function(module)
}

var eventProp = {
'Status': 'error',
'Message': err.engine_result,
Status: 'error',
Message: err.engine_result,
'Currency pair': ccyPair,
'Address': $scope.userBlob.data.account_id
Address: $scope.userBlob.data.account_id
};

if (modifying) rpTracker.track(MIXPNL_MODIFY_EVENT, eventProp);
Expand Down Expand Up @@ -777,6 +799,7 @@ TradeTab.prototype.angular = function(module)
$scope.tx_result = 'unknown';
console.warn('Unhandled engine status encountered!');
}
$scope.showNotification(type, $scope.tx_result);
}

$scope.update_first = function (type) {
Expand Down
42 changes: 17 additions & 25 deletions src/templates/tabs/trade.jade
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,23 @@ section.col-xs-12.content(ng-controller="TradeCtrl")
div(ng-hide="order[type].showWidget")
p.literal(l10n) You do not have sufficient funds to create an order.

group.pending(ng-show='notif[type]=="pending"')
h2.tx-status(l10n) Your order has been submitted.
group.result-success(ng-show="notif[type]=='cleared' && executedOnOfferCreate=='none'")
h2.tx-status(l10n) Your order is now active.
group.result-success(ng-show="notif[type]=='cleared' && executedOnOfferCreate=='all'")
h2.tx-status(l10n) Your order has been filled.
group.result-success(ng-show="notif[type]=='cleared' && executedOnOfferCreate=='partial'")
h2.tx-status(l10n) Your order has been partially filled. The remaining amount is now active.

//- 4a. Ripple error page
group.mode-ripplerror(ng-show='notif[type]=="unknown"')
rp-transaction-status(
rp-engine-result="{{engine_result}}"
rp-engine-result-message="{{engine_result_message}}"
rp-accepted="{{engine_status_accepted}}"
rp-current-tab="trade")

//- 2. Confirmation
form.mode-confirm(ng-switch-when='confirm', ng-submit="order_confirmed(type, order.currency_pair)")
div.alert.alert-warning(ng-show="fatFingerErr")
Expand Down Expand Up @@ -371,31 +388,6 @@ section.col-xs-12.content(ng-controller="TradeCtrl")
img(src="img/button-s.png", class="loader")
span(class="loading_text", l10n) Sending order to Ripple network...

//- 4. Done

group.mode-done(ng-switch-when='done')
group.pending(ng-show='tx_result=="pending"')
h2.tx-status(l10n) Your order has been submitted.
group.result-success(ng-show="tx_result=='cleared' && executedOnOfferCreate=='none'")
h2.tx-status(l10n) Your order is now active.
group.result-success(ng-show="tx_result=='cleared' && executedOnOfferCreate=='all'")
h2.tx-status(l10n) Your order has been filled.
group.result-success(ng-show="tx_result=='cleared' && executedOnOfferCreate=='partial'")
h2.tx-status(l10n) Your order has been partially filled. The remaining amount is now active.

//- 4a. Ripple error page

group.mode-ripplerror(ng-show='tx_result=="unknown"')
rp-transaction-status(
rp-engine-result="{{engine_result}}"
rp-engine-result-message="{{engine_result_message}}"
rp-accepted="{{engine_status_accepted}}"
rp-current-tab="trade")

hr
.actionLink
a(href="#trade", ng-click="reset_widget(type)", l10n) Submit another order

.my-orders-title(l10n) My Orders
span  ({{offersCount}})
small.toggle(ng-hide="isEmpty(offers)", ng-click="hideOffers = !hideOffers") {{hideOffers ? "show" : "hide"}}
Expand Down