Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding overage alert to advanced payout. #2386

Merged
merged 8 commits into from
Oct 23, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 122 additions & 0 deletions app/assets/v2/css/bulk_payout_bounty.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#tooltip--hover {
min-height: 37%;
top: 17rem;
}

@media only screen and (max-width: 1400px) {
#tooltip--hover {
top: 18.5rem;
}
}

@media only screen and (max-width: 750px) {
#tooltip--hover {
min-height: 30%;
}
}

@media only screen and (max-width: 400px) {
#tooltip--hover {
min-height: 33%;
left: 70px;
top: 20.5rem;
}
}

#transaction_registry {
width: 100%;
}

#transaction_registry tr td {
padding: 10px;
border: #333 solid 1px;
}

#trans_preview {
padding: 5px;
border-radius: 3px;
background-color: #fafafa;
position: absolute;
top: 5rem;
right: -20rem;
}

#trans_preview h5 {
color: #08cf7b;
}

#primary_form {
margin: 0px 25%;
}

@media (max-width: 1100px) {
#primary_form {
margin: 0px 15%;
}
}

@media (max-width: 900px) {
#primary_form {
margin: 0px 5%;
}
}

@media (max-width: 750px) {
#trans_preview {
position: unset;
top: 200px;
left: 72%;
width: 100%;
}
#primary_form {
margin: 0px auto;
}
}

tr div {
border-radius: 3px;
padding: 5px;
}

.error {
border: 1px solid red !important;
}

.entry.active {
background-color: #bbb;
}

.overageAlert {
background-color: #E66700;
color: #FFF;
border-radius: 5px;
margin-top: 15px;
margin-bottom: 5px;
display: none;
padding-left: 15px;
}

.overageAlert>div:first-child {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cosmetic / Space to breath 😄
.overageAlert > div:first-child

width: 25px;
float: left;
padding-right: 10px;
}

.overageAlert>div:last-child {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same ^

width: calc(100% - 40px);
float: left;
margin-left: 15px;
padding-right: 15px;
padding-top: 6.5px;
}

.overageAlert>div:first-child>img {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same ^

width: 17px;
margin-top: 10px;
}

