fixed capitolato riferimento
This commit is contained in:
parent
0f0c6a04b7
commit
f3e5cb4ffd
@ -20,8 +20,7 @@
|
|||||||
</button>
|
</button>
|
||||||
|
|
||||||
|
|
||||||
<input type="checkbox" id="showMixParts" name="showMixParts" style="margin-right: 5px; margin-left: 10px;">
|
|
||||||
<label for="showMixParts" style="font-size: 0.9rem; margin-right: 10px;">Mix</label>
|
|
||||||
|
|
||||||
<button type="button" class="btn btn-info btn-sm" id="renumberPartsBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;">
|
<button type="button" class="btn btn-info btn-sm" id="renumberPartsBtn" style="padding: 0.1rem 0.5rem; font-size: 0.8rem;">
|
||||||
Rinumera Parti
|
Rinumera Parti
|
||||||
@ -593,5 +592,130 @@
|
|||||||
max-width: 100% !important;
|
max-width: 100% !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Propagation control for dynamic extra field column */
|
||||||
|
#partsTable th.extra-field-th {
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
#partsTable th.extra-field-th .extra-propagate-wrapper {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#partsTable th.extra-field-th .extra-propagate-label {
|
||||||
|
font-size: 0.75rem;
|
||||||
|
font-weight: 600;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
max-width: 95px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#partsTable th.extra-field-th .extra-propagate-input,
|
||||||
|
#partsTable th.extra-field-th .extra-propagate-select {
|
||||||
|
height: 24px !important;
|
||||||
|
font-size: 0.75rem !important;
|
||||||
|
padding: 0.1rem 0.25rem !important;
|
||||||
|
min-width: 90px;
|
||||||
|
flex: 1 1 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
#partsTable th.extra-field-th .extra-propagate-btn {
|
||||||
|
height: 24px;
|
||||||
|
min-width: 26px;
|
||||||
|
padding: 0.1rem 0.3rem !important;
|
||||||
|
font-size: 0.75rem !important;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
#partsTable th.extra-field-th .select2-container {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-width: 90px;
|
||||||
|
max-width: 100% !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#partsTable th.extra-field-th .select2-selection--single {
|
||||||
|
height: 24px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#partsTable th.extra-field-th .select2-selection__rendered {
|
||||||
|
line-height: 22px !important;
|
||||||
|
font-size: 0.75rem !important;
|
||||||
|
padding-left: 4px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#partsTable th.extra-field-th .select2-selection__arrow {
|
||||||
|
height: 22px !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Extra field propagation header - full column width */
|
||||||
|
#partsTable th.extra-field-th {
|
||||||
|
width: auto !important;
|
||||||
|
min-width: 220px !important;
|
||||||
|
max-width: none !important;
|
||||||
|
padding: 0.25rem !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#partsTable .extra-propagate-wrapper {
|
||||||
|
width: 100% !important;
|
||||||
|
min-width: 100% !important;
|
||||||
|
max-width: 100% !important;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 4px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
#partsTable .extra-propagate-label {
|
||||||
|
width: 100% !important;
|
||||||
|
max-width: 100% !important;
|
||||||
|
display: block;
|
||||||
|
font-size: 0.82rem;
|
||||||
|
font-weight: 700;
|
||||||
|
line-height: 1.15;
|
||||||
|
color: #222;
|
||||||
|
white-space: nowrap !important;
|
||||||
|
overflow: visible !important;
|
||||||
|
text-overflow: unset !important;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
#partsTable .extra-propagate-control {
|
||||||
|
width: 100% !important;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 5px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
#partsTable .extra-propagate-control .extra-propagate-input,
|
||||||
|
#partsTable .extra-propagate-control .extra-propagate-select {
|
||||||
|
flex: 1 1 auto !important;
|
||||||
|
width: 100% !important;
|
||||||
|
min-width: 0 !important;
|
||||||
|
max-width: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#partsTable .extra-propagate-control .select2-container {
|
||||||
|
flex: 1 1 auto !important;
|
||||||
|
width: 100% !important;
|
||||||
|
min-width: 0 !important;
|
||||||
|
max-width: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#partsTable .extra-propagate-control .select2-selection {
|
||||||
|
width: 100% !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
#partsTable .extra-propagate-btn {
|
||||||
|
flex: 0 0 30px !important;
|
||||||
|
width: 30px !important;
|
||||||
|
height: 24px !important;
|
||||||
|
min-width: 30px !important;
|
||||||
|
padding: 0.1rem 0.25rem !important;
|
||||||
|
}
|
||||||
|
|
||||||
/* rosso */
|
/* rosso */
|
||||||
</style>
|
</style>
|
||||||
@ -107,8 +107,45 @@ $(document).ready(function () {
|
|||||||
if (!partsExtraField) return "";
|
if (!partsExtraField) return "";
|
||||||
|
|
||||||
const selectedValueId = $row ? $row.data("extra-value-id") || "" : "";
|
const selectedValueId = $row ? $row.data("extra-value-id") || "" : "";
|
||||||
|
const selectedValueText = $row
|
||||||
|
? $row.data("extra-value-text") || ""
|
||||||
|
: "";
|
||||||
|
|
||||||
// SceltaMultipla -> select + hidden value id
|
// SceltaMultipla -> select + hidden value id
|
||||||
|
if (
|
||||||
|
(partsExtraField.data_type || "").toLowerCase() === "sceltamultipla"
|
||||||
|
) {
|
||||||
|
const opts = [`<option value="">Select…</option>`]
|
||||||
|
.concat(
|
||||||
|
extraFieldOptions.map(
|
||||||
|
(o) =>
|
||||||
|
`<option value="${o.id}" ${String(o.id) === String(selectedValueId) ? "selected" : ""}>${o.label}</option>`,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
.join("");
|
||||||
|
|
||||||
|
return `
|
||||||
|
<td class="extra-field-td" style="width:200px;">
|
||||||
|
<input type="hidden" class="part-extra-field-id" value="${partsExtraField.field_id}">
|
||||||
|
<input type="hidden" class="part-extra-value-id" value="${selectedValueId || ""}">
|
||||||
|
<select class="form-control form-control-sm part-extra-select" data-selected="${selectedValueId || ""}">${opts}</select>
|
||||||
|
</td>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Testo -> input + hidden field_id
|
||||||
|
return `
|
||||||
|
<td class="extra-field-td" style="width:200px;">
|
||||||
|
<input type="hidden" class="part-extra-field-id" value="${partsExtraField.field_id}">
|
||||||
|
<input type="text" class="form-control form-control-sm part-extra-field" data-type="${partsExtraField.data_type || ""}" value="${selectedValueText || ""}">
|
||||||
|
</td>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildExtraFieldHeaderHtml() {
|
||||||
|
if (!partsExtraField) return "";
|
||||||
|
|
||||||
|
const label = partsExtraField.field_label || "Extra";
|
||||||
|
|
||||||
|
// SceltaMultipla: titolo sopra, select + bottone sotto
|
||||||
if (
|
if (
|
||||||
(partsExtraField.data_type || "").toLowerCase() === "sceltamultipla"
|
(partsExtraField.data_type || "").toLowerCase() === "sceltamultipla"
|
||||||
) {
|
) {
|
||||||
@ -121,19 +158,38 @@ $(document).ready(function () {
|
|||||||
.join("");
|
.join("");
|
||||||
|
|
||||||
return `
|
return `
|
||||||
<td class="extra-field-td" style="width:200px;">
|
<th class="extra-field-th">
|
||||||
<input type="hidden" class="part-extra-field-id" value="${partsExtraField.field_id}">
|
<div class="extra-propagate-wrapper">
|
||||||
<input type="hidden" class="part-extra-value-id" value="">
|
<div class="extra-propagate-label" title="${label}">
|
||||||
<select class="form-control form-control-sm part-extra-select" data-selected="${selectedValueId || ""}">${opts}</select>
|
${label}
|
||||||
</td>`;
|
</div>
|
||||||
|
<div class="extra-propagate-control">
|
||||||
|
<select class="form-control form-control-sm extra-propagate-select">
|
||||||
|
${opts}
|
||||||
|
</select>
|
||||||
|
<button type="button" class="btn btn-primary btn-sm extra-propagate-btn" title="Propaga a tutte le parti">
|
||||||
|
<i class="fas fa-arrow-down"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</th>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Testo -> input + hidden field_id
|
// Campo testo: titolo sopra, input + bottone sotto
|
||||||
return `
|
return `
|
||||||
<td class="extra-field-td" style="width:200px;">
|
<th class="extra-field-th">
|
||||||
<input type="hidden" class="part-extra-field-id" value="${partsExtraField.field_id}">
|
<div class="extra-propagate-wrapper">
|
||||||
<input type="text" class="form-control form-control-sm part-extra-field" data-type="${partsExtraField.data_type || ""}">
|
<div class="extra-propagate-label" title="${label}">
|
||||||
</td>`;
|
${label}
|
||||||
|
</div>
|
||||||
|
<div class="extra-propagate-control">
|
||||||
|
<input type="text" class="form-control form-control-sm extra-propagate-input" placeholder="Value">
|
||||||
|
<button type="button" class="btn btn-primary btn-sm extra-propagate-btn" title="Propaga a tutte le parti">
|
||||||
|
<i class="fas fa-arrow-down"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</th>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function initializeExtraFieldSelect2($context) {
|
function initializeExtraFieldSelect2($context) {
|
||||||
@ -191,6 +247,79 @@ $(document).ready(function () {
|
|||||||
saveRow($row);
|
saveRow($row);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$(document).on("click", ".extra-propagate-btn", function (e) {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
if (!partsExtraField) return;
|
||||||
|
|
||||||
|
const isSelect =
|
||||||
|
(partsExtraField.data_type || "").toLowerCase() ===
|
||||||
|
"sceltamultipla";
|
||||||
|
|
||||||
|
let propagateValueId = null;
|
||||||
|
let propagateValueText = null;
|
||||||
|
|
||||||
|
if (isSelect) {
|
||||||
|
propagateValueId =
|
||||||
|
$("#partsTable thead .extra-propagate-select").val() || "";
|
||||||
|
|
||||||
|
if (!propagateValueId) {
|
||||||
|
const errorMsg = $(
|
||||||
|
'<div class="alert alert-warning temp-alert" role="alert">Seleziona un valore da propagare.</div>',
|
||||||
|
);
|
||||||
|
$("#partsModal .modal-body").prepend(errorMsg);
|
||||||
|
setTimeout(() => {
|
||||||
|
errorMsg.fadeOut(500, function () {
|
||||||
|
$(this).remove();
|
||||||
|
});
|
||||||
|
}, 3500);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
propagateValueText = (
|
||||||
|
$("#partsTable thead .extra-propagate-input").val() || ""
|
||||||
|
).trim();
|
||||||
|
|
||||||
|
if (!propagateValueText) {
|
||||||
|
const errorMsg = $(
|
||||||
|
'<div class="alert alert-warning temp-alert" role="alert">Inserisci un valore da propagare.</div>',
|
||||||
|
);
|
||||||
|
$("#partsModal .modal-body").prepend(errorMsg);
|
||||||
|
setTimeout(() => {
|
||||||
|
errorMsg.fadeOut(500, function () {
|
||||||
|
$(this).remove();
|
||||||
|
});
|
||||||
|
}, 3500);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#partsTableBody tr").each(function () {
|
||||||
|
const $row = $(this);
|
||||||
|
|
||||||
|
if (isSelect) {
|
||||||
|
const $select = $row.find(".part-extra-select");
|
||||||
|
|
||||||
|
if ($select.length) {
|
||||||
|
$select.val(propagateValueId).trigger("change.select2");
|
||||||
|
|
||||||
|
$row.data("extra-value-id", propagateValueId);
|
||||||
|
$row.find(".part-extra-value-id").val(propagateValueId);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const $input = $row.find(".part-extra-field");
|
||||||
|
|
||||||
|
if ($input.length) {
|
||||||
|
$input.val(propagateValueText);
|
||||||
|
|
||||||
|
$row.data("extra-value-text", propagateValueText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
saveRow($row);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
function applyExtraFieldColumn() {
|
function applyExtraFieldColumn() {
|
||||||
const $theadRow = $("#partsTable thead tr");
|
const $theadRow = $("#partsTable thead tr");
|
||||||
|
|
||||||
@ -203,16 +332,17 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 3) se non c'è campo extra -> fine
|
// 3) se non c'è campo extra -> fine
|
||||||
if (!partsExtraField) return;
|
if (!partsExtraField) {
|
||||||
|
if (typeof window.applyPartsColumnWidths === "function") {
|
||||||
|
setTimeout(window.applyPartsColumnWidths, 100);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 4) inserisci header prima di "Azioni" (ultima colonna)
|
// 4) inserisci header propagabile prima di "Azioni" ultima colonna
|
||||||
$theadRow
|
$theadRow.find("th:last").before(buildExtraFieldHeaderHtml());
|
||||||
.find("th:last")
|
|
||||||
.before(
|
|
||||||
`<th class="extra-field-th" style="width:200px;">${partsExtraField.field_label}</th>`,
|
|
||||||
);
|
|
||||||
|
|
||||||
// 5) aggiungi cella a ogni riga già presente (una sola volta)
|
// 5) aggiungi cella a ogni riga già presente
|
||||||
$("#partsTableBody tr").each(function () {
|
$("#partsTableBody tr").each(function () {
|
||||||
const $row = $(this);
|
const $row = $(this);
|
||||||
$row.find("td:last").before(buildExtraFieldCellHtml($row));
|
$row.find("td:last").before(buildExtraFieldCellHtml($row));
|
||||||
@ -225,6 +355,33 @@ $(document).ready(function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
initializeExtraFieldSelect2($("#partsTableBody"));
|
initializeExtraFieldSelect2($("#partsTableBody"));
|
||||||
|
|
||||||
|
// Select2 anche sul campo di propagazione in testata
|
||||||
|
if (
|
||||||
|
(partsExtraField.data_type || "").toLowerCase() === "sceltamultipla"
|
||||||
|
) {
|
||||||
|
const $headerSelect = $(
|
||||||
|
"#partsTable thead .extra-propagate-select",
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($headerSelect.length && typeof $.fn.select2 !== "undefined") {
|
||||||
|
if ($headerSelect.hasClass("select2-hidden-accessible")) {
|
||||||
|
$headerSelect.select2("destroy");
|
||||||
|
}
|
||||||
|
|
||||||
|
$headerSelect.select2({
|
||||||
|
placeholder: "Select…",
|
||||||
|
allowClear: true,
|
||||||
|
width: "100%",
|
||||||
|
dropdownParent: $("#partsModal"),
|
||||||
|
minimumResultsForSearch: 0,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof window.applyPartsColumnWidths === "function") {
|
||||||
|
setTimeout(window.applyPartsColumnWidths, 100);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPartId($row, id) {
|
function setPartId($row, id) {
|
||||||
@ -971,7 +1128,7 @@ $(document).ready(function () {
|
|||||||
// Raccogli tutti i dati della riga per evitare sovrascritture
|
// Raccogli tutti i dati della riga per evitare sovrascritture
|
||||||
const partNumber = $row.find(".part-number").val();
|
const partNumber = $row.find(".part-number").val();
|
||||||
const partDescription = $row.find(".part-description").val().trim();
|
const partDescription = $row.find(".part-description").val().trim();
|
||||||
const mix = partDescription.startsWith("Mix") ? "Y" : "N";
|
const mix = getRowMix($row);
|
||||||
const idmatrice = $row.find(".part-matrice").val() || null;
|
const idmatrice = $row.find(".part-matrice").val() || null;
|
||||||
const dateexpiry = $row.find(".part-dateexpiry").val() || null;
|
const dateexpiry = $row.find(".part-dateexpiry").val() || null;
|
||||||
|
|
||||||
@ -1070,7 +1227,7 @@ $(document).ready(function () {
|
|||||||
// Raccogli tutti i dati della riga per evitare sovrascritture
|
// Raccogli tutti i dati della riga per evitare sovrascritture
|
||||||
const partNumber = $row.find(".part-number").val();
|
const partNumber = $row.find(".part-number").val();
|
||||||
const partDescription = $row.find(".part-description").val().trim();
|
const partDescription = $row.find(".part-description").val().trim();
|
||||||
const mix = partDescription.startsWith("Mix") ? "Y" : "N";
|
const mix = getRowMix($row);
|
||||||
const idmatrice = $row.find(".part-matrice").val() || null;
|
const idmatrice = $row.find(".part-matrice").val() || null;
|
||||||
const note = $row.data("note") || null;
|
const note = $row.data("note") || null;
|
||||||
|
|
||||||
@ -1440,6 +1597,19 @@ $(document).ready(function () {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
part.extra_value_text !== undefined &&
|
||||||
|
part.extra_value_text !== null
|
||||||
|
) {
|
||||||
|
$row.data(
|
||||||
|
"extra-value-text",
|
||||||
|
part.extra_value_text,
|
||||||
|
);
|
||||||
|
$row.find(".part-extra-field").val(
|
||||||
|
part.extra_value_text,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
initializeExtraFieldSelect2($row);
|
initializeExtraFieldSelect2($row);
|
||||||
|
|
||||||
const $select = $("#partsTableBody").find(
|
const $select = $("#partsTableBody").find(
|
||||||
@ -2481,7 +2651,7 @@ $(document).on("click", "#showHideImageBtn", function () {
|
|||||||
// ===================
|
// ===================
|
||||||
(function () {
|
(function () {
|
||||||
// Larghezze default per indice colonna (0-based)
|
// Larghezze default per indice colonna (0-based)
|
||||||
const defaultWidths = [55, 320, 360, 150, 230];
|
const defaultWidths = [55, 320, 360, 150, 220, 230];
|
||||||
const savedWidths = [...defaultWidths];
|
const savedWidths = [...defaultWidths];
|
||||||
|
|
||||||
function getColgroup() {
|
function getColgroup() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user