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; + }; + /** * Принудительно снять выделение со всех товаров */