added fiel tecnici tags additional 2 and fixed menu
This commit is contained in:
+131
-6
@@ -577,6 +577,60 @@ function revisionLabel($rev)
|
||||
background: #6f42c1;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.attachments-existing-list .attachment-existing-row.is-ciclo:not(.is-disegno) {
|
||||
border: 2px solid #0f9d77;
|
||||
background: #effaf6;
|
||||
}
|
||||
|
||||
.attachments-existing-list .attachment-existing-row.is-strumento:not(.is-disegno):not(.is-ciclo) {
|
||||
border: 2px solid #fd7e14;
|
||||
background: #fff6ee;
|
||||
}
|
||||
|
||||
.badge-strumento,
|
||||
.badge-ciclo {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
color: #fff;
|
||||
font-size: .78rem;
|
||||
font-weight: 700;
|
||||
padding: 4px 9px;
|
||||
border-radius: 999px;
|
||||
margin-left: 6px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.badge-strumento {
|
||||
background: #fd7e14;
|
||||
}
|
||||
|
||||
.badge-ciclo {
|
||||
background: #0f9d77;
|
||||
}
|
||||
|
||||
.btn-toggle-strumento {
|
||||
border-color: #fd7e14;
|
||||
color: #fd7e14;
|
||||
}
|
||||
|
||||
.btn-toggle-strumento:hover,
|
||||
.btn-toggle-strumento.active {
|
||||
background: #fd7e14;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.btn-toggle-ciclo {
|
||||
border-color: #0f9d77;
|
||||
color: #0f9d77;
|
||||
}
|
||||
|
||||
.btn-toggle-ciclo:hover,
|
||||
.btn-toggle-ciclo.active {
|
||||
background: #0f9d77;
|
||||
color: #fff;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
@@ -1175,9 +1229,11 @@ function revisionLabel($rev)
|
||||
return;
|
||||
}
|
||||
|
||||
const list = (data.attachments || []).sort((a, b) =>
|
||||
(parseInt(b.is_disegno, 10) || 0) - (parseInt(a.is_disegno, 10) || 0)
|
||||
);
|
||||
const flagScore = x =>
|
||||
(parseInt(x.is_disegno, 10) || 0) * 4 +
|
||||
(parseInt(x.is_ciclo, 10) || 0) * 2 +
|
||||
(parseInt(x.is_strumento, 10) || 0);
|
||||
const list = (data.attachments || []).sort((a, b) => flagScore(b) - flagScore(a));
|
||||
const container = $("#existingAttachmentsList");
|
||||
container.empty();
|
||||
|
||||
@@ -1196,6 +1252,8 @@ function revisionLabel($rev)
|
||||
const createdAt = item.created_at || '';
|
||||
const id = item.id || 0;
|
||||
const isDisegno = (parseInt(item.is_disegno, 10) || 0) === 1;
|
||||
const isStrumento = (parseInt(item.is_strumento, 10) || 0) === 1;
|
||||
const isCiclo = (parseInt(item.is_ciclo, 10) || 0) === 1;
|
||||
|
||||
const previewHtml = isImageExt(ext) && filePath ?
|
||||
`<img src="${escapeHtml(filePath)}" class="attachment-preview-thumb" alt="">` :
|
||||
@@ -1221,7 +1279,7 @@ function revisionLabel($rev)
|
||||
}
|
||||
|
||||
const html = `
|
||||
<div class="attachment-existing-row ${isDisegno ? 'is-disegno' : ''}">
|
||||
<div class="attachment-existing-row ${isDisegno ? 'is-disegno' : ''} ${isCiclo ? 'is-ciclo' : ''} ${isStrumento ? 'is-strumento' : ''}">
|
||||
<div class="d-flex gap-3 align-items-start">
|
||||
<div>${previewHtml}</div>
|
||||
|
||||
@@ -1230,7 +1288,9 @@ function revisionLabel($rev)
|
||||
<div>
|
||||
<div class="attachment-meta-title">
|
||||
${escapeHtml(fileName)}
|
||||
${isDisegno ? '<span class="badge-disegno"><i class="fa-solid fa-compass-drafting"></i> Disegno tecnico</span>' : ''}
|
||||
${isDisegno ? '<span class="badge-disegno"><i class="fa-solid fa-compass-drafting"></i> Disegno tecnico</span>' : ''}
|
||||
${isStrumento ? '<span class="badge-strumento"><i class="fa-solid fa-screwdriver-wrench"></i> Strumento di lavoro</span>' : ''}
|
||||
${isCiclo ? '<span class="badge-ciclo"><i class="fa-solid fa-arrows-rotate"></i> Ciclo di lavoro</span>' : ''}
|
||||
</div>
|
||||
<div class="attachment-meta-sub">${badge} ${createdAt ? ' • ' + escapeHtml(createdAt) : ''}</div>
|
||||
</div>
|
||||
@@ -1241,9 +1301,25 @@ function revisionLabel($rev)
|
||||
class="btn btn-sm btn-toggle-disegno toggle-disegno ${isDisegno ? 'active' : ''}"
|
||||
data-id="${id}"
|
||||
data-value="${isDisegno ? 1 : 0}"
|
||||
title="${isDisegno ? 'Togli da disegni tecnici' : 'Segna come disegno tecnico'}">
|
||||
title="${isDisegno ? 'Togli da disegni tecnici' : 'Segna come disegno tecnico'}">
|
||||
<i class="fa-solid fa-compass-drafting"></i>
|
||||
</button>
|
||||
<button type="button"
|
||||
class="btn btn-sm btn-toggle-strumento toggle-flag ${isStrumento ? 'active' : ''}"
|
||||
data-id="${id}"
|
||||
data-field="is_strumento"
|
||||
data-value="${isStrumento ? 1 : 0}"
|
||||
title="${isStrumento ? 'Togli da strumenti di lavoro' : 'Segna come strumento di lavoro'}">
|
||||
<i class="fa-solid fa-screwdriver-wrench"></i>
|
||||
</button>
|
||||
<button type="button"
|
||||
class="btn btn-sm btn-toggle-ciclo toggle-flag ${isCiclo ? 'active' : ''}"
|
||||
data-id="${id}"
|
||||
data-field="is_ciclo"
|
||||
data-value="${isCiclo ? 1 : 0}"
|
||||
title="${isCiclo ? 'Togli da cicli di lavoro' : 'Segna come ciclo di lavoro'}">
|
||||
<i class="fa-solid fa-arrows-rotate"></i>
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-danger delete-existing-file" data-id="${id}">Elimina</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1820,6 +1896,55 @@ function revisionLabel($rev)
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", ".toggle-flag", function() {
|
||||
const $btn = $(this);
|
||||
const id = $btn.data("id");
|
||||
const field = $btn.data("field");
|
||||
const newValue = parseInt($btn.data("value"), 10) === 1 ? 0 : 1;
|
||||
const idmatrice = $("#mf_idmatrice").val();
|
||||
|
||||
$btn.prop("disabled", true);
|
||||
|
||||
fetch("toggle_matrice_attachment_disegno.php", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/x-www-form-urlencoded"
|
||||
},
|
||||
body: "id=" + encodeURIComponent(id) +
|
||||
"&field=" + encodeURIComponent(field) +
|
||||
"&value=" + newValue
|
||||
})
|
||||
.then(r => r.json())
|
||||
.then(data => {
|
||||
if (!data.success) {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Errore",
|
||||
text: data.message || ""
|
||||
});
|
||||
$btn.prop("disabled", false);
|
||||
return;
|
||||
}
|
||||
Swal.fire({
|
||||
toast: true,
|
||||
position: "top-end",
|
||||
icon: "success",
|
||||
title: data.message,
|
||||
showConfirmButton: false,
|
||||
timer: 1500
|
||||
});
|
||||
loadExistingAttachments(idmatrice);
|
||||
})
|
||||
.catch(() => {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Errore",
|
||||
text: "Errore di comunicazione con il server"
|
||||
});
|
||||
$btn.prop("disabled", false);
|
||||
});
|
||||
});
|
||||
|
||||
$(document).on("click", ".preview-existing-file", function() {
|
||||
const file = $(this).data("file") || "";
|
||||
const name = $(this).data("name") || "Anteprima file";
|
||||
|
||||
Reference in New Issue
Block a user