From 521455f156edd4abddb42eeb8cc48e1b1d1f3770 Mon Sep 17 00:00:00 2001 From: consultoria-as Date: Thu, 14 May 2026 22:24:09 +0000 Subject: [PATCH] fix(brand-catalog): separate search input from content grid - Add #brandCatalogSearch container in HTML for search inputs - Move brand search input out of renderBrandList so it persists while typing - Move parts search input out of renderPartsList so it persists while typing - Reset now clears search container - Bump JS cache bust to v=3 --- pos/static/js/brand-catalog.js | 43 ++++++++++++++++++++-------------- pos/templates/catalog.html | 3 ++- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/pos/static/js/brand-catalog.js b/pos/static/js/brand-catalog.js index 7e3f959..b02c667 100644 --- a/pos/static/js/brand-catalog.js +++ b/pos/static/js/brand-catalog.js @@ -9,6 +9,8 @@ _limit: 50, _total: 0, + el: function(id) { return document.getElementById(id); }, + _getToken: function() { return localStorage.getItem('pos_token'); }, @@ -30,8 +32,6 @@ return true; }, - el: function(id) { return document.getElementById(id); }, - show: function() { if (!this._getToken()) { window.location.href = '/pos/login'; @@ -56,6 +56,7 @@ this._allBrands = []; this._offset = 0; this._total = 0; + this.el('brandCatalogSearch').innerHTML = ''; }, loading: function(on) { @@ -66,6 +67,10 @@ this.el('brandCatalogContent').innerHTML = html; }, + setSearch: function(html) { + this.el('brandCatalogSearch').innerHTML = html; + }, + setBreadcrumb: function(html) { this.el('brandCatalogBreadcrumb').innerHTML = html; }, @@ -75,6 +80,12 @@ this.loading(true); this.state = 'brands'; this.setBreadcrumb('Marcas de vehiculo'); + this.setSearch( + '' + ); var self = this; fetch('/pos/api/catalog/vehicle-brands', { headers: this._headers() }) .then(function(r) { @@ -98,12 +109,7 @@ }, renderBrandList: function(brands) { - var html = '
' + - '' + - '
'; + var html = ''; brands.forEach(function(b) { html += '
' + '
' + escapeHtml(b.name) + '
' + @@ -134,6 +140,7 @@ loadCategories: function(brandName) { this.loading(true); this.state = 'categories'; + this.setSearch(''); this.setBreadcrumb( 'Marcas' + escapeHtml(brandName) + '' ); @@ -185,6 +192,16 @@ '' + escapeHtml(brandName) + ' › ' + '' + escapeHtml(this.currentCategory.name) + '' ); + this.setSearch( + '
' + + '' + + '' + + '' + + '
' + ); var url = '/pos/api/catalog/brand-parts?brand=' + encodeURIComponent(brandName) + '&category_id=' + encodeURIComponent(categoryId) + '&limit=' + this._limit + '&offset=' + this._offset; if (searchTerm) { @@ -215,15 +232,7 @@ }, renderPartsList: function(items, searchTerm) { - var html = '
' + - '' + - '' + - '' + - '
'; - + var html = ''; if (!items.length) { html += '
' + '

No se encontraron refacciones.

' + diff --git a/pos/templates/catalog.html b/pos/templates/catalog.html index 61769ff..a470b88 100644 --- a/pos/templates/catalog.html +++ b/pos/templates/catalog.html @@ -277,6 +277,7 @@
+
@@ -294,6 +295,6 @@ - +