fix(pos): broken image in item details section

This commit is contained in:
Saqib Ansari 2021-06-06 11:18:20 +05:30
parent bc46a9772d
commit 3f32969bee

View File

@ -133,13 +133,24 @@ erpnext.PointOfSale.ItemDetails = class {
this.$item_description.html(get_description_html());
this.$item_price.html(format_currency(price_list_rate, this.currency));
if (image) {
this.$item_image.html(`<img src="${image}" alt="${image}">`);
this.$item_image.html(
`<img
onerror="cur_pos.item_details.handle_broken_image(this)"
class="h-full" src="${image}"
alt="${frappe.get_abbr(item_name)}"
style="object-fit: cover;">`
);
} else {
this.$item_image.html(`<div class="item-abbr">${frappe.get_abbr(item_name)}</div>`);
}
}
handle_broken_image($img) {
const item_abbr = $($img).attr('alt');
$($img).replaceWith(`<div class="item-abbr">${item_abbr}</div>`);
}
render_discount_dom(item) {
if (item.discount_percentage) {
this.$dicount_section.html(