Merge pull request #224 from JDonadio/fix/comment-tpx

Add description
This commit is contained in:
Matias Alejo Garcia 2016-08-24 17:07:12 -03:00 committed by GitHub
commit a556f36f4c
3 changed files with 49 additions and 28 deletions

View file

@ -61,9 +61,11 @@
</div> </div>
<div class="item item-icon-right"> <div class="item item-icon-left item-icon-right" ng-click="showDescriptionPopup()">
Add Description (not yet working...) <span ng-show="!description">Add Description</span>
<i class="icon ion-ios-arrow-right size-21"></i> <span ng-show="description">{{description}}</span>
<i class="icon ion-ios-chatbubble-outline size-21"></i>
<i class="icon ion-ios-plus-empty size-21"></i>
</div> </div>
</div> </div>

View file

@ -1,15 +1,11 @@
<div class="columns m20t"> <div class="padding">
<label class="size-14 text-center">
<span ng-show="!comment" translate>Add comment</span>
<span ng-show="comment" translate>Edit comment</span>
</label>
<input type="text" ng-model="data.comment" autofocus> <input type="text" ng-model="data.comment" autofocus>
</div> </div>
<div class="row m20t dib"> <div class="row">
<div class="half-row left"> <div class="col">
<button class="round outline dark-gray expand" ng-click="commentPopupClose()" translate>Cancel</button> <button class="button button-dark button-block" ng-click="commentPopupClose()" translate>Cancel</button>
</div> </div>
<div class="half-row left"> <div class="col">
<button ng-style="{'background-color': index.backgroundColor}" class="round outline expand" ng-click="commentPopupSave()" translate>Save</button> <button class="button button-dark button-block" ng-click="commentPopupSave()" translate>Save</button>
</div> </div>
</div> </div>

View file

@ -1,12 +1,12 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, $ionicPopup, txStatus, gettext, txFormatService) { angular.module('copayApp.controllers').controller('confirmController', function($rootScope, $scope, $filter, $timeout, $ionicScrollDelegate, gettextCatalog, walletService, platformInfo, lodash, configService, rateService, $stateParams, $window, $state, $log, profileService, bitcore, $ionicPopup, txStatus, gettext, txFormatService) {
var cachedTxp = {}; var cachedTxp = {};
// An alert dialog // An alert dialog
var showAlert = function(title, msg, cb) { var showAlert = function(title, msg, cb) {
$log.warn(title + ":" + msg); $log.warn(title + ": " + msg);
var alertPopup = $ionicPopup.alert({ var alertPopup = $ionicPopup.alert({
title: title, title: title,
template: msg template: msg
@ -17,6 +17,29 @@ angular.module('copayApp.controllers').controller('confirmController', function(
alertPopup.then(cb); alertPopup.then(cb);
}; };
$scope.showDescriptionPopup = function() {
var commentPopup = $ionicPopup.show({
templateUrl: "views/includes/note.html",
title: gettextCatalog.getString('Set description'),
scope: $scope,
});
$scope.commentPopupClose = function() {
commentPopup.close();
};
$scope.commentPopupSave = function() {
$log.debug('Saving description: ' + $scope.data.comment);
$scope.description = $scope.data.comment;
$scope.txp = null;
createTx($scope.wallet, $scope.toAddress, $scope.toAmount, $scope.data.comment, function(err, txp) {
if (err) return;
cachedTxp[$scope.wallet.id] = txp;
apply(txp);
});
commentPopup.close();
};
};
$scope.init = function() { $scope.init = function() {
// TODO (URL , etc) // TODO (URL , etc)
@ -67,17 +90,11 @@ angular.module('copayApp.controllers').controller('confirmController', function(
stop = null; stop = null;
} }
function apply(txp) {
$scope.fee = txFormatService.formatAmountStr(txp.fee);
$scope.txp = txp;
$scope.$apply();
};
if (cachedTxp[wallet.id]) { if (cachedTxp[wallet.id]) {
apply(cachedTxp[wallet.id]); apply(cachedTxp[wallet.id]);
} else { } else {
stop = $timeout(function() { stop = $timeout(function() {
createTx(wallet, $scope.toAddress, $scope.toAmount, $scope.comment, function(err, txp) { createTx(wallet, $scope.toAddress, $scope.toAmount, $scope.description, function(err, txp) {
if (err) return; if (err) return;
cachedTxp[wallet.id] = txp; cachedTxp[wallet.id] = txp;
apply(txp); apply(txp);
@ -106,7 +123,13 @@ angular.module('copayApp.controllers').controller('confirmController', function(
showAlert(gettext('Error creating transaction'), msg); showAlert(gettext('Error creating transaction'), msg);
}; };
var createTx = function(wallet, toAddress, toAmount, comment, cb) { function apply(txp) {
$scope.fee = txFormatService.formatAmountStr(txp.fee);
$scope.txp = txp;
$scope.$apply();
};
var createTx = function(wallet, toAddress, toAmount, description, cb) {
var config = configService.getSync().wallet; var config = configService.getSync().wallet;
// //
@ -117,7 +140,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
var paypro = $scope.paypro; var paypro = $scope.paypro;
// ToDo: use a credential's (or fc's) function for this // ToDo: use a credential's (or fc's) function for this
if (comment && !wallet.credentials.sharedEncryptingKey) { if (description && !wallet.credentials.sharedEncryptingKey) {
var msg = 'Could not add message to imported wallet without shared encrypting key'; var msg = 'Could not add message to imported wallet without shared encrypting key';
$log.warn(msg); $log.warn(msg);
return setSendError(gettext(msg)); return setSendError(gettext(msg));
@ -132,7 +155,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
outputs.push({ outputs.push({
'toAddress': toAddress, 'toAddress': toAddress,
'amount': toAmount, 'amount': toAmount,
'message': comment 'message': description
}); });
var txp = {}; var txp = {};
@ -145,7 +168,7 @@ angular.module('copayApp.controllers').controller('confirmController', function(
} }
txp.outputs = outputs; txp.outputs = outputs;
txp.message = comment; txp.message = description;
txp.payProUrl = paypro ? paypro.url : null; txp.payProUrl = paypro ? paypro.url : null;
txp.excludeUnconfirmedUtxos = config.spendUnconfirmed ? false : true; txp.excludeUnconfirmedUtxos = config.spendUnconfirmed ? false : true;
txp.feeLevel = config.settings.feeLevel || 'normal'; txp.feeLevel = config.settings.feeLevel || 'normal';