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
use the phase`s name to get the correct color
ulferts6e55cce82b3e
diff --git a/app/helpers/colors_helper.rb b/app/helpers/colors_helper.rbindex ee613ef29bf..5effa615bc0 100644--- a/app/helpers/colors_helper.rb+++ b/app/helpers/colors_helper.rb@@ -67,6 +67,26 @@ module ColorsHelperendend+ # Render the highlighting color for the project phase definition.+ # On top of the normal classes as done for other resources, we also add a class based on the+ # base64 encoded name of the project phase definition.+ #+ # The class name is based on the project phase definition's name, which is guaranteed to be unique.+ #+ # That way the frontend does not have to load the definitions to get the color.+ # The = signs at the end of the base64 string are replaced with _ to make it a valid class name.+ # This needs to be kept in sync with the ProjectPhaseDisplayField#phaseIcon method in the front end.+ def project_phase_color_css+ Project::PhaseDefinition.includes(:color).find_each do |definition|+ resource_color_css("project_phase_definition", definition, inline_foreground: true)++ set_foreground_colors_for(+ class_name: ".#{hl_inline_class('project_phase_definition', Base64.strict_encode64(definition.name).tr('=', '_'))}",+ color: definition.color+ )+ end+ end+def resource_color_css(name, entry, inline_foreground: false)color = entry.colordiff --git a/app/views/highlighting/styles.css.erb b/app/views/highlighting/styles.css.erbindex cfd9dc5e4b3..e289b000caf 100644--- a/app/views/highlighting/styles.css.erb+++ b/app/views/highlighting/styles.css.erb@@ -3,7 +3,7 @@<%= resources_scope_color_css("priority", ::IssuePriority) %><%= resources_scope_color_css("type", ::Type, inline_foreground: true) %><%# Color coded icons %>-<%= resources_scope_color_css("project_phase_definition", Project::PhaseDefinition, inline_foreground: true) %>+<%= project_phase_color_css %><% Meetings::Statuses::AVAILABLE.each do |meeting_status| %><%= resource_color_css("meeting_status", meeting_status) %>diff --git a/frontend/src/app/shared/components/fields/display/field-types/project-phase-display-field.module.ts b/frontend/src/app/shared/components/fields/display/field-types/project-phase-display-field.module.tsindex 0bc690b452f..e875c214fcc 100644--- a/frontend/src/app/shared/components/fields/display/field-types/project-phase-display-field.module.ts+++ b/frontend/src/app/shared/components/fields/display/field-types/project-phase-display-field.module.ts@@ -57,14 +57,21 @@ export class ProjectPhaseDisplayField extends DisplayField {const projectPhase = this.attribute as ProjectPhaseResource;const icon = document.createElement('span');- if (projectPhase && projectPhase.definition) {- icon.classList.add(`__hl_inline_project_phase_definition_${projectPhase.definition.id}`, 'mr-1');+ if (projectPhase) {+ icon.classList.add('mr-1');icon.innerHTML = toDOMString(opPhaseIconData,'small',{ 'aria-hidden': 'true', class: 'octicon' },);++ // Use a base64 encoded string of the project phase name to access the definition's color.+ // That way the frontend does not have to load the definitions to get the color.+ // The name is guaranteed to be unique.+ // The = signs at the end of the base64 string are replaced with _ to make it a valid class name.+ // This needs to be kept in sync with the ColorsHelper#project_phase_color_css method in the backend.+ icon.classList.add(`__hl_inline_project_phase_definition_${btoa(projectPhase.name).replace(/=/g, '_')}`);}return icon;