OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Show placeholder "(Custom)" in the theme selection field when colors have been changed manually
Henriette Dingerf067c4702e9f
diff --git a/app/controllers/custom_styles_controller.rb b/app/controllers/custom_styles_controller.rbindex b9612f8baf0..6ce8f384d9b 100644--- a/app/controllers/custom_styles_controller.rb+++ b/app/controllers/custom_styles_controller.rb@@ -37,8 +37,8 @@ class CustomStylesController < ApplicationControllerdef show@custom_style = CustomStyle.current || CustomStyle.new- @themes = OpenProject::CustomStyles::ColorThemes::THEMES.map { |val| val[:name] }@current_theme = @custom_style.theme+ @theme_options = options_for_theme_selectenddef upsale; end@@ -109,6 +109,13 @@ class CustomStylesController < ApplicationControllerprivate+ def options_for_theme_select+ options = OpenProject::CustomStyles::ColorThemes::THEMES.map { |val| val[:name] }+ options << [t('admin.custom_styles.color_theme_custom'), '', disabled: true] if @current_theme.empty?++ options+ end+def set_colors(variable_params)variable_params.each do |param_variable, param_hexcode|if design_color = DesignColor.find_by(variable: param_variable)@@ -127,8 +134,10 @@ class CustomStylesController < ApplicationControllerenddef set_theme(params)+ theme = ActionController::Parameters.new(theme: params[:theme] || '').permit(:theme)+@custom_style = CustomStyle.current- @custom_style.update(params.permit(:theme))+ @custom_style.update(theme)enddef require_ee_tokendiff --git a/app/views/custom_styles/show.html.erb b/app/views/custom_styles/show.html.erbindex 5c7faf18fa8..156c9f8f075 100644--- a/app/views/custom_styles/show.html.erb+++ b/app/views/custom_styles/show.html.erb@@ -36,11 +36,11 @@ See docs/COPYRIGHT.rdoc for more details.<%= form_tag update_design_themes_path, method: :post, class: "form" do %><section class="form--section"><fieldset class="form--fieldset">- <legend class="form--fieldset-legend"><%= I18n.t('admin.custom_styles.color_themes') %></legend>+ <legend class="form--fieldset-legend"><%= I18n.t('admin.custom_styles.color_theme') %></legend><div class="form--field"><div class="form--field-container"><%= styled_select_tag 'theme',- options_for_select(@themes, @current_theme),+ options_for_select(@theme_options, @current_theme),container_class: '-slim' %></div></div>diff --git a/config/locales/en.yml b/config/locales/en.ymlindex 5b5ab8dcd42..fafccaf75f4 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -37,7 +37,8 @@ en:plugins:no_results_title_text: There are currently no plugins available.custom_styles:- color_themes: "Color themes"+ color_theme: "Color theme"+ color_theme_custom: "(Custom)"colors:alternative-color: "Alternative"content-link-color: "Link font"diff --git a/db/migrate/20200114091135_add_theme_name_to_custom_styles.rb b/db/migrate/20200114091135_add_theme_name_to_custom_styles.rbindex 8ab7aaa0ca8..93187deffb3 100644--- a/db/migrate/20200114091135_add_theme_name_to_custom_styles.rb+++ b/db/migrate/20200114091135_add_theme_name_to_custom_styles.rb@@ -1,5 +1,5 @@class AddThemeNameToCustomStyles < ActiveRecord::Migration[6.0]def change- add_column :custom_styles, :theme, :string, default: ""+ add_column :custom_styles, :theme, :string, default: "OpenProject"endenddiff --git a/lib/open_project/custom_styles/color_themes.rb b/lib/open_project/custom_styles/color_themes.rbindex 14611c71157..243b1b68847 100644--- a/lib/open_project/custom_styles/color_themes.rb+++ b/lib/open_project/custom_styles/color_themes.rb@@ -48,7 +48,7 @@ module OpenProject::CustomStyles'main-menu-font-color' => "#FFFFFF",'main-menu-hover-font-color' => "#FFFFFF",'main-menu-selected-font-color' => "#FFFFFF",- 'main-menu-border-color' => "#EAEAEA",+ 'main-menu-border-color' => "#EAEAEA"}},{@@ -69,7 +69,7 @@ module OpenProject::CustomStyles'main-menu-font-color' => "#000000",'main-menu-hover-font-color' => "#000000",'main-menu-selected-font-color' => "#000000",- 'main-menu-border-color' => "#EAEAEA",+ 'main-menu-border-color' => "#EAEAEA"}},{@@ -90,7 +90,7 @@ module OpenProject::CustomStyles'main-menu-font-color' => "#DFDFDF",'main-menu-hover-font-color' => "#DFDFDF",'main-menu-selected-font-color' => "#DFDFDF",- 'main-menu-border-color' => "#000000",+ 'main-menu-border-color' => "#000000"}}].freezediff --git a/spec/views/custom_styles/show.html.erb_spec.rb b/spec/views/custom_styles/show.html.erb_spec.rbindex fe880ee30bc..bd435251b71 100644--- a/spec/views/custom_styles/show.html.erb_spec.rb+++ b/spec/views/custom_styles/show.html.erb_spec.rb@@ -38,6 +38,7 @@ describe 'custom_styles/show', type: :view docontext "no custom logo yet" dobefore doassign(:custom_style, CustomStyle.new)+ allow(view).to receive(:options_for_select).and_return('')renderend@@ -49,6 +50,7 @@ describe 'custom_styles/show', type: :view docontext "with existing custom logo" dobefore doassign(:custom_style, FactoryBot.build(:custom_style_with_logo))+ allow(view).to receive(:options_for_select).and_return('')renderend