Skip to content

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

Fix setting of theme

Oliver Güntherf3219d4666ee
diff --git a/app/controllers/custom_styles_controller.rb b/app/controllers/custom_styles_controller.rb
index 2fe6de5bbaf..425f1cf0be4 100644
--- a/app/controllers/custom_styles_controller.rb
+++ b/app/controllers/custom_styles_controller.rb
@@ -123,7 +123,7 @@ class CustomStylesController < ApplicationController
def options_for_theme_select
options = OpenProject::CustomStyles::ColorThemes.themes.map { |val| val[:theme] }
- options << [t('admin.custom_styles.color_theme_custom'), '', disabled: true] if @current_theme.empty?
+ options << [t('admin.custom_styles.color_theme_custom'), '', selected: true, disabled: true] unless @current_theme.present?
options
end
diff --git a/app/services/design/update_design_service.rb b/app/services/design/update_design_service.rb
index 13cbf1e408b..0f20c4f5ea3 100644
--- a/app/services/design/update_design_service.rb
+++ b/app/services/design/update_design_service.rb
@@ -46,9 +46,7 @@ module Design
private
def set_logo
- return unless params[:logo]
-
- custom_style.theme_logo = params[:logo]
+ custom_style.theme_logo = params[:logo].presence
end
def set_colors
@@ -71,9 +69,7 @@ module Design
end
def set_theme
- return unless params[:theme]
-
- custom_style.theme = params[:theme]
+ custom_style.theme = params[:theme].presence
end
def custom_style
diff --git a/app/views/custom_styles/_inline_css.erb b/app/views/custom_styles/_inline_css.erb
index e8c9242cb30..1a46a39301b 100644
--- a/app/views/custom_styles/_inline_css.erb
+++ b/app/views/custom_styles/_inline_css.erb
@@ -28,15 +28,20 @@ See docs/COPYRIGHT.rdoc for more details.
++#%>
<style type="text/css">
- <% if CustomStyle.current.logo.present? %>
- #logo .home-link {
- background-image: url("<%= custom_style_logo_path(digest: CustomStyle.current.digest, filename: CustomStyle.current.logo_identifier) %>");
- }
- <% elsif CustomStyle.current.theme_logo %>
- #logo .home-link {
- background-image: url("<%= asset_path(CustomStyle.current.theme_logo) %>");
- }
- <% end %>
+ <%
+ logo_url =
+ if CustomStyle.current.logo.present?
+ custom_style_logo_path(digest: CustomStyle.current.digest, filename: CustomStyle.current.logo_identifier)
+ elsif CustomStyle.current.theme_logo.present?
+ asset_path(CustomStyle.current.theme_logo)
+ else
+ asset_path("logo_openproject_white_big.png")
+ end
+ %>
+
+ #logo .home-link {
+ background-image: url(<%= logo_url %>);
+ }
:root {
<% DesignColor.overwritten.each do |design_color| %>
diff --git a/app/views/custom_styles/show.html.erb b/app/views/custom_styles/show.html.erb
index 49795cf3e92..6be42239e10 100644
--- a/app/views/custom_styles/show.html.erb
+++ b/app/views/custom_styles/show.html.erb
@@ -46,7 +46,7 @@ See docs/COPYRIGHT.rdoc for more details.
</div>
<%= styled_button_tag t(:button_save),
- data:({ confirm: t('admin.custom_styles.theme_warning') } if @current_theme.empty?) %>
+ data:({ confirm: t('admin.custom_styles.theme_warning') } unless @current_theme.present?) %>
</fieldset>
</section>
<% end %>
@@ -157,7 +157,7 @@ See docs/COPYRIGHT.rdoc for more details.
<%= form_tag update_design_colors_path, method: :post, class: "form" do %>
<section class="form--section">
- <fieldset class="form--fieldset -collapsible <%= 'collapsed' unless @current_theme.empty? %> ">
+ <fieldset class="form--fieldset -collapsible <%= 'collapsed' if @current_theme.present? %> ">
<legend class="form--fieldset-legend"><%= I18n.t(:label_advanced_settings) %></legend>
<% DesignColor.setables.each do |design_color| %>