Skip to content

Commit cf22b46

Browse files
committed
Merge branch 'bug-fixing-#1786' into develop
2 parents bb1b611 + fd3fd68 commit cf22b46

20 files changed

+292
-10
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
<%= color_field_tag "custom_field_enumerations[#{value.id}][color]", value.color, class: 'color-tag' %>
1+
<% if @custom_field.color_support? %>
2+
<%= color_field_tag "custom_field_enumerations[#{value.id}][color]", value.color, class: 'color-tag' %>
3+
<% end %>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<%=tag.p class: 'custom-field-enumeration-color-support' do %>
2+
<p><%= f.check_box :color_support %>
3+
<em class="info"><%= l(:text_custom_field_enumeration_color_support) %></em></p>
4+
<% end %>

config/locales/de.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
de:
22
error_invalid_css_hex_color: ist ungültig.
3+
field_color_support: Farbunterstützung
4+
text_custom_field_enumeration_color_support: Farbunterstützung aktivieren. Der Wert selbst wird nur dann eingeblendet, wenn Sie mit der Maus über das Farbfeld fahren.
5+
36

config/locales/en.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
en:
22
error_invalid_css_hex_color: is invalid.
3-
3+
field_color_support: Color support
4+
text_custom_field_enumeration_color_support: Enable color support. The value behind will be fade in when you hover the field.

db/migrate/001_add_color_to_custom_field_enumerations.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
# along with this program; if not, write to the Free Software
1919
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
2020

21-
class AddColorToCustomFieldEnumerations < ActiveRecord::Migration[5.2]
21+
class AddColorToCustomFieldEnumerations < ActiveRecord::Migration[6.1]
2222
def change
2323
add_column :custom_field_enumerations, :color, :text
2424
end
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# frozen_string_literal: true
2+
3+
# Redmine plugin called Redmine Colored Enumeration.
4+
#
5+
# Copyright (C) 2021-2023 Liane Hampe <[email protected]>, xmera Solutions GmbH.
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License
9+
# as published by the Free Software Foundation; either version 2
10+
# of the License, or (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program; if not, write to the Free Software
19+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20+
21+
class AddColorSupportToCustomFields < ActiveRecord::Migration[6.1]
22+
def change
23+
add_column :custom_fields, :color_support, :boolean, default: false
24+
end
25+
end
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# frozen_string_literal: true
2+
3+
# Redmine plugin called Redmine Colored Enumeration.
4+
#
5+
# Copyright (C) 2021-2023 Liane Hampe <[email protected]>, xmera Solutions GmbH.
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License
9+
# as published by the Free Software Foundation; either version 2
10+
# of the License, or (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program; if not, write to the Free Software
19+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20+
21+
class DisableColorSupport < ActiveRecord::Migration[6.1]
22+
23+
##
24+
# Disable color support for all existing custom fields where there is the color
25+
# black or nil.
26+
#
27+
def self.up
28+
CustomField.joins(:enumerations).where(enumerations: { color: ['#000000', nil] } ).update_all(color_support: false)
29+
end
30+
31+
def self.down
32+
# no-op
33+
end
34+
end
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# frozen_string_literal: true
2+
3+
# Redmine plugin called Redmine Colored Enumeration.
4+
#
5+
# Copyright (C) 2021-2023 Liane Hampe <[email protected]>, xmera Solutions GmbH.
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License
9+
# as published by the Free Software Foundation; either version 2
10+
# of the License, or (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU General Public License for more details.
16+
#
17+
# You should have received a copy of the GNU General Public License
18+
# along with this program; if not, write to the Free Software
19+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
20+
21+
class EnableColorSupport < ActiveRecord::Migration[6.1]
22+
23+
##
24+
# Enable color support for all existing custom fields where there is the color
25+
# set to any value but not black.
26+
#
27+
def self.up
28+
CustomField.joins(:enumerations).where.not(enumerations: { color: ['#000000', nil] } ).update_all(color_support: true)
29+
end
30+
31+
def self.down
32+
# no-op
33+
end
34+
end

lib/colored_enumeration.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
# Hooks
3131
require File.expand_path('colored_enumeration/hooks/view_layouts_base_hook_listener', __dir__)
3232
require File.expand_path('colored_enumeration/hooks/view_issues_index_bottom_hook_listener', __dir__)
33+
require File.expand_path('colored_enumeration/hooks/view_custom_fields_form_upper_box_hook_listener', __dir__)
3334

3435
# Overrides
3536
require File.expand_path('colored_enumeration/overrides/custom_field_enumerations_controller_patch', __dir__)

lib/colored_enumeration/extensions/custom_field_patch.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,20 @@ module Extensions
2323
module CustomFieldPatch
2424
def self.included(base)
2525
base.include(InstanceMethods)
26+
base.class_eval do
27+
safe_attributes 'color_support'
28+
validates :color_support, inclusion: [true, false], if: :enumeration?
29+
end
2630
end
2731

2832
module InstanceMethods
2933
def color_map
3034
enumerations.pluck(:id, :color).to_h
3135
end
36+
37+
def enumeration?
38+
field_format == 'enumeration'
39+
end
3240
end
3341
end
3442
end

0 commit comments

Comments
 (0)