PoS: Fix images in cart view (#2649)

Fixes an issue I overlooked in #2449 and which was brought up by @dstrukt [on Mattermost](https://chat.btcpayserver.org/btcpayserver/pl/jzxqs7xw33rjfe5itorxygifbe).
This commit is contained in:
d11n 2021-07-02 04:28:38 +02:00 committed by GitHub
parent 6e154f6cbc
commit 3800780ef2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 6 deletions

View file

@ -7,7 +7,7 @@
<script id="template-cart-item" type="text/template">
<tr data-id="{id}">
{image}
<td class="align-middle pe-0" width="1%">{image}</td>
<td class="align-middle pe-0 ps-2"><b>{title}</b></td>
<td class="align-middle px-0">
<a class="js-cart-item-remove btn btn-link" href="#"><i class="fa fa-trash text-muted"></i></a>
@ -26,7 +26,7 @@
</script>
<script id="template-cart-item-image" type="text/template">
<td class="align-middle pe-0" width="1%"><img src="{image}" width="50" alt=""></td>
<img src="{image}" width="50" alt="">
</script>
<script id="template-cart-custom-amount" type="text/template">
@ -219,9 +219,9 @@
var description = item.Description;
<div class="js-add-cart card px-0 card-wrapper" data-index="@index">
@if (!String.IsNullOrWhiteSpace(image))
@if (!string.IsNullOrWhiteSpace(image))
{
@:<img class="card-img-top" src="@image" alt="Card image cap" asp-append-version="true">
<img class="card-img-top" src="@image" alt="@item.Title" asp-append-version="true">
}
<div class="card-body p-3">
<h6 class="card-title mb-0">@item.Title</h6>

View file

@ -425,7 +425,11 @@ Cart.prototype.listItems = function() {
// Prepare the list of items in the cart
for (var key in this.content) {
var item = this.content[key],
image = this.escape(item.image);
image = item.image && this.escape(item.image);
if (image && image.startsWith("~")) {
image = image.replace('~', window.location.pathname.substring(0, image.indexOf('/apps')));
}
tableTemplate = this.template($('#template-cart-item'), {
'id': this.escape(item.id),
@ -475,7 +479,7 @@ Cart.prototype.listItems = function() {
id: id,
title: item.title,
price: item.price,
image: typeof item.image != 'underfined' ? item.image : null
image: item.image
});
}
} else if (!qtyIncreased) { // Quantity decreased