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
Add theme column to custom_styles table to save the currently used theme and show the correct one in the select field
Henriette Dinger8041925ea4a7
diff --git a/app/assets/stylesheets/content/_forms.sass b/app/assets/stylesheets/content/_forms.sassindex 764b4b641f3..f0d14db6880 100644--- a/app/assets/stylesheets/content/_forms.sass+++ b/app/assets/stylesheets/content/_forms.sass@@ -236,6 +236,10 @@ hrfieldset.form--fieldset@extend %form--fieldset-or-section+ &.-collapsible.collapsed+ .-hide-when-collapsed+ display: none+.form--fieldset-legend@extend %form--fieldset-legend-or-section-titlewidth: 100%diff --git a/app/assets/stylesheets/openproject/_variables.scss.erb b/app/assets/stylesheets/openproject/_variables.scss.erbindex fb2a14cc6b1..6a28a3ecce5 100644--- a/app/assets/stylesheets/openproject/_variables.scss.erb+++ b/app/assets/stylesheets/openproject/_variables.scss.erb@@ -2,7 +2,7 @@Depend on the design file so that this is recompiled on core changes.Doesn't work for theme plugins, sorry :-/ just update the core design.rb as well to reload!%>-<% depend_on Rails.root.join('lib', 'open_project', 'design.rb') %>+<% depend_on Rails.root.join('lib', 'open_project', 'custom_styles', 'design.rb') %><%#Set defaults for the following variablesdiff --git a/app/controllers/custom_styles_controller.rb b/app/controllers/custom_styles_controller.rbindex f2dddb87f1e..b9612f8baf0 100644--- a/app/controllers/custom_styles_controller.rb+++ b/app/controllers/custom_styles_controller.rb@@ -37,6 +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.themeenddef upsale; end@@ -88,6 +90,7 @@ class CustomStylesController < ApplicationControllerdef update_colorsvariable_params = params[:design_colors].firstset_colors(variable_params)+ set_theme(params)redirect_to action: :showend@@ -95,6 +98,7 @@ class CustomStylesController < ApplicationControllerdef update_themesvariable_params = OpenProject::CustomStyles::ColorThemes::THEMES.find { |theme| theme[:name] == params[:theme] }[:colors]set_colors(variable_params)+ set_theme(params)redirect_to action: :showend@@ -122,6 +126,11 @@ class CustomStylesController < ApplicationControllerendend+ def set_theme(params)+ @custom_style = CustomStyle.current+ @custom_style.update(params.permit(:theme))+ end+def require_ee_tokenunless EnterpriseToken.allows_to?(:define_custom_style)redirect_to custom_style_upsale_pathdiff --git a/app/views/custom_styles/show.html.erb b/app/views/custom_styles/show.html.erbindex 947a932f269..5c7faf18fa8 100644--- a/app/views/custom_styles/show.html.erb+++ b/app/views/custom_styles/show.html.erb@@ -33,6 +33,23 @@ See docs/COPYRIGHT.rdoc for more details.<%= error_messages_for 'custom_style' %>+<%= 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>+ <div class="form--field">+ <div class="form--field-container">+ <%= styled_select_tag 'theme',+ options_for_select(@themes, @current_theme),+ container_class: '-slim' %>+ </div>+ </div>++ <button type="submit" class="button"><%= I18n.t(:button_save) %></button>+ </fieldset>+ </section>+<% end %>+<%= form_for @custom_style, url: custom_style_path, html: { multipart: true, class: "form -vertical" } do |f| %><section class="form--section"><fieldset class="form--fieldset">@@ -137,23 +154,6 @@ See docs/COPYRIGHT.rdoc for more details.</section><% end %>-<%= 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>- <div class="form--field">- <div class="form--field-container">- <%= styled_select_tag 'theme',- options_for_select(OpenProject::CustomStyles::ColorThemes::THEMES.map { |val| val[:name] }),- container_class: '-slim' %>- </div>- </div>-- <button type="submit" class="button"><%= I18n.t(:button_save) %></button>- </fieldset>- </section>-<% end %>-<%= form_tag update_design_colors_path, method: :post, class: "form" do %><section class="form--section"><fieldset class="form--fieldset -collapsible collapsed">@@ -181,7 +181,7 @@ See docs/COPYRIGHT.rdoc for more details.</div><% end %>- <button type="submit" class="button"><%= I18n.t(:button_save) %></button>+ <button type="submit" class="button -hide-when-collapsed"><%= I18n.t(:button_save) %></button></fieldset></section>diff --git a/db/migrate/20200114091135_add_theme_name_to_custom_styles.rb b/db/migrate/20200114091135_add_theme_name_to_custom_styles.rbnew file mode 100644index 00000000000..8ab7aaa0ca8--- /dev/null+++ b/db/migrate/20200114091135_add_theme_name_to_custom_styles.rb@@ -0,0 +1,5 @@+class AddThemeNameToCustomStyles < ActiveRecord::Migration[6.0]+ def change+ add_column :custom_styles, :theme, :string, default: ""+ end+enddiff --git a/lib/open_project.rb b/lib/open_project.rbindex 6547dc5bdf6..8dc3800eb9d 100644--- a/lib/open_project.rb+++ b/lib/open_project.rb@@ -35,7 +35,7 @@ require 'open_project/custom_field_format'require 'open_project/logging/log_delegator'require 'redmine/mime_type'require 'redmine/core_ext'-require 'open_project/design'+require 'open_project/custom_styles/design'require 'redmine/hook'require 'open_project/hooks'require 'redmine/plugin'diff --git a/lib/open_project/design.rb b/lib/open_project/custom_styles/design.rbsimilarity index 100%rename from lib/open_project/design.rbrename to lib/open_project/custom_styles/design.rbdiff --git a/modules/bim_seeder/lib/open_project/bim_seeder/patches/design_patch.rb b/modules/bim_seeder/lib/open_project/bim_seeder/patches/design_patch.rbindex ae718099dac..5a15109305b 100644--- a/modules/bim_seeder/lib/open_project/bim_seeder/patches/design_patch.rb+++ b/modules/bim_seeder/lib/open_project/bim_seeder/patches/design_patch.rb@@ -1,4 +1,4 @@-require 'open_project/design'+require 'open_project/custom_styles/design'module OpenProject::BimSeedermodule Patches