Add configurable options for the stockitem renderer

This commit is contained in:
Oliver 2021-10-04 17:31:38 +11:00
parent eba0d15fe4
commit 49dc88abbc
3 changed files with 24 additions and 5 deletions

View File

@ -1168,7 +1168,7 @@ function addSecondaryModal(field, fields, options) {
/*
* Initializea single related-field
* Initialize a single related-field
*
* argument:
* - modal: DOM identifier for the modal window

View File

@ -65,7 +65,7 @@ function imageHoverIcon(url) {
function thumbnailImage(url) {
if (!url) {
url = '/static/img/blank_img.png';
url = blankImage();
}
// TODO: Support insertion of custom classes

View File

@ -49,9 +49,18 @@ function renderStockItem(name, data, parameters, options) {
var image = data.part_detail.thumbnail || data.part_detail.image || blankImage();
var html = `<img src='${image}' class='select2-thumbnail'>`;
var html = '';
var render_part_detail = true;
if ("render_part_detail" in parameters) {
render_part_detail = parameters["render_part_detail"];
}
if (render_part_detail) {
html += `<img src='${image}' class='select2-thumbnail'>`;
html += ` <span>${data.part_detail.full_name || data.part_detail.name}</span>`;
}
if (data.serial && data.quantity == 1) {
html += ` - <i>{% trans "Serial Number" %}: ${data.serial}`;
@ -59,10 +68,20 @@ function renderStockItem(name, data, parameters, options) {
html += ` - <i>{% trans "Quantity" %}: ${data.quantity}`;
}
if (data.part_detail.description) {
if (render_part_detail && data.part_detail.description) {
html += `<p><small>${data.part_detail.description}</small></p>`;
}
var render_location_detail = false;
if ("render_location_detail" in parameters) {
render_location_detail = parameters["render_location_detail"];
}
if (render_location_detail && data.location_detail) {
html += `<p><small>${data.location_detail.pathstring}</small></p>`;
}
return html;
}