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

Remove any custom colors if setting a new theme

Oliver Günther0c339d33029b
diff --git a/app/services/design/update_design_service.rb b/app/services/design/update_design_service.rb
index 0f20c4f5ea3..dbc52a0c2f2 100644
--- a/app/services/design/update_design_service.rb
+++ b/app/services/design/update_design_service.rb
@@ -35,12 +35,17 @@ module Design
end
def call
- set_logo
- set_colors
- set_theme
+ CustomStyle.transaction do
+ set_logo
+ set_colors
+ set_theme
- ServiceResult.new success: custom_style.save,
- result: custom_style
+ custom_style.save!
+
+ ServiceResult.new success: true, result: custom_style
+ end
+ rescue StandardError => e
+ ServiceResult.new success: false, message: e.message
end
private
@@ -52,6 +57,11 @@ module Design
def set_colors
return unless params[:colors]
+ # reset all colors if a new theme is set
+ if params[:theme].present?
+ DesignColor.delete_all
+ end
+
params[:colors].each do |param_variable, param_hexcode|
if design_color = DesignColor.find_by(variable: param_variable)
if param_hexcode.blank?