Code coloring invoice states

This commit is contained in:
rockstardev
2019-05-01 15:33:46 -05:00
committed by Nicolas Dorier
parent 1d3ff143d2
commit 4bc03fbf06
3 changed files with 69 additions and 19 deletions

View File

@@ -498,7 +498,8 @@ namespace BTCPayServer.Controllers
var state = invoice.GetInvoiceState(); var state = invoice.GetInvoiceState();
model.Invoices.Add(new InvoiceModel() model.Invoices.Add(new InvoiceModel()
{ {
Status = state.ToString(), Status = invoice.Status,
StatusString = state.ToString(),
ShowCheckout = invoice.Status == InvoiceStatus.New, ShowCheckout = invoice.Status == InvoiceStatus.New,
Date = invoice.InvoiceTime, Date = invoice.InvoiceTime,
InvoiceId = invoice.Id, InvoiceId = invoice.Id,

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using BTCPayServer.Services.Invoices;
namespace BTCPayServer.Models.InvoicingModels namespace BTCPayServer.Models.InvoicingModels
{ {
@@ -25,7 +26,8 @@ namespace BTCPayServer.Models.InvoicingModels
public string RedirectUrl { get; set; } public string RedirectUrl { get; set; }
public string InvoiceId { get; set; } public string InvoiceId { get; set; }
public string Status { get; set; } public InvoiceStatus Status { get; set; }
public string StatusString { get; set; }
public bool CanMarkComplete { get; set; } public bool CanMarkComplete { get; set; }
public bool CanMarkInvalid { get; set; } public bool CanMarkInvalid { get; set; }
public bool CanMarkStatus => CanMarkComplete || CanMarkInvalid; public bool CanMarkStatus => CanMarkComplete || CanMarkInvalid;

View File

@@ -116,25 +116,13 @@
} }
</td> </td>
<td>@invoice.InvoiceId</td> <td>@invoice.InvoiceId</td>
<td>@invoice.Status</td> <td>
<td style="text-align:right">@invoice.AmountCurrency</td>
<td style="text-align:right">
@if (invoice.ShowCheckout)
{
<span>
<a asp-action="Checkout" asp-route-invoiceId="@invoice.InvoiceId">Checkout</a>
<a href="javascript:btcpay.showInvoice('@invoice.InvoiceId')">[^]</a>
@if (!invoice.CanMarkStatus)
{
<span>-</span>
}
</span>
}
@if (invoice.CanMarkStatus) @if (invoice.CanMarkStatus)
{ {
<a class="dropdown-toggle dropdown-toggle-split" href="#" style="cursor: pointer;" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <span class="dropdown-toggle dropdown-toggle-split pavpill pavpil-@invoice.Status.ToString().ToLower()"
Change status <span class="sr-only">Toggle Dropdown</span> data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
</a> @invoice.StatusString
</span>
<div class="dropdown-menu pull-right"> <div class="dropdown-menu pull-right">
@if (invoice.CanMarkInvalid) @if (invoice.CanMarkInvalid)
{ {
@@ -150,6 +138,24 @@
} }
</div> </div>
} }
else
{
<span class="pavpill pavpil-@invoice.Status.ToString().ToLower()">@invoice.StatusString</span>
}
</td>
<td style="text-align:right">@invoice.AmountCurrency</td>
<td style="text-align:right">
@if (invoice.ShowCheckout)
{
<span>
<a asp-action="Checkout" asp-route-invoiceId="@invoice.InvoiceId">Checkout</a>
<a href="javascript:btcpay.showInvoice('@invoice.InvoiceId')">[^]</a>
@if (!invoice.CanMarkStatus)
{
<span>-</span>
}
</span>
}
&nbsp; &nbsp;
<a asp-action="Invoice" asp-route-invoiceId="@invoice.InvoiceId">Details</a> <a asp-action="Invoice" asp-route-invoiceId="@invoice.InvoiceId">Details</a>
@*<span title="Details" class="fa fa-list"></span>*@ @*<span title="Details" class="fa fa-list"></span>*@
@@ -260,5 +266,46 @@
display: block; display: block;
white-space: nowrap; white-space: nowrap;
} }
.pavpill {
display: inline-block;
padding: 0.3em 0.5em;
font-size: 85%;
font-weight: 500;
line-height: 1;
text-align: center;
white-space: nowrap;
vertical-align: baseline;
border-radius: 0.25rem;
}
.pavpill.dropdown-toggle {
cursor: pointer;
}
.pavpil-new {
background: #d4edda;
color: #000;
}
.pavpil-expired {
background: #eee;
color: #000;
}
.pavpil-invalid {
background: #c94a47;
color: #fff;
}
.pavpil-confirmed, .pavpil-paid {
background: #f1c332;
color: #000;
}
.pavpil-complete {
background: #329f80;
color: #fff;
}
</style> </style>
</section> </section>