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 3 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
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,9 +209,23 @@ 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);
$('#total_overage').html(over + ' ' + denomination);
Anish-Agnihotri marked this conversation as resolved.
Show resolved Hide resolved
$('#address_ending').html(addr + ' ');
$('#preview_ending').html(addr + ' ');
$('#preview_overage').html(over + ' ' + denomination);

if (over > 0) {
$('.overageAlert').css('display', 'inline-block');
$('.overagePreview').css('display', 'inline-block');
} else {
$('.overageAlert').css('display', 'none');
$('.overagePreview').css('display', 'none');
}

let transactions = [];

Expand Down
41 changes: 39 additions & 2 deletions app/dashboard/templates/bulk_payout_bounty.html
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,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 +116,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 @@ -215,7 +223,36 @@ <h5>{% trans 'Payout Preview' %}</h5>
.entry.active{
background-color: #bbb;
}

.overageAlert {
Anish-Agnihotri marked this conversation as resolved.
Show resolved Hide resolved
background-color: #E66700;
color: #FFF;
border-radius: 5px;
margin-top: 15px;
margin-bottom: 5px;
display: none;
padding-left: 15px;
}
.overageAlert > div:first-child {
width: 25px;
float: left;
padding-right: 10px;
}
.overageAlert > div:last-child {
width: calc(100% - 40px);
float: left;
margin-left: 15px;
padding-right: 15px;
padding-top: 6.5px;
}
.overageAlert > div:first-child > img {
width: 17px;
margin-top: 10px;
}
.overagePreview {
color: #E66700;
padding-bottom: 5px;
display: none;
}
Anish-Agnihotri marked this conversation as resolved.
Show resolved Hide resolved
</style>
{% include 'shared/bottom_notification.html' %}
{% include 'shared/analytics.html' %}
Expand Down