Skip to content

Commit 4889686

Browse files
committed
Merge branch 'improvement-#1814' into develop
2 parents cf22b46 + a75e39e commit 4889686

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

lib/colored_enumeration/extensions/custom_field_patch.rb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ def self.included(base)
2525
base.include(InstanceMethods)
2626
base.class_eval do
2727
safe_attributes 'color_support'
28-
validates :color_support, inclusion: [true, false], if: :enumeration?
28+
validates :color_support, inclusion: [true, false], if: :with_color_support?
29+
class_attribute :color_supporting_field_formats
30+
self.color_supporting_field_formats = %w[enumeration]
2931
end
3032
end
3133

@@ -34,8 +36,8 @@ def color_map
3436
enumerations.pluck(:id, :color).to_h
3537
end
3638

37-
def enumeration?
38-
field_format == 'enumeration'
39+
def with_color_support?
40+
self.class.color_supporting_field_formats.include?(field_format)
3941
end
4042
end
4143
end

lib/colored_enumeration/extensions/query_custom_field_column_patch.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def color_map
4242
# @overrides QueryCustomFieldColumn#css_classes
4343
#
4444
def html_attributes(issue)
45-
return { class: css_classes } unless custom_field.enumeration?
45+
return { class: css_classes } unless custom_field.with_color_support?
4646
return { class: css_classes } unless custom_field.color_support?
4747

4848
val = value_object(issue)

lib/colored_enumeration/hooks/view_custom_fields_form_upper_box_hook_listener.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def view_custom_fields_form_upper_box(context = {})
3737
custom_field = context[:custom_field]
3838
form = context[:form]
3939

40-
return unless custom_field.enumeration?
40+
return unless custom_field.with_color_support?
4141

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

0 commit comments

Comments
 (0)