Bug fix for units text in part label (#4470)

- Display even if no other badges are rendered
- Fixes https://github.com/inventree/InvenTree/issues/4467
This commit is contained in:
Oliver 2023-03-08 23:18:22 +11:00 committed by GitHub
parent 2dfea9b825
commit beac7d15df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -679,19 +679,19 @@ function partStockLabel(part, options={}) {
bg_class = 'bg-success';
}
// Display units next to stock badge
let unit_badge = '';
let output = '';
// Display units next to stock badge
if (units && !options.no_units) {
unit_badge = `<span class='badge rounded-pill text-muted bg-muted ${classes}'>{% trans "Unit" %}: ${units}</span> `;
output += `<span class='badge rounded-pill text-muted bg-muted ${classes}'>{% trans "Unit" %}: ${units}</span> `;
}
if (elements.length > 0) {
let text = elements.join(' | ');
return `${unit_badge}<span class='badge rounded-pill ${bg_class} ${classes}'>${text}</span>`;
} else {
return '';
output += `<span class='badge rounded-pill ${bg_class} ${classes}'>${text}</span>`;
}
return output;
}