fixed Mix
This commit is contained in:
@@ -235,6 +235,17 @@ $(document).ready(function () {
|
||||
$row.data("__pid", id);
|
||||
}
|
||||
|
||||
function setRowMix($row, isMix) {
|
||||
const mixValue = isMix === true || isMix === "Y" ? "Y" : "N";
|
||||
$row.attr("data-is-mix", mixValue);
|
||||
$row.data("is-mix", mixValue);
|
||||
}
|
||||
|
||||
function getRowMix($row) {
|
||||
const value = $row.attr("data-is-mix") || $row.data("is-mix");
|
||||
return value === "Y" ? "Y" : "N";
|
||||
}
|
||||
|
||||
// ===================
|
||||
// VOICE RECOGNITION SETUP
|
||||
// ===================
|
||||
@@ -698,7 +709,7 @@ $(document).ready(function () {
|
||||
const $saveLoading = $row.find(".save-loading");
|
||||
const iddatadb = $("#partsModal").data("iddatadb");
|
||||
const idquotations = $("#partsModal").data("idquotations");
|
||||
const isMix = partDescription.startsWith("Mix") ? "Y" : "N";
|
||||
const isMix = getRowMix($row);
|
||||
|
||||
// EXTRA FIELD (0/1)
|
||||
const extra_field_id = $row.find(".part-extra-field-id").val() || null;
|
||||
@@ -837,11 +848,7 @@ $(document).ready(function () {
|
||||
|
||||
let $mixRow = $("#partsTableBody tr")
|
||||
.filter(function () {
|
||||
return $(this)
|
||||
.find(".part-description")
|
||||
.val()
|
||||
.trim()
|
||||
.startsWith("Mix");
|
||||
return getRowMix($(this)) === "Y";
|
||||
})
|
||||
.last();
|
||||
|
||||
@@ -897,7 +904,7 @@ $(document).ready(function () {
|
||||
function addNewRow(nextPartNumber, isMix = false) {
|
||||
const description = isMix ? "Mix" : "";
|
||||
const newRow = `
|
||||
<tr data-part-id="new">
|
||||
<tr data-part-id="new" data-is-mix="${isMix ? "Y" : "N"}">
|
||||
<td><input type="number" class="form-control form-control-sm part-number" value="${nextPartNumber || 1}" style="width: 80px;"></td>
|
||||
<td><input type="text" class="form-control form-control-sm part-description" value="${description}" placeholder="Inserisci descrizione"></td>
|
||||
<td>
|
||||
@@ -918,6 +925,7 @@ $(document).ready(function () {
|
||||
</tr>`;
|
||||
$("#partsTableBody").append(newRow);
|
||||
const $newRow = $("#partsTableBody tr:last");
|
||||
setRowMix($newRow, isMix ? "Y" : "N");
|
||||
const $select = $newRow.find(".part-matrice");
|
||||
const selectedMacro = $("#macro-matrice-filter").val() || "";
|
||||
|
||||
@@ -1394,7 +1402,7 @@ $(document).ready(function () {
|
||||
? $("<div>").text(part.note).html()
|
||||
: "";
|
||||
const newRow = `
|
||||
<tr data-part-id="${part.id}" data-note="${escapedNote}">
|
||||
<tr data-part-id="${part.id}" data-note="${escapedNote}" data-is-mix="${part.mix === "Y" ? "Y" : "N"}">
|
||||
<td><input type="number" class="form-control form-control-sm part-number" value="${part.part_number || ""}" style="width: 80px;"></td>
|
||||
<td><input type="text" class="form-control form-control-sm part-description" value="${escapedDescription}" placeholder="Inserisci descrizione"></td>
|
||||
<td>
|
||||
@@ -1418,7 +1426,7 @@ $(document).ready(function () {
|
||||
const $row = $(
|
||||
`#partsTableBody tr[data-part-id="${part.id}"]`,
|
||||
);
|
||||
|
||||
setRowMix($row, part.mix === "Y" ? "Y" : "N");
|
||||
if (
|
||||
part.extra_value_id !== undefined &&
|
||||
part.extra_value_id !== null
|
||||
@@ -1883,7 +1891,7 @@ $(document).ready(function () {
|
||||
id: part.partId,
|
||||
part_number: index + 1,
|
||||
part_description: part.partDescription,
|
||||
mix: part.partDescription.startsWith("Mix") ? "Y" : "N",
|
||||
mix: getRowMix($rows.eq(index)),
|
||||
idmatrice: partMatrice[index + 1] || null,
|
||||
note: part.note,
|
||||
dateexpiry: part.dateexpiry,
|
||||
@@ -2238,7 +2246,7 @@ $(document).on("change", ".propagate-date-input", function () {
|
||||
const partId = $row.data("part-id");
|
||||
const partNumber = $row.find(".part-number").val();
|
||||
const partDescription = $row.find(".part-description").val().trim();
|
||||
const mix = partDescription.startsWith("Mix") ? "Y" : "N";
|
||||
const mix = $row.attr("data-is-mix") === "Y" ? "Y" : "N";
|
||||
const idmatrice = $row.find(".part-matrice").val() || null;
|
||||
const note = $row.data("note") || null;
|
||||
|
||||
@@ -2349,7 +2357,7 @@ $(document).on("click", ".save-common-note-btn", function () {
|
||||
const partId = $row.data("part-id");
|
||||
const partNumber = $row.find(".part-number").val();
|
||||
const partDescription = $row.find(".part-description").val().trim();
|
||||
const mix = partDescription.startsWith("Mix") ? "Y" : "N";
|
||||
const mix = $row.attr("data-is-mix") === "Y" ? "Y" : "N";
|
||||
const idmatrice = $row.find(".part-matrice").val() || null;
|
||||
const dateexpiry = $row.find(".part-dateexpiry").val() || null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user