Show units next to [No Stock]-badge in part search (implements #4330) (#4339)

This commit is contained in:
simonkuehling 2023-02-13 21:00:53 +01:00 committed by GitHub
parent 2fbbce1550
commit d5459e5ddf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -617,7 +617,12 @@ function partStockLabel(part, options={}) {
return `<span class='badge rounded-pill bg-info ${options.classes}'>{% trans "Building" %}: ${part.building} ${units}</span>`;
} else {
// There is no stock
return `<span class='badge rounded-pill bg-danger ${options.classes}'>{% trans "No Stock" %}</span>`;
var unit_badge = '';
if (units) {
// show units next to [No Stock] badge
unit_badge = `<span class='badge rounded-pill text-muted bg-muted ${options.classes}'>{% trans "Unit" %}: ${units}</span> `;
}
return `${unit_badge}<span class='badge rounded-pill bg-danger ${options.classes}'>{% trans "No Stock" %}</span>`;
}
}