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 life cycle steps into styles.css
ulferts718f9d3e691b
diff --git a/app/helpers/colors_helper.rb b/app/helpers/colors_helper.rbindex ac61eaa323f..a049b8a5abc 100644--- a/app/helpers/colors_helper.rb+++ b/app/helpers/colors_helper.rb@@ -49,33 +49,41 @@ module ColorsHelper##def color_cssColor.find_each do |color|- set_background_colors_for class_name: ".__hl_inline_color_#{color.id}_dot::before", hexcode: color.hexcode- set_foreground_colors_for class_name: ".__hl_inline_color_#{color.id}_text", hexcode: color.hexcode+ set_background_colors_for(class_name: ".#{hl_inline_class('color', color)}_dot::before", color:)+ set_foreground_colors_for(class_name: ".#{hl_inline_class('color', color)}_text", color:)endend## Styles to display the color of attributes (type, status etc.) for example in the WP view##- def resource_color_css(name, scope)+ def resource_color_css(name, scope, inline_foreground: false)scope.includes(:color).find_each do |entry|color = entry.colorif color.nil?- concat ".__hl_inline_#{name}_#{entry.id}::before { display: none }\n"+ concat ".#{hl_inline_class(name, entry)}::before { display: none }\n"nextend- if name === "type"- set_foreground_colors_for class_name: ".__hl_inline_#{name}_#{entry.id}", hexcode: color.hexcode+ if inline_foreground+ set_foreground_colors_for(class_name: ".#{hl_inline_class(name, entry)}", color:)else- set_background_colors_for class_name: ".__hl_inline_#{name}_#{entry.id}::before", hexcode: color.hexcode+ set_background_colors_for(class_name: ".#{hl_inline_class(name, entry)}::before", color:)end- set_background_colors_for class_name: ".__hl_background_#{name}_#{entry.id}", hexcode: color.hexcode+ set_background_colors_for(class_name: ".#{hl_background_class(name, entry)}", color:)endend+ def hl_inline_class(name, model)+ "__hl_inline_#{name}_#{model.id}"+ end++ def hl_background_class(name, model)+ "__hl_background_#{name}_#{model.id}"+ end+def icon_for_color(color, options = {})return unless color@@ -90,10 +98,10 @@ module ColorsHelperDesignColor.find_by(variable:)&.hexcodeend- def set_background_colors_for(class_name:, hexcode:)+ def set_background_colors_for(class_name:, color:)mode = User.current.pref.theme.split("_", 2)[0]- concat "#{class_name} { #{default_color_styles(hexcode)} }"+ concat "#{class_name} { #{default_color_styles(color.hexcode)} }"if mode == "dark"concat "#{class_name} { #{default_variables_dark} }"concat "#{class_name} { #{highlighted_background_dark} }"@@ -103,10 +111,10 @@ module ColorsHelperendend- def set_foreground_colors_for(class_name:, hexcode:)+ def set_foreground_colors_for(class_name:, color:)mode = User.current.pref.theme.split("_", 2)[0]- concat "#{class_name} { #{default_color_styles(hexcode)} }"+ concat "#{class_name} { #{default_color_styles(color.hexcode)} }"if mode == "dark"concat "#{class_name} { #{default_variables_dark} }"concat "#{class_name} { #{highlighted_foreground_dark} }"diff --git a/app/views/highlighting/styles.css.erb b/app/views/highlighting/styles.css.erbindex f140ef23ff0..8f981cd72f6 100644--- a/app/views/highlighting/styles.css.erb+++ b/app/views/highlighting/styles.css.erb@@ -1,7 +1,10 @@<%# Highlightable resources %><%= resource_color_css('status', ::Status) %><%= resource_color_css('priority', ::IssuePriority) %>-<%= resource_color_css('type', ::Type) %>+<%= resource_color_css('type', ::Type, inline_foreground: true) %>+<%# Color coded icons %>+<%= resource_color_css('life_cycle_step_definition', Project::LifeCycleStepDefinition, inline_foreground: true) %>+<%= color_css() %><%# Overdue tasks %>diff --git a/frontend/src/global_styles/layout/_colors.sass b/frontend/src/global_styles/layout/_colors.sassindex 915cc7fbdb3..82752becb1c 100644--- a/frontend/src/global_styles/layout/_colors.sass+++ b/frontend/src/global_styles/layout/_colors.sass@@ -95,8 +95,8 @@font-weight: var(--base-text-weight-bold)// Inline: all except type-[class^='__hl_inline_']:not([class^='__hl_inline_type']),-[class*=' __hl_inline_']:not([class*='__hl_inline_type'])+[class^='__hl_inline_']:not([class^='__hl_inline_type'], [class^='__hl_inline_life_cycle_step_definition']),+[class*=' __hl_inline_']:not([class*='__hl_inline_type'], [class^='__hl_inline_life_cycle_step_definition'])&::beforecontent: ''display: inline-blockdiff --git a/spec/helpers/colors_helper_spec.rb b/spec/helpers/colors_helper_spec.rbnew file mode 100644index 00000000000..b5c0236cd22--- /dev/null+++ b/spec/helpers/colors_helper_spec.rb@@ -0,0 +1,45 @@+# -- copyright+# OpenProject is an open source project management software.+# Copyright (C) 2024 the OpenProject GmbH+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License version 3.+#+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:+# Copyright (C) 2006-2013 Jean-Philippe Lang+# Copyright (C) 2010-2013 the ChiliProject Team+#+# This program is free software; you can redistribute it and/or+# modify it under the terms of the GNU General Public License+# as published by the Free Software Foundation; either version 2+# of the License, or (at your option) any later version.+#+# This program is distributed in the hope that it will be useful,+# but WITHOUT ANY WARRANTY; without even the implied warranty of+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the+# GNU General Public License for more details.+#+# You should have received a copy of the GNU General Public License+# along with this program; if not, write to the Free Software+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.+#+# See COPYRIGHT and LICENSE files for more details.+# ++++require "spec_helper"++RSpec.describe ColorsHelper do+ let(:model) { Data.define(:id).new(5) }++ describe "#hl_inline_class" do+ it "returns the correct class name" do+ expect(helper.hl_inline_class("foo_bar", model)).to eq("__hl_inline_foo_bar_5")+ end+ end++ describe "#hl_background_class" do+ it "returns the correct class name" do+ expect(helper.hl_background_class("foo_bar", model)).to eq("__hl_background_foo_bar_5")+ end+ end+end