From 79aa8c44d641f9d225443d3677994f81cf3cd1aa Mon Sep 17 00:00:00 2001 From: Javier Date: Wed, 24 Aug 2016 15:47:36 -0300 Subject: [PATCH 1/2] wip --- public/views/confirm.html | 12 +++++++----- public/views/includes/note.html | 18 +++++++----------- src/js/controllers/confirm.js | 22 ++++++++++++++++++++-- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/public/views/confirm.html b/public/views/confirm.html index dac9298d6..0f21a0ce2 100644 --- a/public/views/confirm.html +++ b/public/views/confirm.html @@ -23,7 +23,7 @@
-
Fee: {{feeLevel}} +
Fee: {{feeLevel}} {{fee || '...'}} @@ -49,7 +49,7 @@
  • - {{item.name || item.id}} + {{item.name || item.id}} {{item.availableBalanceStr}} @@ -61,9 +61,11 @@
-
- Add Description (not yet working...) - +
+ Add Description + {{comment}} + +
diff --git a/public/views/includes/note.html b/public/views/includes/note.html index a4af02532..ee7b59894 100644 --- a/public/views/includes/note.html +++ b/public/views/includes/note.html @@ -1,15 +1,11 @@ -
- +
-
-
- +
+
+
-
- +
+
-
+
\ No newline at end of file diff --git a/src/js/controllers/confirm.js b/src/js/controllers/confirm.js index e793c2709..6eeb7756c 100644 --- a/src/js/controllers/confirm.js +++ b/src/js/controllers/confirm.js @@ -1,12 +1,12 @@ '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 = {}; // An alert dialog var showAlert = function(title, msg, cb) { - $log.warn(title + ":" + msg); + $log.warn(title + ": " + msg); var alertPopup = $ionicPopup.alert({ title: title, template: msg @@ -17,6 +17,22 @@ angular.module('copayApp.controllers').controller('confirmController', function( alertPopup.then(cb); }; + $scope.showCommentPopup = function() { + var commentPopup = $ionicPopup.show({ + templateUrl: "views/includes/note.html", + title: $scope.data.comment ? gettextCatalog.getString('Edit comment') : gettextCatalog.getString('Add comment'), + scope: $scope, + }); + $scope.commentPopupClose = function() { + commentPopup.close(); + }; + $scope.commentPopupSave = function() { + $log.debug('Saving comment'); + $scope.comment = $scope.data.comment; + commentPopup.close(); + }; + }; + $scope.init = function() { // TODO (URL , etc) @@ -160,6 +176,8 @@ angular.module('copayApp.controllers').controller('confirmController', function( $scope.approve = function() { + console.log($scope.comment); + return; var wallet = $scope.wallet; var txp = $scope.txp; if (!wallet) { From dc7f55708e32d01e2521a0ec3a0d3ab1e52ae622 Mon Sep 17 00:00:00 2001 From: Javier Date: Wed, 24 Aug 2016 16:53:14 -0300 Subject: [PATCH 2/2] fix comment (description) on send view --- public/views/confirm.html | 6 ++--- public/views/includes/note.html | 2 +- src/js/controllers/confirm.js | 39 +++++++++++++++++++-------------- 3 files changed, 26 insertions(+), 21 deletions(-) diff --git a/public/views/confirm.html b/public/views/confirm.html index 0f21a0ce2..d6669bbc3 100644 --- a/public/views/confirm.html +++ b/public/views/confirm.html @@ -61,9 +61,9 @@
-
- Add Description - {{comment}} +
+ Add Description + {{description}}
diff --git a/public/views/includes/note.html b/public/views/includes/note.html index ee7b59894..e52beba85 100644 --- a/public/views/includes/note.html +++ b/public/views/includes/note.html @@ -8,4 +8,4 @@
-
\ No newline at end of file +
diff --git a/src/js/controllers/confirm.js b/src/js/controllers/confirm.js index 6eeb7756c..383a7ba56 100644 --- a/src/js/controllers/confirm.js +++ b/src/js/controllers/confirm.js @@ -17,18 +17,25 @@ angular.module('copayApp.controllers').controller('confirmController', function( alertPopup.then(cb); }; - $scope.showCommentPopup = function() { + $scope.showDescriptionPopup = function() { var commentPopup = $ionicPopup.show({ templateUrl: "views/includes/note.html", - title: $scope.data.comment ? gettextCatalog.getString('Edit comment') : gettextCatalog.getString('Add comment'), + title: gettextCatalog.getString('Set description'), scope: $scope, }); $scope.commentPopupClose = function() { commentPopup.close(); }; $scope.commentPopupSave = function() { - $log.debug('Saving comment'); - $scope.comment = $scope.data.comment; + $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(); }; }; @@ -83,17 +90,11 @@ angular.module('copayApp.controllers').controller('confirmController', function( stop = null; } - function apply(txp) { - $scope.fee = txFormatService.formatAmountStr(txp.fee); - $scope.txp = txp; - $scope.$apply(); - }; - if (cachedTxp[wallet.id]) { apply(cachedTxp[wallet.id]); } else { 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; cachedTxp[wallet.id] = txp; apply(txp); @@ -122,7 +123,13 @@ angular.module('copayApp.controllers').controller('confirmController', function( 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; // @@ -133,7 +140,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( var paypro = $scope.paypro; // 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'; $log.warn(msg); return setSendError(gettext(msg)); @@ -148,7 +155,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( outputs.push({ 'toAddress': toAddress, 'amount': toAmount, - 'message': comment + 'message': description }); var txp = {}; @@ -161,7 +168,7 @@ angular.module('copayApp.controllers').controller('confirmController', function( } txp.outputs = outputs; - txp.message = comment; + txp.message = description; txp.payProUrl = paypro ? paypro.url : null; txp.excludeUnconfirmedUtxos = config.spendUnconfirmed ? false : true; txp.feeLevel = config.settings.feeLevel || 'normal'; @@ -176,8 +183,6 @@ angular.module('copayApp.controllers').controller('confirmController', function( $scope.approve = function() { - console.log($scope.comment); - return; var wallet = $scope.wallet; var txp = $scope.txp; if (!wallet) {