Skip to content

Commit

Permalink
Merge branch 'improvement-#1814' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
liaham committed Nov 13, 2023
2 parents cf22b46 + a75e39e commit 4889686
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
8 changes: 5 additions & 3 deletions lib/colored_enumeration/extensions/custom_field_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ def self.included(base)
base.include(InstanceMethods)
base.class_eval do
safe_attributes 'color_support'
validates :color_support, inclusion: [true, false], if: :enumeration?
validates :color_support, inclusion: [true, false], if: :with_color_support?
class_attribute :color_supporting_field_formats
self.color_supporting_field_formats = %w[enumeration]
end
end

Expand All @@ -34,8 +36,8 @@ def color_map
enumerations.pluck(:id, :color).to_h
end

def enumeration?
field_format == 'enumeration'
def with_color_support?
self.class.color_supporting_field_formats.include?(field_format)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def color_map
# @overrides QueryCustomFieldColumn#css_classes
#
def html_attributes(issue)
return { class: css_classes } unless custom_field.enumeration?
return { class: css_classes } unless custom_field.with_color_support?
return { class: css_classes } unless custom_field.color_support?

val = value_object(issue)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def view_custom_fields_form_upper_box(context = {})
custom_field = context[:custom_field]
form = context[:form]

return unless custom_field.enumeration?
return unless custom_field.with_color_support?

controller.send :render_to_string, { partial: 'hooks/color_support',
locals: { f: form, custom_field: custom_field } }
Expand Down

0 comments on commit 4889686

Please sign in to comment.