allow to rm comment

This commit is contained in:
Matias Alejo Garcia 2016-06-04 17:52:34 -03:00
commit 7ef07bc0ee
No known key found for this signature in database
GPG key ID: 02470DB551277AB3

View file

@ -1,6 +1,6 @@
'use strict'; 'use strict';
angular.module('copayApp.controllers').controller('txDetailsController', function($rootScope, $log, $scope, $filter, $ionicPopup, gettextCatalog, profileService, configService) { angular.module('copayApp.controllers').controller('txDetailsController', function($rootScope, $log, $scope, $filter, $ionicPopup, gettextCatalog, profileService, configService, lodash) {
var self = $scope.self; var self = $scope.self;
var fc = profileService.focusedClient; var fc = profileService.focusedClient;
@ -14,7 +14,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
$scope.isShared = fc.credentials.n > 1; $scope.isShared = fc.credentials.n > 1;
$scope.showCommentPopup = function() { $scope.showCommentPopup = function() {
$scope.data = { $scope.data = {
comment: $scope.btx.note ? $scope.btx.note.body : '', comment: $scope.btx.note ? $scope.btx.note.body : '',
}; };
var commentPopup = $ionicPopup.show({ var commentPopup = $ionicPopup.show({
@ -28,19 +28,27 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
$scope.commentPopupSave = function() { $scope.commentPopupSave = function() {
$log.debug('Saving note'); $log.debug('Saving note');
fc.editTxNote({ var args = {
txid: $scope.btx.txid, txid: $scope.btx.txid,
body: $scope.data.comment, };
}, function(err) {
if (!lodash.isEmpty($scope.data.comment)) {
args.body = $scope.data.comment;
};
fc.editTxNote(args, function(err) {
if (err) { if (err) {
$log.debug('Could not save tx comment'); $log.debug('Could not save tx comment');
return; return;
} }
// This is only to refresh the current screen data // This is only to refresh the current screen data
$scope.btx.note = {}; $scope.btx.note = null;
$scope.btx.note.body = $scope.data.comment; if (args.body) {
$scope.btx.note.editedByName = fc.credentials.copayerName; $scope.btx.note = {};
$scope.btx.note.editedOn = Math.floor(Date.now() / 1000); $scope.btx.note.body = $scope.data.comment;
$scope.btx.note.editedByName = fc.credentials.copayerName;
$scope.btx.note.editedOn = Math.floor(Date.now() / 1000);
}
$scope.btx.searcheableString = null; $scope.btx.searcheableString = null;
commentPopup.close(); commentPopup.close();
}); });