.overagePreview {
color: #E66700;
padding-bottom: 5px;
display: none;
}
20 changes: 17 additions & 3 deletions app/assets/v2/js/pages/bulk_payout.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ $(document).ready(function($) {
<tr>
<td class="pl-0 pb-0">
<div class="pl-0">
<select id="username" onchange="update_registry()" class="username-search custom-select" style="width: 100%; margin-left: auto; margin-right: auto;"></select>
<select onchange="update_registry()" class="username-search custom-select" style="width: 100%; margin-left: auto; margin-right: auto;"></select>
Anish-Agnihotri marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add w-100 ml-auto mr-auto to the class attribute and we can get rid of the style=... attribute. :)

</div>
</td>
<td class="pb-0"><div class="percent" contenteditable="true">` + percent + `</div></td>
Expand All @@ -185,12 +185,12 @@ $(document).ready(function($) {
});

var get_total_cost = function() {
var num_rows = $('#payout_table tbody').find('tr').length;
var num_rows = $('#payout_table').find('tr').length;
Anish-Agnihotri marked this conversation as resolved.
Show resolved Hide resolved
var total = 0;
var i = 1;
Anish-Agnihotri marked this conversation as resolved.
Show resolved Hide resolved

for (i = 1; i < num_rows; i += 1) {
Anish-Agnihotri marked this conversation as resolved.
Show resolved Hide resolved
var $row = $('#payout_table tobdy').find('tr:nth-child(' + i + ')');
var $row = $('#payout_table').find('tr:nth-child(' + i + ')');
var amount = parseFloat($row.find('.amount').text());
var username = $row.find('.username-search').text();
var is_error = !$.isNumeric(amount) || amount <= 0 || username == '' || username == '@';
Expand All @@ -209,10 +209,24 @@ var update_registry = function() {
var denomination = $('#token_name').text();
var original_amount = $('#original_amount').val();
var net = round(original_amount - tc, 2);
var over = round((original_amount - get_total_cost()) * -1, 4);
var addr = web3.eth.coinbase.substring(38);

$('#total_cost').html(tc + ' ' + denomination);
$('#total_net').html(net + ' ' + denomination);

if (over > 0) {
$('.overageAlert').css('display', 'inline-block');
$('.overagePreview').css('display', 'inline-block');
$('#total_overage').html(over + ' ' + denomination);
$('#address_ending').html(addr + ' ');
$('#preview_ending').html(addr + ' ');
$('#preview_overage').html(over + ' ' + denomination);
} else {
$('.overageAlert').css('display', 'none');
$('.overagePreview').css('display', 'none');
}

let transactions = [];

for (let j = 1; j <= num_rows; j++) {
Expand Down
101 changes: 11 additions & 90 deletions app/dashboard/templates/bulk_payout_bounty.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,7 @@
{% include 'shared/cards.html' %}
{% include 'shared/current_profile.html' %}
<link rel="stylesheet" type="text/css" href="{% static "v2/css/tooltip_hover.css" %}">
<style type="text/css">
#tooltip--hover {
min-height: 37%;
top: 17rem;
}

@media only screen and (max-width: 1400px) {
#tooltip--hover {
top: 18.5rem;
}
}

@media only screen and (max-width: 750px) {
#tooltip--hover {
min-height: 30%;
}
}

@media only screen and (max-width: 400px) {
#tooltip--hover {
min-height: 33%;
left: 70px;
top: 20.5rem;
}
}
</style>
<link rel="stylesheet" type="text/css" href="{% static "v2/css/bulk_payout_bounty.css" %}">
</head>

<body class="interior {{ active }} g-font-muli">
Expand Down Expand Up @@ -99,6 +74,14 @@ <h3>{% trans "Advanced Payout" %}</h3>
<input type="hidden" id="original_amount" value="{{ bounty.value_true }}">
<span id="token_name">{{ bounty.token_name }}</span>
</div>
<div class="w-100 overageAlert">
<div>
<img src="{% static "v2/images/warning.svg" %}">
</div>
<div>
<p>{% trans "You have exceeded the bounty's funded amount. The difference of " %}<span id="total_overage"></span> {% trans "will be paid from your metamask wallet ending in ..." %}<span id="address_ending"></span></p>
</div>
</div>
<div class="w-100 my-3">
<label for=bountyFulfillment>{% trans "Payout" %}</label>
<label id="tooltip">{% trans "Where is my Eth going? " %}<i class='fa fa-info-circle'></i></label>
Expand All @@ -108,7 +91,7 @@ <h3>{% trans "Advanced Payout" %}</h3>
</div>
<div class="mt-2" id="trans_preview">
<h5>{% trans 'Payout Preview' %}</h5>
<p class="mb-0">{% trans 'Refunded' %}: <span id="total_returned">{{ bounty.value_true }} {{ bounty.token_name }}</span></p>
<p class="mb-0 overagePreview"><strong><span id="preview_overage"></span>{% trans ' to be paid from wallet ending in ...' %}<span id="preview_ending"></span></strong></p>
<p class="mb-0">{% trans 'Paid' %}: -<span id="total_cost"></span></p>
<p class="mb-0">{% trans 'Net' %}: <span id="total_net"></span></p>
<p class="mt-1 mb-0">{% trans 'Transactions:' %}</p>
Expand Down Expand Up @@ -139,13 +122,8 @@ <h5>{% trans 'Payout Preview' %}</h5>
<a id="acceptBounty" class="button button--primary btn-block js-submit mt-3 mb-2 pulseClick submitBounty" name="submit" style="width: 100%; text-transform: uppercase; text-align: center; color: white;">
{% trans "Payout Bounty" %}
</a>
<a class="font-caption" style="display: block; margin-top: 20px;" target="_blank" rel="noopener noreferrer" href="https://github.com/gitcoinco/web#high-level-flows">
Your transaction is secured by the Ethereum blockchain.</br>
Learn more here.
</a>
</div>
</div>

</div>
</div>
<div id="tooltip--hover">
<span id="heading">{% trans "Where is my Eth Going?" %}</span><br>
Expand All @@ -160,63 +138,6 @@ <h5>{% trans 'Payout Preview' %}</h5>
</div>
</div>
</div>
<style>
#transaction_registry {
width: 100%;
}
#transaction_registry tr td{
padding: 10px;
border: #333 solid 1px;
}
#trans_preview{
padding: 5px;
border-radius: 3px;
background-color: #fafafa;
position: absolute;
top: 5rem;
right: -20rem;
}
#trans_preview h5{
color: #08cf7b;
}
#primary_form{
margin: 0px 25%;
}
@media (max-width: 1100px) {
#primary_form{
margin: 0px 15%;
}
}
@media (max-width: 900px) {
#primary_form{
margin: 0px 5%;
}
}
@media (max-width: 750px) {
#trans_preview{
position: unset;
top: 200px;
left: 72%;
width: 100%;
}
#primary_form{
margin: 0px auto;
}
}


tr div{
border-radius: 3px;
padding: 5px;
}
.error{
border: 1px solid red !important;
}
.entry.active{
background-color: #bbb;
}

</style>
{% include 'shared/bottom_notification.html' %}
{% include 'shared/analytics.html' %}
{% include 'shared/footer_scripts.html' %}
Expand Down