Skip to content
This repository has been archived by the owner on Oct 8, 2019. It is now read-only.

Commit

Permalink
Merge pull request #1220 from jstettner/coinify-limits
Browse files Browse the repository at this point in the history
Coinify limits
  • Loading branch information
plondon authored Jul 29, 2017
2 parents 608e8a4 + 307c523 commit 873db93
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 11 deletions.
6 changes: 3 additions & 3 deletions app/templates/buy-quick-start.pug
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
ul.uib-dropdown-menu.dropdown-menu.currency-dropdown(role="menu")
li(ng-repeat="currency in currencies"
role="menuitem"
ng-click="changeCurrency({currency: currency}); transaction.fiat && getQuote();"
ng-click="handleCurrencyClick({currency: currency}); transaction.fiat && getQuote();"
ng-class="{active: isCurrencySelected(currency)}")
a(ng-click="$event.preventDefault()") {{ currency.code }}
i.ti-arrows-horizontal.mhm.type-h4.hidden-sm.hidden-xs
Expand All @@ -54,8 +54,8 @@
button.btn.btn-default.brdrn
span.btc BTC
.mts.pos-rel(ng-hide="tradingDisabled")
span.pos-abs.type-sm.state-danger-text(ng-show="fiatForm.fiat.$error.min" translate="BUY_AMT_LOW")
span.pos-abs.type-sm.state-danger-text(ng-show="fiatForm.fiat.$error.max" translate="BUY_AMT_HIGH")
span.pos-abs.type-sm.state-danger-text(ng-click="setFiat(limits.absoluteMin(transaction.currency.code)); updateLastInput('fiat'); transaction.fiat && getQuote();" ng-show="fiatForm.fiat.$error.min" translate="BUY_AMT_LOW" translate-values="{limit: limits.absoluteMin(transaction.currency.code), symbol: symbol}")
span.pos-abs.type-sm.state-danger-text(ng-click="setFiat(limits.absoluteMax(transaction.currency.code)); updateLastInput('fiat'); transaction.fiat && getQuote();" ng-show="fiatForm.fiat.$error.max" translate="BUY_AMT_HIGH" translate-values="{limit: limits.absoluteMax(transaction.currency.code), symbol: symbol}")
.mts.pos-rel(ng-show="serviceSuspended && serviceSuspendedReason === 'service_temporarily_unavailable'")
span.pos-abs.type-sm
span.state-danger-text(translate="TRADING_SERVICE_IS_DISABLED")
Expand Down
8 changes: 4 additions & 4 deletions app/templates/sell-quick-start.pug
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
ng-click="handleCurrencyClick({currency: currency}); getQuote();"
ng-class="{active: isCurrencySelected(currency)}")
a(ng-click="$event.preventDefault()") {{ currency.code }}
.mts.pos-rel.mb-10.mtm.pbl(ng-show="!$ctrl.serviceSuspended && showZeroBalance && !isPendingSellTrade()")
.mts.pos-rel.mb-10(ng-show="!$ctrl.serviceSuspended && showZeroBalance && !isPendingSellTrade()")
| 😢
|
span.type-sm(translate="SELL.ZERO_BALANCE")
Expand All @@ -65,9 +65,9 @@
span or
|  
a(ng-click="$ctrl.selectTab({tab:'BUY_BITCOIN'})") Buy.
.pos-rel.mt-10(ng-hide="tradingDisabled")
span.pos-abs.type-sm.state-danger-text(ng-show="fiatForm.fiat.$error.min" translate="SELL_AMT_LOW" translate-values="{limit: limits.bank.min[$ctrl.transaction.currency.code], symbol: $ctrl.sellCurrencySymbol.symbol}")
span.pos-abs.type-sm.state-danger-text(ng-show="fiatForm.fiat.$error.max" translate="SELL_AMT_HIGH" translate-values="{limit: limits.bank.maxOutRemaining[$ctrl.transaction.currency.code], symbol: $ctrl.sellCurrencySymbol.symbol}")
.mts.pos-rel(ng-hide="tradingDisabled || $ctrl.error.moreThanInWallet")
span.pos-abs.type-sm.state-danger-text(ng-click="setFiat(limits.bank.min[$ctrl.transaction.currency.code]); updateLastInput('fiat'); $ctrl.transaction.fiat && getQuote();" ng-show="fiatForm.fiat.$error.min" translate="SELL_AMT_LOW" translate-values="{limit: limits.bank.min[$ctrl.transaction.currency.code], symbol: $ctrl.sellCurrencySymbol.symbol}")
span.pos-abs.type-sm.state-danger-text(ng-click="setFiat(limits.bank.maxOutRemaining[$ctrl.transaction.currency.code]); updateLastInput('fiat'); $ctrl.transaction.fiat && getQuote();" ng-show="fiatForm.fiat.$error.max" translate="SELL_AMT_HIGH" translate-values="{limit: limits.bank.maxOutRemaining[$ctrl.transaction.currency.code], symbol: $ctrl.sellCurrencySymbol.symbol}")
.mts.pos-rel(ng-show="$ctrl.serviceSuspended && $ctrl.serviceSuspendedReason === 'service_temporarily_unavailable'")
span.pos-abs.type-sm
span.state-danger-text(translate="TRADING_SERVICE_IS_DISABLED")
Expand Down
4 changes: 4 additions & 0 deletions assets/js/components/sell-quick-start.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ function sellQuickStartController ($scope, $rootScope, currency, buySell, Alerts
}
};

