Displaying low stock warning [SCI-6497] (#3912)

* Low stock warning [SCI-6497

* Fix some bugs [SCI-6497]

* Fix to long line [SCI-6497]

* Clean not needed information in renderes [SCI-6497]
This commit is contained in:
ajugo 2022-03-16 15:06:52 +01:00 committed by GitHub
parent d1610fba53
commit a89244c537
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 5 deletions

View file

@ -200,16 +200,23 @@ $.fn.dataTable.render.AssignedTasksValue = function(data, row) {
};
$.fn.dataTable.render.RepositoryStockValue = function(data) {
var stockAlertTag;
if (data) {
if (data.value) {
if (data.value.stock_amount <= 0) {
stockAlertTag = 'stock-alert';
} else {
stockAlertTag = parseFloat(data.value.stock_amount) < parseFloat(data.value.low_stock_threshold)
? 'stock-low-stock-alert' : '';
}
if (data.stock_managable) {
return `<a class="manage-repository-stock-value-link stock-value-view-render
${data.value.stock_amount <= 0 ? 'stock-alert' : ''}">
return `<a class="manage-repository-stock-value-link stock-value-view-render ${stockAlertTag}">
${data.value.stock_formatted}
</a>`;
}
return `<span class="stock-value-view-render
${data.value.stock_amount <= 0 ? 'stock-alert' : ''}">
${data.stock_managable !== undefined ? stockAlertTag : ''}">
${data.value.stock_formatted}
</span>`;
}

View file

@ -192,6 +192,23 @@
grid-area: table;
padding: 0;
}
.stock-low-stock-alert {
&::before {
@include font-awesome;
color: $brand-warning;
content: $font-fas-exclamation-triangle;
}
}
.stock-alert {
color: $brand-danger;
&::before {
@include font-awesome;
content: $font-fas-exclamation-triangle;
}
}
}
}

View file

@ -189,7 +189,7 @@
// Stock
.stock-value-view-render {
cursor: pointer;
&:hover {
text-decoration: none;
@ -203,6 +203,15 @@
content: $font-fas-exclamation-triangle;
}
}
&.stock-low-stock-alert {
&::before {
@include font-awesome;
color: $brand-warning;
content: $font-fas-exclamation-triangle;
}
}
}
.not-assigned-stock {

View file

@ -7,7 +7,8 @@ module RepositoryDatatable
def value
{
stock_formatted: object.formatted,
stock_amount: object.data
stock_amount: object.data,
low_stock_threshold: object.low_stock_threshold
}
end
end