Commit d8d04777 by Damien Moulard

cell coloring if product not available for supplier

parent a57456e8
...@@ -2,6 +2,14 @@ ...@@ -2,6 +2,14 @@
margin-top: 30px; margin-top: 30px;
} }
#products_table_filter{
text-align: right !important;
}
#products_table_filter input{
height: 50px;
}
#supplier_input { #supplier_input {
width: 500px; width: 500px;
margin-right: 10px; margin-right: 10px;
...@@ -12,6 +20,10 @@ ...@@ -12,6 +20,10 @@
width: 100px; width: 100px;
} }
.product_not_from_supplier {
background-color: #e7e9ed;
}
#suppliers_container { #suppliers_container {
display: flex; display: flex;
...@@ -39,3 +51,6 @@ ...@@ -39,3 +51,6 @@
margin-left: 5px; margin-left: 5px;
cursor: pointer; cursor: pointer;
} }
...@@ -255,14 +255,12 @@ function prepare_datatable_columns() { ...@@ -255,14 +255,12 @@ function prepare_datatable_columns() {
data: supplier_column_name(supplier), data: supplier_column_name(supplier),
title: supplier.display_name, title: supplier.display_name,
width: "8%", width: "8%",
className:"dt-body-center", className:"dt-body-center supplier_input_cell",
render: function (data, type, full) { render: function (data, type, full) {
if (data === false) { if (data === false) {
return "X"; return "X";
} else { } else {
const input_id = `product_${full.id}_supplier_${supplier.id}_qty_input`; const input_id = `product_${full.id}_supplier_${supplier.id}_qty_input`;
return `<input type="number" class="product_qty_input" id=${input_id} value=${data}>`; return `<input type="number" class="product_qty_input" id=${input_id} value=${data}>`;
} }
} }
...@@ -302,13 +300,31 @@ function display_products() { ...@@ -302,13 +300,31 @@ function display_products() {
columns: columns, columns: columns,
order: [ order: [
[ [
2, 5, // Order by default by first supplier
"asc" "asc"
] ]
], ],
dom: 'lrtip', // TODO: change DOM display? stripeClasses: [], // Remove datatable cells coloring
orderClasses: false,
iDisplayLength: 100, iDisplayLength: 100,
language: {url : '/static/js/datatables/french.json'} language: {url : '/static/js/datatables/french.json'},
createdRow: function( row, data, dataIndex ) {
for (const cell_node of row.cells) {
const cell = $(cell_node);
if (cell.hasClass("supplier_input_cell")) {
if (cell.text() == "X") {
cell.addClass( 'product_not_from_supplier' );
} else {
// TODO: supplier shortage cell coloring, when supplier shortage usecase is defined
// let val = parseFloat(cell.find('.product_qty_input').val());
// if (!isNaN(val) && val < 0) {
// cell.addClass( 'product_supplier_shortage' );
// }
}
}
}
}
}); });
$('.main').show(); $('.main').show();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment