mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2026-01-04 22:54:20 +01:00
Print view improvements (#3050)
* Add ln enable link Add print button + print-related css classes * Modify print-specific css -Adds @dennisreimann css suggestions to prevent page-breaks cutting off QR codes -Removes item image and description in print view -Add comment to explain purpose of print-specific styling in site.css * Streamline POS print view Co-authored-by: Dennis Reimann <mail@dennisreimann.de>
This commit is contained in:
@@ -4,119 +4,87 @@
|
||||
@inject BTCPayNetworkProvider BTCPayNetworkProvider
|
||||
@model BTCPayServer.Models.AppViewModels.ViewPointOfSaleViewModel
|
||||
|
||||
<style>
|
||||
/* This hides unwanted metadata such as url, date, etc from appearing on a printed page. */
|
||||
@@media print {
|
||||
@@page {
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
.card { display: inline-block; width: 300px; page-break-inside: avoid; margin: 2em 1em 0 1em; }
|
||||
</style>
|
||||
|
||||
@{
|
||||
Layout = "_LayoutPos";
|
||||
Context.Request.Query.TryGetValue("cryptocode", out var cryptoCodeValues);
|
||||
var cryptoCode = cryptoCodeValues.FirstOrDefault() ?? "BTC";
|
||||
Layout = "_LayoutPos";
|
||||
var anyInventoryItems = Model.Items.Any(item => item.Inventory.HasValue);
|
||||
var supported = Model.Store.GetSupportedPaymentMethods(BTCPayNetworkProvider).OfType<LNURLPaySupportedPaymentMethod>().OrderBy(method => method.CryptoCode == cryptoCode).FirstOrDefault();
|
||||
if (supported != null && !Model.Store.GetEnabledPaymentIds(BTCPayNetworkProvider).Contains(supported.PaymentId))
|
||||
{
|
||||
supported = null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@if (supported is null)
|
||||
{
|
||||
<div class="alert alert-warning text-center sticky-top mb-0 rounded-0" role="alert">
|
||||
LNURL is not enabled on your store, which this print feature relies on.
|
||||
<a asp-action="PaymentMethods" asp-controller="Stores" asp-route-storeId="@Model.Store.Id" class="alert-link p-0">
|
||||
Enable LNURL
|
||||
</a>
|
||||
</div>
|
||||
}
|
||||
<div class="container d-flex h-100">
|
||||
<div class="justify-content-center align-self-center text-center mx-auto px-2 py-3 w-100 m-auto">
|
||||
<partial name="_StatusMessage" />
|
||||
|
||||
<h1 class="mb-4">@Model.Title</h1>
|
||||
@if (!string.IsNullOrEmpty(Model.Description))
|
||||
{
|
||||
<div class="row">
|
||||
<div class="overflow-hidden col-12">@Safe.Raw(Model.Description)</div>
|
||||
</div>
|
||||
}
|
||||
<div class="card-deck my-3 mx-auto">
|
||||
@for (int x = 0; x < Model.Items.Length; x++)
|
||||
{
|
||||
var item = Model.Items[x];
|
||||
var buttonText = string.IsNullOrEmpty(item.BuyButtonText) ? item.Price.Type != ViewPointOfSaleViewModel.Item.ItemPrice.ItemPriceType.Fixed ? Model.CustomButtonText : Model.ButtonText : item.BuyButtonText;
|
||||
buttonText = buttonText.Replace("{0}",item.Price.Formatted)
|
||||
?.Replace("{Price}",item.Price.Formatted);
|
||||
|
||||
<div class="card px-0" data-id="@x">
|
||||
@if (!String.IsNullOrWhiteSpace(item.Image))
|
||||
{
|
||||
<img class="card-img-top" src="@item.Image" asp-append-version="true">
|
||||
}
|
||||
@{CardBody(item.Title, item.Description);}
|
||||
<div class="card-footer bg-transparent border-0 pb-3">
|
||||
<div class="w-100 pt-2 text-center text-muted">
|
||||
@switch (item.Price.Type)
|
||||
{
|
||||
case ViewPointOfSaleViewModel.Item.ItemPrice.ItemPriceType.Topup:
|
||||
<span>Any amount</span>
|
||||
break;
|
||||
case ViewPointOfSaleViewModel.Item.ItemPrice.ItemPriceType.Minimum:
|
||||
<span>@item.Price.Formatted minimum</span>
|
||||
break;
|
||||
case ViewPointOfSaleViewModel.Item.ItemPrice.ItemPriceType.Fixed:
|
||||
@item.Price.Formatted
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
</div>
|
||||
@if (!item.Inventory.HasValue || item.Inventory.Value > 0)
|
||||
{
|
||||
if (supported != null)
|
||||
{
|
||||
var lnurlEndpoint = new Uri(Url.Action("GetLNURLForApp", "LNURL", new
|
||||
{
|
||||
cryptoCode = supported.CryptoCode,
|
||||
appid = Model.AppId,
|
||||
ItemCode = item.Id
|
||||
}, Context.Request.Scheme, Context.Request.Host.ToString()));
|
||||
var lnUrl = LNURL.EncodeUri(lnurlEndpoint, "payRequest", supported.UseBech32Scheme);
|
||||
<vc:qr-code data="@lnUrl.ToString().ToUpperInvariant()"></vc:qr-code>
|
||||
|
||||
<a href="@lnUrl" class="btn btn-secondary d-print-none w-100 mt-2 lnurl" data-choice="@item.Id" rel="noreferrer noopener">
|
||||
Open in wallet
|
||||
</a>
|
||||
}
|
||||
}
|
||||
@if (item.Inventory.HasValue)
|
||||
{
|
||||
|
||||
<div class="w-100 pt-2 text-center text-muted">
|
||||
@if (item.Inventory > 0)
|
||||
{
|
||||
<span>@item.Inventory left</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>Sold out</span>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
else if (anyInventoryItems)
|
||||
{
|
||||
<div class="w-100 pt-2"> </div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
else
|
||||
{
|
||||
<div class="alert alert-info d-flex align-items-center justify-content-center sticky-top mb-0 rounded-0 d-print-none" role="alert">
|
||||
<button type="button" class="btn btn-info me-4 border border-light" onclick="window.print()">
|
||||
<i class="fa fa-print"></i> Print
|
||||
</button>
|
||||
This view is intended for printing only —
|
||||
<a asp-route-viewType="static" class="alert-link">Regular version</a>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@functions {
|
||||
private void CardBody(string title, string description)
|
||||
<div class="container text-center">
|
||||
@for (int x = 0; x < Model.Items.Length; x++)
|
||||
{
|
||||
<div class="card-body my-auto pb-0">
|
||||
<h5 class="card-title">@title</h5>
|
||||
@if (!String.IsNullOrWhiteSpace(description))
|
||||
{
|
||||
<p class="card-text">@Safe.Raw(description)</p>
|
||||
}
|
||||
var item = Model.Items[x];
|
||||
<div class="card" data-id="@x">
|
||||
<div class="card-body my-auto">
|
||||
<h4 class="card-title text-center">@item.Title</h4>
|
||||
<div class="w-100 mb-3 fs-5 text-center">
|
||||
@switch (item.Price.Type)
|
||||
{
|
||||
case ViewPointOfSaleViewModel.Item.ItemPrice.ItemPriceType.Topup:
|
||||
<span>Any amount</span>
|
||||
break;
|
||||
case ViewPointOfSaleViewModel.Item.ItemPrice.ItemPriceType.Minimum:
|
||||
<span>@item.Price.Formatted minimum</span>
|
||||
break;
|
||||
case ViewPointOfSaleViewModel.Item.ItemPrice.ItemPriceType.Fixed:
|
||||
@item.Price.Formatted
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
</div>
|
||||
@if (!item.Inventory.HasValue || item.Inventory.Value > 0)
|
||||
{
|
||||
if (supported != null)
|
||||
{
|
||||
var lnurlEndpoint = new Uri(Url.Action("GetLNURLForApp", "LNURL", new
|
||||
{
|
||||
cryptoCode = supported.CryptoCode,
|
||||
appid = Model.AppId,
|
||||
ItemCode = item.Id
|
||||
}, Context.Request.Scheme, Context.Request.Host.ToString()));
|
||||
var lnUrl = LNURL.EncodeUri(lnurlEndpoint, "payRequest", supported.UseBech32Scheme);
|
||||
<vc:qr-code data="@lnUrl.ToString().ToUpperInvariant()" />
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user