From 5d8360dd8796994226d461b9e6ec9c12b810327c Mon Sep 17 00:00:00 2001 From: solocla Date: Wed, 29 Oct 2025 12:32:09 +0100 Subject: [PATCH] marker with size --- public/userarea/annotationsModal.js | 151 ++++++++++++-------------- public/userarea/modal_annotations.php | 49 ++++++++- public/userarea/quotations.php | 56 ++++++++-- 3 files changed, 158 insertions(+), 98 deletions(-) diff --git a/public/userarea/annotationsModal.js b/public/userarea/annotationsModal.js index 05e4dc3..15bdb4b 100644 --- a/public/userarea/annotationsModal.js +++ b/public/userarea/annotationsModal.js @@ -18,6 +18,8 @@ $(document).ready(function () { let descriptionTextbox = null; let markerObjects = {}; let partsListData = []; + // DIMENSIONE GLOBALE MARKER + let globalMarkerSize = 24; // =================== // MODAL INITIALIZATION @@ -67,6 +69,9 @@ $(document).ready(function () { }); } modal.show(); + // Inizializza slider dimensione marker + $("#markerSizeSlider").val(globalMarkerSize); + $("#markerSizeValue").text(globalMarkerSize + "px"); // Debug: Verifica presenza elementi DOM console.log( @@ -128,6 +133,7 @@ $(document).ready(function () { } descriptionTextbox = null; markerObjects = {}; + globalMarkerSize = 24; $("#photoSelectorContainerAnnotations").empty().hide(); $("#samplePhotoAnnotations").attr("src", ""); $("#partsListAnnotations").empty(); @@ -144,6 +150,16 @@ $(document).ready(function () { $(":focus").blur(); }); + // SLIDER DIMENSIONE MARKER + $(document) + .off("input", "#markerSizeSlider") + .on("input", "#markerSizeSlider", function () { + globalMarkerSize = parseInt($(this).val()); + $("#markerSizeValue").text(globalMarkerSize + "px"); + updateMarkers(); + markUnsaved(); + }); + // =================== // PHOTO LOADERS // =================== @@ -465,113 +481,80 @@ $(document).ready(function () { ); // =================== - // BACK TO PARTS MODAL + // TORNA AL MODALE PARTI (modal_partsTable.php) // =================== $(document) .off("click.backToParts", "#backToPartsBtnAnnotations") .on("click.backToParts", "#backToPartsBtnAnnotations", function (e) { e.preventDefault(); e.stopPropagation(); - console.log( - "Evento click su #backToPartsBtnAnnotations, ID elemento:", - $(this).attr("id"), - ); - if (!$("#backToPartsBtnAnnotations").length) { - console.error( - "Pulsante #backToPartsBtnAnnotations non trovato nel DOM.", - ); - const errorMsg = $( - '', - ); - $("#annotationsModal .modal-body").prepend(errorMsg); - setTimeout(function () { - errorMsg.fadeOut(500, function () { - $(this).remove(); - }); - }, 5000); - return; - } - // Controlla modifiche non salvate if ( unsavedChanges && !confirm( "Hai modifiche non salvate. Vuoi davvero tornare al modale delle parti?", ) ) { - console.log( - "Tornare al modale delle parti annullato a causa di modifiche non salvate.", - ); return; } - // Chiudi annotationsModal - const annotationsModalElement = - document.getElementById("annotationsModal"); - const annotationsModal = bootstrap.Modal.getInstance( - annotationsModalElement, - ); - if (annotationsModal) { - annotationsModal.hide(); - } else { - console.error( - "Impossibile trovare l'istanza del modale #annotationsModal.", - ); - } - - // Apri partsModal const iddatadb = $("#annotationsModal").data("iddatadb"); const idquotations = $("#annotationsModal").data("idquotations"); const trfHeader = $("#trfHeaderAnnotations").text(); - console.log("Apertura partsModal con:", { + + // CHIUDI MODALE ANNOTAZIONI IN MODO SICURO + const annotationsModalElement = + document.getElementById("annotationsModal"); + if (annotationsModalElement) { + const modalInstance = bootstrap.Modal.getInstance( + annotationsModalElement, + ); + if (modalInstance) { + modalInstance.hide(); + } else { + $(annotationsModalElement).modal("hide"); // fallback jQuery + } + } + console.log("Torno a modal_partsTable.php con:", { iddatadb, idquotations, trfHeader, }); + // CARICA E APRI MODALE PARTI + $.get( + "modal_partsTable.php", + { + iddatadb: iddatadb || "", + idquotations: idquotations || "", + trfHeader: trfHeader, + }, + function (data) { + // Rimuovi vecchio modale (con ID corretto) + $("#partsTableModal").remove(); + $(".modal-backdrop").remove(); - const partsModalElement = document.getElementById("partsModal"); - if (!partsModalElement) { - console.error("Elemento #partsModal non trovato nel DOM."); - const errorMsg = $( - '', + // Aggiungi nuovo modale + $("body").append(data); + + // Apri con Bootstrap 5 + const partsModalElement = + document.getElementById("partsTableModal"); + if (partsModalElement) { + const modal = new bootstrap.Modal(partsModalElement, { + backdrop: true, + keyboard: true, + focus: true, + }); + modal.show(); + } + }, + ).fail(function (xhr) { + console.error("Errore caricamento modale parti:", xhr); + alert( + "Errore 404: modal_partsTable.php non trovato o errore server.", ); - $("#annotationsModal .modal-body").prepend(errorMsg); - setTimeout(function () { - errorMsg.fadeOut(500, function () { - $(this).remove(); - }); - }, 5000); - return; - } - - let partsModal = bootstrap.Modal.getInstance(partsModalElement); - if (!partsModal) { - partsModal = new bootstrap.Modal(partsModalElement, { - backdrop: true, - keyboard: true, - focus: true, - }); - } - - // Inizializza il modale delle parti - if (typeof window.initPartsModal === "function") { - window.initPartsModal(iddatadb, idquotations, trfHeader); - partsModal.show(); - console.log("partsModal aperto con successo."); - } else { - console.error("Funzione initPartsModal non definita."); - const errorMsg = $( - '', - ); - $("#annotationsModal .modal-body").prepend(errorMsg); - setTimeout(function () { - errorMsg.fadeOut(500, function () { - $(this).remove(); - }); - }, 5000); - } + }); }); - // =================== // PARTS LIST // =================== @@ -892,8 +875,8 @@ $(document).ready(function () { return; } - const radius = 12; - const fontSize = 16; + const radius = globalMarkerSize / 2; + const fontSize = Math.max(10, Math.round(globalMarkerSize * 0.65)); const markerColor = marker.color || partColors[marker.partNumber] || "#ff0000"; @@ -1013,7 +996,7 @@ $(document).ready(function () { scaleY: 1, backgroundColor: "transparent", fontFamily: "Arial", - fontSize: 24, + fontSize: Math.max(16, Math.round(globalMarkerSize * 0.8)), fill: "#000000", padding: 10, editable: false, diff --git a/public/userarea/modal_annotations.php b/public/userarea/modal_annotations.php index 85203c7..fcc66e6 100644 --- a/public/userarea/modal_annotations.php +++ b/public/userarea/modal_annotations.php @@ -1,14 +1,23 @@