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 <noreply@anthropic.com>
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user