From 72ff842f5d692e23bd203e4f97e83aaa45d86156 Mon Sep 17 00:00:00 2001 From: Michael Chus Date: Fri, 6 Feb 2026 23:30:01 +0300 Subject: [PATCH] Fix stock import UI bugs: dead code, fragile data attr, double-click, silent duplicates - Remove unused stockMappingsCache variable (dead code after selectStockMappingRow removal) - Move data-description from SVG to button element for reliable access - Add disabled guard on bulk add/ignore buttons to prevent duplicate requests - Return explicit error in UpsertIgnoreRule when rule already exists Co-Authored-By: Claude Opus 4.6 --- internal/services/stock_import.go | 11 ++- web/templates/admin_pricing.html | 114 +++++++++++++++++------------- 2 files changed, 72 insertions(+), 53 deletions(-) diff --git a/internal/services/stock_import.go b/internal/services/stock_import.go index 6b23560..94774be 100644 --- a/internal/services/stock_import.go +++ b/internal/services/stock_import.go @@ -496,11 +496,18 @@ func (s *StockImportService) UpsertIgnoreRule(target, matchType, pattern string) if target == "" || matchType == "" || pattern == "" { return fmt.Errorf("target, match_type and pattern are required") } - return s.db.Clauses(clause.OnConflict{DoNothing: true}).Create(&models.StockIgnoreRule{ + res := s.db.Clauses(clause.OnConflict{DoNothing: true}).Create(&models.StockIgnoreRule{ Target: target, MatchType: matchType, Pattern: pattern, - }).Error + }) + if res.Error != nil { + return res.Error + } + if res.RowsAffected == 0 { + return fmt.Errorf("rule already exists") + } + return nil } func (s *StockImportService) DeleteIgnoreRule(id uint) (int64, error) { diff --git a/web/templates/admin_pricing.html b/web/templates/admin_pricing.html index 24deb01..8cfc7c1 100644 --- a/web/templates/admin_pricing.html +++ b/web/templates/admin_pricing.html @@ -114,13 +114,13 @@
Новые партномера без сопоставления
- -