diff --git a/app/models/tag.rb b/app/models/tag.rb index c5bdc0bc2..108e1c89c 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -5,6 +5,7 @@ class Tag < ApplicationRecord has_many :import_mappings, as: :mappable, dependent: :destroy, class_name: "Import::Mapping" validates :name, presence: true, uniqueness: { scope: :family } + validates :color, format: { with: /\A#[0-9A-Fa-f]{6}\z/ }, allow_nil: true scope :alphabetically, -> { order(:name) } diff --git a/app/views/transactions/searches/filters/_tag_filter.html.erb b/app/views/transactions/searches/filters/_tag_filter.html.erb index 76b198119..0c6b93873 100644 --- a/app/views/transactions/searches/filters/_tag_filter.html.erb +++ b/app/views/transactions/searches/filters/_tag_filter.html.erb @@ -16,15 +16,15 @@ tag.name, nil %> <%= form.label :tags, value: tag.name, class: "text-sm text-primary flex items-center gap-2" do %> - <%= render DS::FilledIcon.new( - variant: :text, - hex_color: tag.color || Tag::UNCATEGORIZED_COLOR, - text: tag.name, - size: "sm", - rounded: true - ) %> - - <%= tag.name %> + <% tag_color = tag.color.presence || Tag::UNCATEGORIZED_COLOR %> + + + <%= tag.name %> + <% end %> <% end %>