$scope.setFiat = (amount) => {
this.transaction.fiat = amount;
};

const success = (quote) => {
$scope.quote = quote;
$scope.getMinLimits(quote);
Expand Down
14 changes: 14 additions & 0 deletions assets/js/directives/buy-quick-start.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ function buyQuickStart ($rootScope, currency, buySell, Alerts, $interval, $timeo
scope.currencies = currency.coinifyCurrencies;
scope.format = currency.formatCurrencyForView;
scope.inMobileBuy = $rootScope.inMobileBuy;
scope.symbol = currency.conversions[scope.transaction.currency.code].symbol;

scope.updateLastInput = (type) => scope.lastInput = type;
scope.isPendingTradeState = (state) => scope.pendingTrade && scope.pendingTrade.state === state && scope.pendingTrade.medium !== 'blockchain';
Expand Down Expand Up @@ -61,6 +62,15 @@ function buyQuickStart ($rootScope, currency, buySell, Alerts, $interval, $timeo

scope.isCurrencySelected = (currency) => currency === scope.transaction.currency;

scope.handleCurrencyClick = (curr) => {
scope.changeCurrency(curr);
scope.refreshSymbol();
};

scope.refreshSymbol = () => {
scope.symbol = currency.conversions[scope.transaction.currency.code].symbol;
};

scope.getQuote = () => {
scope.status.busy = true;

Expand Down Expand Up @@ -103,6 +113,10 @@ function buyQuickStart ($rootScope, currency, buySell, Alerts, $interval, $timeo
.finally(() => scope.disabled = false);
};

scope.setFiat = (amount) => {
scope.transaction.fiat = amount;
};

scope.getMinLimits = (quote) => {
$q.resolve(buySell.getMinLimits(quote))
.then(scope.limits = buySell.limits);
Expand Down
6 changes: 3 additions & 3 deletions locales/en-human.json
Original file line number Diff line number Diff line change
Expand Up @@ -1109,10 +1109,10 @@
"MAX_LIMIT_EXCEEDED": "To pay via {{::medium}}, please decrease your amount below {{::max}} {{::code}}.",
"BELOW_MIN_LIMIT": "To pay via {{::medium }}, please increase your amount to {{::min}} {{::code}} or more.",
"MAX_MIN_HELPER": "Minimum buy amount is {{::min}} {{::code}}. Maximum buy amount is {{::max}} {{::code}}.",
"BUY_AMT_LOW": "Buy amount too low.",
"BUY_AMT_HIGH": "Buy amount too high.",
"BUY_AMT_LOW": "Minimum buy amount is {{::symbol}}{{::limit}}",
"BUY_AMT_HIGH": "Maximum buy amount is {{::symbol}}{{::limit}}",
"BUY_AMT_IS": "Your limit is set to {{::amount}} {{::code}}.",
"SELL_AMT_LOW": "Minimum sell amount is {{::symbol}}{{::limit}}.",
"SELL_AMT_LOW": "Minimum sell amount is {{::symbol}}{{::limit}}",
"SELL_AMT_HIGH": "Maximum sell amount is {{::symbol}}{{::limit}}",
"WHY": "Why?",
"UPDATE": "Update",
Expand Down
4 changes: 3 additions & 1 deletion tests/directives/buy-quick-start_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ describe('buyQuickStart', () => {
let buySell;

beforeEach(module('walletDirectives'));

beforeEach(module('walletApp'));

beforeEach(inject(function ($compile, $rootScope, $injector, _$q_, $httpBackend) {
Expand Down Expand Up @@ -63,6 +63,8 @@ describe('buyQuickStart', () => {
})
;

currency.conversions.USD = { conversion: 1000, symbol: '$' };

buySell.getMinLimits = () => $q.resolve(limits);
buySell.cancelTrade = () => $q.resolve(trade);
buySell.getQuote = () => $q.resolve(quote);
Expand Down

0 comments on commit 873db93

Please sign in to comment.