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
Display life cycles in the sidebar
Dombi Attila96d1f2eac2cd
diff --git a/app/models/project/gate.rb b/app/models/project/gate.rbindex 46ee6fffdb7..c2342505d2d 100644--- a/app/models/project/gate.rb+++ b/app/models/project/gate.rb@@ -39,4 +39,8 @@ class Project::Gate < Project::LifeCycleSteperrors.add(:base, :end_date_not_allowed)endend++ def not_set?+ date.blank?+ endenddiff --git a/app/models/project/life_cycle_step.rb b/app/models/project/life_cycle_step.rbindex d4ffcf43842..abccc560a70 100644--- a/app/models/project/life_cycle_step.rb+++ b/app/models/project/life_cycle_step.rb@@ -33,6 +33,8 @@ class Project::LifeCycleStep < ApplicationRecordclass_name: "Project::LifeCycleStepDefinition"has_many :work_packages, inverse_of: :project_life_cycle_step, dependent: :nullify+ delegate :name, to: :life_cycle+attr_readonly :definition_id, :typevalidates :type, inclusion: { in: %w[Project::Stage Project::Gate], message: :must_be_a_stage_or_gate }diff --git a/app/models/project/stage.rb b/app/models/project/stage.rbindex b49ca7787b7..cf9e456add5 100644--- a/app/models/project/stage.rb+++ b/app/models/project/stage.rb@@ -30,4 +30,8 @@ class Project::Stage < Project::LifeCycleStep# This ensures the type cannot be changed after initialising the class.validates :type, inclusion: { in: %w[Project::Stage], message: :must_be_a_stage }validates :start_date, :end_date, presence: true++ def not_set?+ start_date.blank? || end_date.blank?+ endenddiff --git a/modules/overviews/app/components/project_life_cycles/sections/project_life_cycles/show_component.html.erb b/modules/overviews/app/components/project_life_cycles/sections/project_life_cycles/show_component.html.erbnew file mode 100644index 00000000000..ac45e374d7d--- /dev/null+++ b/modules/overviews/app/components/project_life_cycles/sections/project_life_cycles/show_component.html.erb@@ -0,0 +1,23 @@+<%=+ flex_layout(align_items: :flex_start,+ justify_content: :space_between,+ classes: 'op-project-life-cycle-container',+ data: {+ test_selector: "project-life-cycle-#{@project_life_cycle.id}"+ }) do |life_cycle_value_container|+ # temporarily using inline styles in order to align the content as desired+ life_cycle_container.with_row(mb: 1) do+ render(Primer::Beta::Text.new(font_weight: :bold)) do+ concat @project_life_cycle.name+ end+ end++ life_cycle_container.with_row(w: :full) do+ if not_set?+ render(Primer::Beta::Text.new()) { t('placeholders.default') }+ else+ render_value+ end+ end+ end+%>diff --git a/modules/overviews/app/components/project_life_cycles/sections/project_life_cycles/show_component.rb b/modules/overviews/app/components/project_life_cycles/sections/project_life_cycles/show_component.rbnew file mode 100644index 00000000000..9f54f071385--- /dev/null+++ b/modules/overviews/app/components/project_life_cycles/sections/project_life_cycles/show_component.rb@@ -0,0 +1,63 @@+#-- copyright+# OpenProject is an open source project management software.+# Copyright (C) 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.+#++++module ProjectLifeCycles+ module Sections+ module ProjectLifeCycles+ class ShowComponent < ApplicationComponent+ include ApplicationHelper+ include OpPrimer::ComponentHelpers++ def initialize(project_life_cycle:)+ super++ @project_life_cycle = project_life_cycle+ end++ private++ def not_set?+ @project_life_cycle.not_set?+ end++ def render_value+ case @project_life_cycle+ when Project::Gate+ render(Primer::Beta::Text.new) do+ concat @project_life_cycle.date+ end+ when Project::Stage+ render(Primer::Beta::Text.new) do+ concat [@project_life_cycle.start_date, " - ", @project_life_cycle.end_date].join+ end+ end+ end+ end+ end+ end+enddiff --git a/modules/overviews/app/components/project_life_cycles/sections/show_component.html.erb b/modules/overviews/app/components/project_life_cycles/sections/show_component.html.erbindex cb1fcd5ac93..4a0c5187d9c 100644--- a/modules/overviews/app/components/project_life_cycles/sections/show_component.html.erb+++ b/modules/overviews/app/components/project_life_cycles/sections/show_component.html.erb@@ -1,31 +1,18 @@<%=component_wrapper dorender(Primer::OpenProject::SidePanel::Section.new(- classes: 'op-project-custom-field-section-container',- test_selector: "project-custom-field-section-#{@project_custom_field_section.id}"+ classes: 'op-project-life-cyle-section-container',+ test_selector: "project-life-cycle-section")) do |section|section.with_title { "Life Cycles" }- if allowed_to_edit?- section.with_action_icon(- icon: :pencil,- tag: :a,- href: project_custom_field_section_dialog_path(project_id: @project.id, section_id: @project_custom_field_section.id),- data: {- controller: 'async-dialog'- },- test_selector: "project-custom-field-section-edit-button",- aria: { label: I18n.t(:label_edit) }- )- endflex_layout do |details_container|- @project_custom_fields.each_with_index do |project_custom_field, i|- margin = i == @project_custom_fields.size - 1 ? 0 : 3+ @project_life_cycles.each_with_index do |project_life_cycle, i|+ margin = i == @project_life_cycles.size - 1 ? 0 : 3details_container.with_row(mb: margin) do- render(ProjectCustomFields::Sections::ProjectCustomFields::ShowComponent.new(- project_custom_field:,- project_custom_field_values: get_eager_loaded_project_custom_field_values_for(project_custom_field.id)+ render(ProjectLifeCycles::Sections::ProjectLifeCycles::ShowComponent.new(+ project_life_cycle:))endenddiff --git a/modules/overviews/app/components/project_life_cycles/sections/show_component.rb b/modules/overviews/app/components/project_life_cycles/sections/show_component.rbindex c629c990fa4..a2788ed9a98 100644--- a/modules/overviews/app/components/project_life_cycles/sections/show_component.rb+++ b/modules/overviews/app/components/project_life_cycles/sections/show_component.rb@@ -33,14 +33,11 @@ module ProjectLifeCyclesinclude OpPrimer::ComponentHelpersinclude OpTurbo::Streamable- def initialize(project:, project_custom_field_section:, project_custom_fields:)+ def initialize(project:)super@project = project- @project_custom_field_section = project_custom_field_section- @project_custom_fields = project_custom_fields-- eager_load_project_custom_field_values+ @project_life_cycles = @project.project_life_cycles.includes(:life_cycle)endprivate@@ -48,21 +45,6 @@ module ProjectLifeCyclesdef allowed_to_edit?User.current.allowed_in_project?(:edit_project_attributes, @project)end-- def eager_load_project_custom_field_values- # TODO: move to service- @eager_loaded_project_custom_field_values = CustomValue- .includes(custom_field: :custom_options)- .where(- custom_field_id: @project_custom_fields.pluck(:id),- customized_id: @project.id- )- .to_a- end-- def get_eager_loaded_project_custom_field_values_for(custom_field_id)- @eager_loaded_project_custom_field_values.select { |pcfv| pcfv.custom_field_id == custom_field_id }- endendendenddiff --git a/modules/overviews/app/components/project_life_cycles/side_panel_component.html.erb b/modules/overviews/app/components/project_life_cycles/side_panel_component.html.erbindex 8af7ed711e3..763a30ed12c 100644--- a/modules/overviews/app/components/project_life_cycles/side_panel_component.html.erb+++ b/modules/overviews/app/components/project_life_cycles/side_panel_component.html.erb@@ -1,20 +1,10 @@<%=component_wrapper do- if available_project_custom_fields_grouped_by_section.any?- render(Primer::OpenProject::SidePanel.new(- spacious: true,- test_selector: "project-life-cycles-sidebar-async-content"- )) do |panel|- available_project_custom_fields_grouped_by_section.each do |project_custom_field_section, project_custom_fields|- panel.with_section(- ProjectLifeCycles::Sections::ShowComponent.new(- project: @project,- project_custom_field_section:,- project_custom_fields: project_custom_fields- )- )- end- end+ render(Primer::OpenProject::SidePanel.new(+ spacious: true,+ test_selector: "project-life-cycles-sidebar-async-content"+ )) do |panel|+ panel.with_section(ProjectLifeCycles::Sections::ShowComponent.new(project: @project))endend%>diff --git a/modules/overviews/app/components/project_life_cycles/side_panel_component.rb b/modules/overviews/app/components/project_life_cycles/side_panel_component.rbindex c21cba59c50..d837969ffa3 100644--- a/modules/overviews/app/components/project_life_cycles/side_panel_component.rb+++ b/modules/overviews/app/components/project_life_cycles/side_panel_component.rb@@ -37,12 +37,5 @@ module ProjectLifeCycles@project = projectend-- private-- def available_project_custom_fields_grouped_by_section- @available_project_custom_fields_grouped_by_section ||=- @project.available_custom_fields.group_by(&:project_custom_field_section)- endendend