allow to rm comment

This commit is contained in:
Matias Alejo Garcia 2016-06-04 17:52:34 -03:00
parent b1a15d56c0
commit 7ef07bc0ee
No known key found for this signature in database
GPG Key ID: 02470DB551277AB3
1 changed files with 17 additions and 9 deletions

View File

@ -1,6 +1,6 @@
'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 fc = profileService.focusedClient;
@ -14,7 +14,7 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
$scope.isShared = fc.credentials.n > 1;
$scope.showCommentPopup = function() {
$scope.data = {
comment: $scope.btx.note ? $scope.btx.note.body : '',
comment: $scope.btx.note ? $scope.btx.note.body : '',
};
var commentPopup = $ionicPopup.show({
@ -28,19 +28,27 @@ angular.module('copayApp.controllers').controller('txDetailsController', functio
$scope.commentPopupSave = function() {
$log.debug('Saving note');
fc.editTxNote({
var args = {
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) {
$log.debug('Could not save tx comment');
return;
}
// This is only to refresh the current screen data
$scope.btx.note = {};
$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.note = null;
if (args.body) {
$scope.btx.note = {};
$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;
commentPopup.close();
});