diff --git a/proveedores.html b/proveedores.html index 48aa143..88b76ba 100644 --- a/proveedores.html +++ b/proveedores.html @@ -749,13 +749,19 @@ } // --- CARGAR ESTADOS EN EL SELECTOR --- + filterStatusOptions(); // Ejecutamos el filtro inicial + const statusSelect = document.getElementById('impStatus'); - statusSelect.innerHTML = ''; - systemStatuses.forEach(st => { - statusSelect.innerHTML += ``; - }); - if (raw.status_operativo) statusSelect.value = raw.status_operativo; + + // Si el JSON traía un estado previo, intentamos fijarlo (solo si es válido en el filtro) + if (raw.status_operativo && Array.from(statusSelect.options).some(opt => opt.value === String(raw.status_operativo))) { + statusSelect.value = raw.status_operativo; + } + // Añadimos un "chivato" para que si eligen a un operario a mano, se desbloqueen los estados al instante + const opSelect = document.getElementById('impOperator'); + opSelect.removeEventListener('change', filterStatusOptions); // Limpiar previo por si acaso + opSelect.addEventListener('change', filterStatusOptions); // --- ADAPTACIÓN VISUAL PARA ARCHIVADOS (VISTA BREVE) --- // Obtenemos los contenedores que queremos ocultar cuando esté archivado const guildOperatorSection = document.getElementById('impGuild').closest('.grid'); // El bloque azul de gremio/operario