From 9a7c0728f07998b347676aed3c27df64496ee6db Mon Sep 17 00:00:00 2001 From: Andrey Smakotin Date: Mon, 26 Jan 2026 23:40:27 +0300 Subject: [PATCH] =?UTF-8?q?feat(ui):=20improve=20product=20search=20and=20?= =?UTF-8?q?inventory=20interaction=20-=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D1=82=D1=8C=20=D0=B4=D0=B2=D0=BE=D0=B9=D0=BD=D0=BE=D0=B9?= =?UTF-8?q?=20=D0=BA=D0=BB=D0=B8=D0=BA=20=D0=BF=D0=BE=20=D1=82=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D1=80=D1=83=20=D0=B2=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA?= =?UTF-8?q?=D0=BE=D0=B2=D0=B8=D0=BA=D0=B5=20=D0=B4=D0=BB=D1=8F=20=D0=B1?= =?UTF-8?q?=D1=8B=D1=81=D1=82=D1=80=D0=BE=D0=B3=D0=BE=20=D0=B4=D0=BE=D0=B1?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F=20-=20=D0=94=D0=BE?= =?UTF-8?q?=D0=B1=D0=B0=D0=B2=D0=B8=D1=82=D1=8C=20=D0=B0=D0=B2=D1=82=D0=BE?= =?UTF-8?q?=D1=84=D0=BE=D0=BA=D1=83=D1=81=20=D0=B8=20=D1=81=D0=B5=D0=BB?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=20=D0=BD=D0=B0=20=D0=BF=D0=BE=D0=BB=D0=B5=20?= =?UTF-8?q?=D0=B2=D0=B2=D0=BE=D0=B4=D0=B0=20=D0=BA=D0=BE=D0=BB=D0=B8=D1=87?= =?UTF-8?q?=D0=B5=D1=81=D1=82=D0=B2=D0=B0=20=D0=BF=D1=80=D0=B8=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B8=20=D1=82?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D1=80=D0=B0=20=D0=B2=20=D0=B8=D0=BD=D0=B2?= =?UTF-8?q?=D0=B5=D0=BD=D1=82=D0=B0=D1=80=D1=8C=20-=20=D0=92=D1=8B=D0=BD?= =?UTF-8?q?=D0=B5=D1=81=D1=82=D0=B8=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D1=83?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=B8=D1=81=D0=BA=D0=B0=20=D1=82=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=20=D0=BF=D0=BE=20ID=20=D0=B2=20=D0=BE=D1=82?= =?UTF-8?q?=D0=B4=D0=B5=D0=BB=D1=8C=D0=BD=D1=8B=D0=B9=20=D0=BC=D0=B5=D1=82?= =?UTF-8?q?=D0=BE=D0=B4=20=5FfindProductById=20=D0=B4=D0=BB=D1=8F=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D0=B8=D1=81=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7?= =?UTF-8?q?=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../static/inventory/js/inventory_detail.js | 9 ++++- .../products/js/product-search-picker.js | 39 +++++++++++++------ 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/myproject/inventory/static/inventory/js/inventory_detail.js b/myproject/inventory/static/inventory/js/inventory_detail.js index 21b87f3..ca01c4b 100644 --- a/myproject/inventory/static/inventory/js/inventory_detail.js +++ b/myproject/inventory/static/inventory/js/inventory_detail.js @@ -401,7 +401,14 @@ // Включаем кнопку завершения const completeBtn = document.getElementById('complete-inventory-btn'); if (completeBtn) completeBtn.disabled = false; - + + // Фокус на поле ввода количества в новой строке + const quantityInput = newRow.querySelector('.quantity-fact-input'); + if (quantityInput) { + quantityInput.focus(); + quantityInput.select(); + } + this.showNotification('Товар добавлен', 'success'); } else { this.showNotification('Ошибка: ' + (data.error || 'Не удалось добавить товар'), 'error'); diff --git a/myproject/products/static/products/js/product-search-picker.js b/myproject/products/static/products/js/product-search-picker.js index 5b12a97..2472c72 100644 --- a/myproject/products/static/products/js/product-search-picker.js +++ b/myproject/products/static/products/js/product-search-picker.js @@ -207,6 +207,18 @@ self._toggleProduct(productId); } }); + + // Двойной клик по товару - сразу добавляет в документ + this.elements.grid.addEventListener('dblclick', function(e) { + var productCard = e.target.closest('.product-picker-item'); + if (productCard && self.options.onAddSelected) { + var productId = productCard.dataset.productId; + var product = self._findProductById(productId); + if (product) { + self.options.onAddSelected(product, self); + } + } + }); } // Добавить выбранный @@ -435,17 +447,7 @@ */ ProductSearchPicker.prototype._toggleProduct = function(productId) { var self = this; - var product = null; - - // Находим товар в списке - for (var i = 0; i < this.state.products.length; i++) { - var p = this.state.products[i]; - if (String(p.id).replace('product_', '') === productId) { - product = p; - product.id = productId; // Сохраняем очищенный ID - break; - } - } + var product = this._findProductById(productId); if (!product) return; @@ -473,6 +475,21 @@ this._updateSelectionUI(); }; + /** + * Поиск товара по ID в загруженном списке + */ + ProductSearchPicker.prototype._findProductById = function(productId) { + for (var i = 0; i < this.state.products.length; i++) { + var p = this.state.products[i]; + if (String(p.id).replace('product_', '') === productId) { + var product = Object.assign({}, p); + product.id = productId; // Сохраняем очищенный ID + return product; + } + } + return null; + }; + /** * Принудительно снять выделение со всех товаров */