feat: dropdown filtra marcas y modelos por ano seleccionado
Al seleccionar ano, solo muestra marcas/modelos disponibles para ese ano. Toyota 2020: 92 modelos vs 625 sin filtro. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -858,9 +858,9 @@
|
||||
|
||||
if (!yearId) return;
|
||||
|
||||
// Load brands (reuse existing endpoint)
|
||||
// Load brands filtered by year
|
||||
vsBrand.disabled = false;
|
||||
apiFetch(API + '/brands').then(function (data) {
|
||||
apiFetch(API + '/brands?year_id=' + yearId).then(function (data) {
|
||||
var brands = data.data || data;
|
||||
if (!brands) return;
|
||||
vsBrand.innerHTML = '<option value="">Marca...</option>';
|
||||
@@ -872,6 +872,7 @@
|
||||
|
||||
function vsBrandChanged() {
|
||||
var brandId = vsBrand.value;
|
||||
var yearId = vsYear.value;
|
||||
vsModel.innerHTML = '<option value="">Modelo...</option>';
|
||||
vsEngine.innerHTML = '<option value="">Motor...</option>';
|
||||
vsModel.disabled = true;
|
||||
@@ -879,8 +880,9 @@
|
||||
|
||||
if (!brandId) return;
|
||||
|
||||
// Load models filtered by brand AND year
|
||||
vsModel.disabled = false;
|
||||
apiFetch(API + '/models?brand_id=' + brandId).then(function (data) {
|
||||
apiFetch(API + '/models?brand_id=' + brandId + (yearId ? '&year_id=' + yearId : '')).then(function (data) {
|
||||
var models = data.data || data;
|
||||
if (!models) return;
|
||||
vsModel.innerHTML = '<option value="">Modelo...</option>';
|
||||
|
||||
Reference in New Issue
Block a user