Actualizar proveedores.html
This commit is contained in:
@@ -704,22 +704,72 @@
|
|||||||
});
|
});
|
||||||
if (raw.status_operativo) statusSelect.value = raw.status_operativo;
|
if (raw.status_operativo) statusSelect.value = raw.status_operativo;
|
||||||
|
|
||||||
// --- BLOQUEAR INPUTS SI ESTÁ ARCHIVADO ---
|
// --- ADAPTACIÓN VISUAL PARA ARCHIVADOS (VISTA BREVE) ---
|
||||||
const inputsToLock = ['impName', 'impPhone', 'impAddress', 'impCP', 'impDesc', 'impUrgent', 'impGuild', 'impOperator', 'impNotesExt'];
|
// Obtenemos los contenedores que queremos ocultar cuando esté archivado
|
||||||
inputsToLock.forEach(inputId => {
|
const guildOperatorSection = document.getElementById('impGuild').closest('.grid'); // El bloque azul de gremio/operario
|
||||||
const el = document.getElementById(inputId);
|
const descNotesSection = document.getElementById('impDesc').closest('.space-y-3'); // El bloque de avería y notas
|
||||||
if (!el) return;
|
const phoneSection = document.getElementById('impPhone').closest('.bg-slate-50\\/50'); // El campo de teléfono
|
||||||
|
|
||||||
|
// Bloquear los inputs que se quedan visibles para que no se editen por error
|
||||||
|
const inputsToLock = ['impName', 'impAddress', 'impCP', 'impUrgent'];
|
||||||
|
|
||||||
|
if (isArchived) {
|
||||||
|
// Ocultar lo innecesario
|
||||||
|
if(guildOperatorSection) guildOperatorSection.classList.add('hidden');
|
||||||
|
if(descNotesSection) descNotesSection.classList.add('hidden');
|
||||||
|
if(phoneSection) phoneSection.classList.add('hidden');
|
||||||
|
|
||||||
if (isArchived) {
|
// Hacer que el campo de nombre ocupe toda la línea (ya que quitamos el teléfono)
|
||||||
el.setAttribute('readonly', 'true');
|
const nameContainer = document.getElementById('impName').closest('.grid');
|
||||||
el.classList.add('bg-slate-100', 'text-slate-400', 'cursor-not-allowed');
|
if(nameContainer) {
|
||||||
if (el.tagName === 'SELECT') el.style.pointerEvents = 'none';
|
nameContainer.classList.remove('md:grid-cols-2');
|
||||||
} else {
|
nameContainer.classList.add('grid-cols-1');
|
||||||
el.removeAttribute('readonly');
|
|
||||||
el.classList.remove('bg-slate-100', 'text-slate-400', 'cursor-not-allowed');
|
|
||||||
if (el.tagName === 'SELECT') el.style.pointerEvents = 'auto';
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
// Bloquear los campos visibles (excepto el estado)
|
||||||
|
inputsToLock.forEach(inputId => {
|
||||||
|
const el = document.getElementById(inputId);
|
||||||
|
if (el) {
|
||||||
|
el.setAttribute('readonly', 'true');
|
||||||
|
el.classList.add('bg-transparent', 'text-slate-500', 'cursor-not-allowed');
|
||||||
|
if (el.tagName === 'SELECT') el.style.pointerEvents = 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Ajustar visualmente el modal para que no parezca un formulario
|
||||||
|
document.getElementById('impAddress').classList.remove('border-2', 'bg-white', 'shadow-sm');
|
||||||
|
document.getElementById('impAddress').classList.add('border-0', 'bg-slate-50/50', 'text-slate-500');
|
||||||
|
document.getElementById('impCP').classList.remove('border-2', 'bg-white', 'shadow-sm');
|
||||||
|
document.getElementById('impCP').classList.add('border-0', 'bg-slate-50/50', 'text-slate-500');
|
||||||
|
|
||||||
|
} else {
|
||||||
|
// Restaurar todo a la vista normal
|
||||||
|
if(guildOperatorSection) guildOperatorSection.classList.remove('hidden');
|
||||||
|
if(descNotesSection) descNotesSection.classList.remove('hidden');
|
||||||
|
if(phoneSection) phoneSection.classList.remove('hidden');
|
||||||
|
|
||||||
|
const nameContainer = document.getElementById('impName').closest('.grid');
|
||||||
|
if(nameContainer) {
|
||||||
|
nameContainer.classList.add('md:grid-cols-2');
|
||||||
|
nameContainer.classList.remove('grid-cols-1');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Desbloquear campos
|
||||||
|
inputsToLock.forEach(inputId => {
|
||||||
|
const el = document.getElementById(inputId);
|
||||||
|
if (el) {
|
||||||
|
el.removeAttribute('readonly');
|
||||||
|
el.classList.remove('bg-transparent', 'text-slate-500', 'cursor-not-allowed');
|
||||||
|
if (el.tagName === 'SELECT') el.style.pointerEvents = 'auto';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Restaurar estilos del formulario
|
||||||
|
document.getElementById('impAddress').classList.add('border-2', 'bg-white', 'shadow-sm');
|
||||||
|
document.getElementById('impAddress').classList.remove('border-0', 'bg-slate-50/50', 'text-slate-500');
|
||||||
|
document.getElementById('impCP').classList.add('border-2', 'bg-white', 'shadow-sm');
|
||||||
|
document.getElementById('impCP').classList.remove('border-0', 'bg-slate-50/50', 'text-slate-500');
|
||||||
|
}
|
||||||
|
|
||||||
// Bloqueamos el botón de Traspaso Manual y Enviar a Bolsa si está archivado
|
// Bloqueamos el botón de Traspaso Manual y Enviar a Bolsa si está archivado
|
||||||
const btnsToHide = document.querySelectorAll('button[type="submit"], button[onclick="sendToQueue()"]');
|
const btnsToHide = document.querySelectorAll('button[type="submit"], button[onclick="sendToQueue()"]');
|
||||||
@@ -728,6 +778,12 @@
|
|||||||
else btn.classList.remove('hidden');
|
else btn.classList.remove('hidden');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Cambiar el texto del botón de Guardar si es archivado para que sea más intuitivo
|
||||||
|
const saveBtn = document.querySelector('button[onclick="saveDraftChanges(event)"] span');
|
||||||
|
if (saveBtn) {
|
||||||
|
saveBtn.innerText = isArchived ? "Actualizar Estado" : "Guardar";
|
||||||
|
}
|
||||||
|
|
||||||
document.getElementById('importModal').classList.remove('hidden');
|
document.getElementById('importModal').classList.remove('hidden');
|
||||||
lucide.createIcons();
|
lucide.createIcons();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user