paypro: implement short merchant names in address box and side box.
This commit is contained in:
parent
20a30609b8
commit
953ff985d8
3 changed files with 35 additions and 5 deletions
|
|
@ -461,6 +461,13 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
var value = scope.address || '';
|
var value = scope.address || '';
|
||||||
var uri;
|
var uri;
|
||||||
|
|
||||||
|
// If we're setting the domain, ignore the change.
|
||||||
|
if ($rootScope.merchant
|
||||||
|
&& $rootScope.merchant.domain
|
||||||
|
&& value === $rootScope.merchant.domain) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (value.indexOf('bitcoin:') === 0) {
|
if (value.indexOf('bitcoin:') === 0) {
|
||||||
uri = new bitcore.BIP21(value).data;
|
uri = new bitcore.BIP21(value).data;
|
||||||
} else if (/^https?:\/\//.test(value)) {
|
} else if (/^https?:\/\//.test(value)) {
|
||||||
|
|
@ -517,12 +524,18 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var url = merchantData.request_url;
|
||||||
|
var domain = /^(?:https?)?:\/\/([^\/:]+).*$/.exec(url)[1];
|
||||||
|
|
||||||
merchantData.unitTotal = (+merchantData.total / config.unitToSatoshi) + '';
|
merchantData.unitTotal = (+merchantData.total / config.unitToSatoshi) + '';
|
||||||
merchantData.expiration = new Date(
|
merchantData.expiration = new Date(
|
||||||
merchantData.pr.pd.expires * 1000).toISOString();
|
merchantData.pr.pd.expires * 1000).toISOString();
|
||||||
|
merchantData.domain = domain;
|
||||||
|
|
||||||
$rootScope.merchant = merchantData;
|
$rootScope.merchant = merchantData;
|
||||||
|
|
||||||
|
scope.sendForm.address.$setViewValue(domain);
|
||||||
|
scope.sendForm.address.$render();
|
||||||
scope.sendForm.address.$isValid = true;
|
scope.sendForm.address.$isValid = true;
|
||||||
|
|
||||||
scope.sendForm.amount.$setViewValue(merchantData.unitTotal);
|
scope.sendForm.amount.$setViewValue(merchantData.unitTotal);
|
||||||
|
|
@ -534,6 +547,14 @@ angular.module('copayApp.controllers').controller('SendController',
|
||||||
var unregister = scope.$watch('address', function() {
|
var unregister = scope.$watch('address', function() {
|
||||||
var val = scope.sendForm.address.$viewValue || '';
|
var val = scope.sendForm.address.$viewValue || '';
|
||||||
var uri;
|
var uri;
|
||||||
|
// If we're setting the domain, ignore the change.
|
||||||
|
if ($rootScope.merchant
|
||||||
|
&& $rootScope.merchant.domain
|
||||||
|
&& val === $rootScope.merchant.domain) {
|
||||||
|
uri = {
|
||||||
|
merchant: $rootScope.merchant.request_url
|
||||||
|
};
|
||||||
|
}
|
||||||
if (val.indexOf('bitcoin:') === 0) {
|
if (val.indexOf('bitcoin:') === 0) {
|
||||||
uri = new bitcore.BIP21(val).data;
|
uri = new bitcore.BIP21(val).data;
|
||||||
} else if (/^https?:\/\//.test(val)) {
|
} else if (/^https?:\/\//.test(val)) {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
angular.module('copayApp.directives')
|
angular.module('copayApp.directives')
|
||||||
.directive('validAddress', function() {
|
.directive('validAddress', ['$rootScope', function($rootScope) {
|
||||||
var bitcore = require('bitcore');
|
var bitcore = require('bitcore');
|
||||||
var Address = bitcore.Address;
|
var Address = bitcore.Address;
|
||||||
var bignum = bitcore.Bignum;
|
var bignum = bitcore.Bignum;
|
||||||
|
|
@ -11,6 +11,14 @@ angular.module('copayApp.directives')
|
||||||
link: function(scope, elem, attrs, ctrl) {
|
link: function(scope, elem, attrs, ctrl) {
|
||||||
var validator = function(value) {
|
var validator = function(value) {
|
||||||
|
|
||||||
|
// If we're setting the domain, ignore the change.
|
||||||
|
if ($rootScope.merchant
|
||||||
|
&& $rootScope.merchant.domain
|
||||||
|
&& value === $rootScope.merchant.domain) {
|
||||||
|
ctrl.$setValidity('validAddress', true);
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
// Regular url
|
// Regular url
|
||||||
if (/^https?:\/\//.test(value)) {
|
if (/^https?:\/\//.test(value)) {
|
||||||
ctrl.$setValidity('validAddress', true);
|
ctrl.$setValidity('validAddress', true);
|
||||||
|
|
@ -35,7 +43,7 @@ angular.module('copayApp.directives')
|
||||||
ctrl.$formatters.unshift(validator);
|
ctrl.$formatters.unshift(validator);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})
|
}])
|
||||||
.directive('enoughAmount', ['$rootScope',
|
.directive('enoughAmount', ['$rootScope',
|
||||||
function($rootScope) {
|
function($rootScope) {
|
||||||
var bitcore = require('bitcore');
|
var bitcore = require('bitcore');
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@
|
||||||
not valid</small>
|
not valid</small>
|
||||||
</label>
|
</label>
|
||||||
<div class="small-10 columns">
|
<div class="small-10 columns">
|
||||||
<input type="text" id="address" name="address" ng-disabled="loading"
|
<input type="text" id="address" name="address" ng-disabled="loading || !!$root.merchant"
|
||||||
placeholder="Send to" ng-model="address" ng-change="onChanged()" valid-address required>
|
placeholder="Send to" ng-model="address" ng-change="onChanged()" valid-address required>
|
||||||
<small class="icon-input" ng-show="!sendForm.address.$invalid && address"><i class="fi-check"></i></small>
|
<small class="icon-input" ng-show="!sendForm.address.$invalid && address"><i class="fi-check"></i></small>
|
||||||
<small class="icon-input" ng-show="sendForm.address.$invalid && address"><i class="fi-x"></i></small>
|
<small class="icon-input" ng-show="sendForm.address.$invalid && address"><i class="fi-x"></i></small>
|
||||||
|
|
@ -129,8 +129,9 @@
|
||||||
<div class="large-6 columns show-for-large-up" ng-show="!!$root.merchant">
|
<div class="large-6 columns show-for-large-up" ng-show="!!$root.merchant">
|
||||||
<div class="send-note">
|
<div class="send-note">
|
||||||
<h6>Send to</h6>
|
<h6>Send to</h6>
|
||||||
<p class="text-gray" ng-class="{'hidden': sendForm.address.$invalid || !address}">
|
<p class="text-gray" ng-class="{'hidden': sendForm.address.$invalid || !address}"
|
||||||
{{$root.merchant.request_url}}
|
title="{{$root.merchant.request_url}}">
|
||||||
|
{{$root.merchant.domain}}
|
||||||
</p>
|
</p>
|
||||||
<h6>Total amount for this transaction:</h6>
|
<h6>Total amount for this transaction:</h6>
|
||||||
<p class="text-gray" ng-class="{'hidden': sendForm.amount.$invalid || !amount > 0}">
|
<p class="text-gray" ng-class="{'hidden': sendForm.amount.$invalid || !amount > 0}">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue