forked from wavesplatform/WavesGUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(transaction): menu to copy transaction details
Introduced a new component for copying tx data to clipboard Removed redundant copy tx addresses to clipboard functionality Removed extra markup for that from index.html
- Loading branch information
1 parent
d9e9769
commit 4b1a5d2
Showing
5 changed files
with
105 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
(function () { | ||
'use strict'; | ||
|
||
var ADDRESS_STUB = 'n/a'; | ||
|
||
function TransactionMenuController(notificationService) { | ||
var ctrl = this; | ||
|
||
ctrl.idCopied = idCopied; | ||
ctrl.dataCopied = dataCopied; | ||
ctrl.fullTransactionData = fullTransactionData; | ||
ctrl.hasRecipient = hasRecipient; | ||
ctrl.addressCopied = addressCopied; | ||
|
||
function addressCopied () { | ||
return notificationService.notice('Address has been copied'); | ||
} | ||
|
||
function idCopied () { | ||
notificationService.notice('Transaction ID has been copied'); | ||
} | ||
|
||
function dataCopied () { | ||
notificationService.notice('Full transaction data have been copied'); | ||
} | ||
|
||
function hasRecipient () { | ||
return !!ctrl.transaction.recipient; | ||
} | ||
|
||
function fullTransactionData () { | ||
var recipient = hasRecipient() ? ctrl.transaction.recipient : ADDRESS_STUB; | ||
|
||
return 'TX ID: ' + ctrl.transaction.id + | ||
' | TYPE: ' + ctrl.transaction.formatted.type + | ||
' | DATE: ' + ctrl.transaction.formatted.datetime + | ||
' | SENDER ADDRESS: ' + ctrl.transaction.sender + | ||
' | TX AMOUNT: ' + ctrl.transaction.formatted.amount + ' ' + ctrl.transaction.formatted.asset + | ||
' | RECIPIENT ADDRESS: ' + recipient + | ||
' | TX FEE: ' + ctrl.transaction.formatted.fee; | ||
} | ||
} | ||
|
||
TransactionMenuController.$inject = ['notificationService']; | ||
|
||
angular | ||
.module('app.shared') | ||
.component('txMenu', { | ||
controller: TransactionMenuController, | ||
bindings: { | ||
transaction: '<' | ||
}, | ||
template: '<md-menu>' + | ||
'<md-button class="md-icon-button" ng-click="$mdOpenMenu($event)">' + | ||
'<img ng-src="img/slack_icon.svg" height="16" width="16" />' + | ||
'</md-button>' + | ||
'<md-menu-content width="2">' + | ||
'<md-menu-item>' + | ||
'<md-button ngclipboard data-clipboard-text="{{::$ctrl.transaction.sender}}" ' + | ||
'ngclipboard-success="$ctrl.addressCopied()">' + | ||
'<span md-menu-align-target>Copy sender address</span>' + | ||
'</md-button>' + | ||
'</md-menu-item>' + | ||
'<md-menu-item>' + | ||
'<md-button ng-disabled="!$ctrl.hasRecipient()" ngclipboard ' + | ||
'data-clipboard-text="{{::$ctrl.transaction.recipient}}" ' + | ||
'ngclipboard-success="$ctrl.addressCopied()">' + | ||
'<span md-menu-align-target>Copy recipient address</span>' + | ||
'</md-button>' + | ||
'</md-menu-item>' + | ||
'<md-menu-item>' + | ||
'<md-button ngclipboard data-clipboard-text="{{::$ctrl.transaction.id}}" ' + | ||
'ngclipboard-success="$ctrl.idCopied()">' + | ||
'<span md-menu-align-target>Copy TX ID</span>' + | ||
'</md-button>' + | ||
'</md-menu-item>' + | ||
'<md-menu-item>' + | ||
'<md-button ngclipboard ngclipboard-text-provider="$ctrl.fullTransactionData()" ' + | ||
'ngclipboard-success="$ctrl.dataCopied()">' + | ||
'<span md-menu-align-target>Copy full TX data</span>' + | ||
'</md-button>' + | ||
'</md-menu-item>' + | ||
'</md-menu-content>' + | ||
'</md-menu>' | ||
}); | ||
})(); |