add transaction comment - custom popup (Gabriel)
This commit is contained in:
parent
97013ea5b6
commit
8759b633fb
8 changed files with 205 additions and 133 deletions
|
|
@ -20,6 +20,14 @@
|
|||
z-index: -1;
|
||||
}
|
||||
|
||||
.popup-container.active .popup {
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
.popup-container .popup {
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
.bct {
|
||||
background-color: transparent !important;
|
||||
margin-top: -25px;
|
||||
|
|
|
|||
|
|
@ -1,50 +1,93 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('txDetailsController', function($rootScope, $scope, $filter, profileService, nodeWebkit, configService, gettextCatalog) {
|
||||
angular.module('copayApp.controllers').controller('txDetailsController', function($rootScope, $log, $scope, $filter, $ionicPopup, gettextCatalog, profileService, configService) {
|
||||
|
||||
var self = $scope.self;
|
||||
var fc = profileService.focusedClient;
|
||||
var config = configService.getSync();
|
||||
var configWallet = config.wallet;
|
||||
var walletSettings = configWallet.settings;
|
||||
var self = $scope.self;
|
||||
var fc = profileService.focusedClient;
|
||||
var config = configService.getSync();
|
||||
var configWallet = config.wallet;
|
||||
var walletSettings = configWallet.settings;
|
||||
|
||||
$scope.alternativeIsoCode = walletSettings.alternativeIsoCode;
|
||||
$scope.color = fc.backgroundColor;
|
||||
$scope.copayerId = fc.credentials.copayerId;
|
||||
$scope.isShared = fc.credentials.n > 1;
|
||||
$scope.alternativeIsoCode = walletSettings.alternativeIsoCode;
|
||||
$scope.color = fc.backgroundColor;
|
||||
$scope.copayerId = fc.credentials.copayerId;
|
||||
$scope.isShared = fc.credentials.n > 1;
|
||||
|
||||
$scope.getAlternativeAmount = function() {
|
||||
var satToBtc = 1 / 100000000;
|
||||
fc.getFiatRate({
|
||||
code: $scope.alternativeIsoCode,
|
||||
ts: $scope.btx.time * 1000
|
||||
}, function(err, res) {
|
||||
if (err) {
|
||||
$log.debug('Could not get historic rate');
|
||||
return;
|
||||
}
|
||||
if (res && res.rate) {
|
||||
var alternativeAmountBtc = ($scope.btx.amount * satToBtc).toFixed(8);
|
||||
$scope.rateDate = res.fetchedOn;
|
||||
$scope.rateStr = res.rate + ' ' + $scope.alternativeIsoCode;
|
||||
$scope.alternativeAmountStr = $filter('noFractionNumber')(alternativeAmountBtc * res.rate, 2) + ' ' + $scope.alternativeIsoCode;
|
||||
$scope.$apply();
|
||||
}
|
||||
});
|
||||
if ($scope.btx.txid) {
|
||||
fc.getTxNote({
|
||||
txid: $scope.btx.txid
|
||||
}, function(err, note) {
|
||||
if (err || !note) {
|
||||
$log.debug(gettextCatalog.getString('Could not fetch transaction note'));
|
||||
return;
|
||||
}
|
||||
$scope.comment = note.body;
|
||||
$scope.editedBy = gettextCatalog.getString('Edited by') + ' ' + note.editedByName;
|
||||
$scope.createdOn = note.createdOn;
|
||||
});
|
||||
}
|
||||
|
||||
$scope.showCommentPopup = function() {
|
||||
$scope.data = {
|
||||
comment: ''
|
||||
};
|
||||
|
||||
$scope.getShortNetworkName = function() {
|
||||
var n = fc.credentials.network;
|
||||
return n.substring(0, 4);
|
||||
var commentPopup = $ionicPopup.show({
|
||||
templateUrl: "views/includes/note.html",
|
||||
title: gettextCatalog.getString('Enter a new comment'),
|
||||
subTitle: gettextCatalog.getString('Save an empty content to delete it'),
|
||||
scope: $scope,
|
||||
});
|
||||
|
||||
$scope.commentPopupClose = function() {
|
||||
commentPopup.close();
|
||||
};
|
||||
|
||||
$scope.copyToClipboard = function(addr) {
|
||||
if (!addr) return;
|
||||
self.copyToClipboard(addr);
|
||||
$scope.commentPopupSave = function() {
|
||||
fc.editTxNote({
|
||||
txid: $scope.btx.txid,
|
||||
body: $scope.data.comment
|
||||
}, function() {});
|
||||
$scope.comment = $scope.data.comment;
|
||||
$scope.editedBy = gettextCatalog.getString('Edited by') + ' ' + fc.credentials.copayerName;
|
||||
$scope.createdOn = Math.floor(Date.now() / 1000);
|
||||
commentPopup.close();
|
||||
};
|
||||
};
|
||||
|
||||
$scope.cancel = function() {
|
||||
$scope.txDetailsModal.hide();
|
||||
};
|
||||
$scope.getAlternativeAmount = function() {
|
||||
var satToBtc = 1 / 100000000;
|
||||
|
||||
});
|
||||
fc.getFiatRate({
|
||||
code: $scope.alternativeIsoCode,
|
||||
ts: $scope.btx.time * 1000
|
||||
}, function(err, res) {
|
||||
if (err) {
|
||||
$log.debug('Could not get historic rate');
|
||||
return;
|
||||
}
|
||||
if (res && res.rate) {
|
||||
var alternativeAmountBtc = ($scope.btx.amount * satToBtc).toFixed(8);
|
||||
$scope.rateDate = res.fetchedOn;
|
||||
$scope.rateStr = res.rate + ' ' + $scope.alternativeIsoCode;
|
||||
$scope.alternativeAmountStr = $filter('noFractionNumber')(alternativeAmountBtc * res.rate, 2) + ' ' + $scope.alternativeIsoCode;
|
||||
$scope.$apply();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$scope.getShortNetworkName = function() {
|
||||
var n = fc.credentials.network;
|
||||
return n.substring(0, 4);
|
||||
};
|
||||
|
||||
$scope.copyToClipboard = function(addr) {
|
||||
if (!addr) return;
|
||||
self.copyToClipboard(addr);
|
||||
};
|
||||
|
||||
$scope.cancel = function() {
|
||||
$scope.txDetailsModal.hide();
|
||||
};
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue