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 Coloured icons, initial rendering of the form fields
Dombi Attila002fdf35f412
diff --git a/app/forms/application_form.rb b/app/forms/application_form.rbindex cb52b5b980f..2fe86546d08 100644--- a/app/forms/application_form.rb+++ b/app/forms/application_form.rb@@ -40,6 +40,11 @@ class ApplicationForm < Primer::Forms::BaseRails.application.routes.url_helpersend+ # @return [ActionView::Base] the view helper instance+ def helpers+ @view_context.helpers+ end+# @return [ActiveRecord::Base] the model instance given to the form builderdef model@builder.objectdiff --git a/app/forms/projects/life_cycles/form.rb b/app/forms/projects/life_cycles/form.rbnew file mode 100644index 00000000000..989e0a2267c--- /dev/null+++ b/app/forms/projects/life_cycles/form.rb@@ -0,0 +1,81 @@+#-- 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 Projects::LifeCycles+ class Form < ApplicationForm+ form do |f|+ life_cycle_input(f)+ end++ private++ def life_cycle_input(form)+ case model+ when Project::Stage+ multi_value_life_cycle_input(form)+ when Project::Gate+ single_value_life_cycle_input(form)+ else+ raise NotImplementedError, "Unknown life cycle definition type #{model.class.name}"+ end+ end++ def single_value_life_cycle_input(form)+ form.text_field name: :date, label: "#{icon} #{text}".html_safe, type: :date # rubocop:disable Rails/OutputSafety+ end++ def multi_value_life_cycle_input(form)+ helpers.angular_component_tag "opce-range-date-picker",+ inputs: {+ name: "my-datepicker",+ value: model.start_date+ }+ form.text_field name: :start_date, label: "#{icon} #{text}".html_safe, type: :date # rubocop:disable Rails/OutputSafety+ end++ def text+ model.name+ end++ def icon+ icon_name = case model+ when Project::Stage+ :"git-commit"+ when Project::Gate+ :diamond+ else+ raise NotImplementedError, "Unknown model #{model.class} to render a LifeCycleForm with"+ end++ render Primer::Beta::Octicon.new(icon: icon_name, classes: icon_color_class)+ end++ def icon_color_class+ helpers.hl_inline_class("life_cycle_step_definition", model.definition)+ end+ end+enddiff --git a/app/models/project.rb b/app/models/project.rbindex 89191c1eba8..78ec43158e8 100644--- a/app/models/project.rb+++ b/app/models/project.rb@@ -88,6 +88,8 @@ class Project < ApplicationRecordhas_many :storages, through: :project_storageshas_many :life_cycle_steps, class_name: "Project::LifeCycleStep", dependent: :destroy+ accepts_nested_attributes_for :life_cycle_steps+store_attribute :settings, :deactivate_work_package_attachments, :booleanacts_as_favorablediff --git a/modules/overviews/app/components/project_life_cycles/sections/edit_component.html.erb b/modules/overviews/app/components/project_life_cycles/sections/edit_component.html.erbnew file mode 100644index 00000000000..27eb079bfd7--- /dev/null+++ b/modules/overviews/app/components/project_life_cycles/sections/edit_component.html.erb@@ -0,0 +1,18 @@+<%= helpers.angular_component_tag 'opce-custom-modal-overlay' %>+<%=+ component_wrapper do+ primer_form_with(+ id: "project-life-cycles-edit-form",+ model:,+ method: :put,+ data: { turbo: true, turbo_stream: true, "test-selector": "async-dialog-content" },+ url: update_project_life_cycles_path(project_id: model.id),+ ) do |f|+ render(Primer::Forms::SpacingWrapper.new) do+ f.fields_for(:life_cycle_steps, life_cycle_steps) do |lcf|+ render(Projects::LifeCycles::Form.new(lcf))+ end+ end+ end+ end+%>diff --git a/modules/overviews/app/components/project_life_cycles/sections/edit_component.rb b/modules/overviews/app/components/project_life_cycles/sections/edit_component.rbnew file mode 100644index 00000000000..d0016f8b313--- /dev/null+++ b/modules/overviews/app/components/project_life_cycles/sections/edit_component.rb@@ -0,0 +1,41 @@+#-- 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+ class EditComponent < ApplicationComponent+ include ApplicationHelper+ include OpTurbo::Streamable+ include OpPrimer::ComponentHelpers++ def life_cycle_steps+ model.life_cycle_steps.active.eager_load(:definition).order(position: :asc)+ end+ end+ end+enddiff --git a/modules/overviews/app/components/project_life_cycles/sections/edit_dialog_component.html.erb b/modules/overviews/app/components/project_life_cycles/sections/edit_dialog_component.html.erbnew file mode 100644index 00000000000..0e51a1686c9--- /dev/null+++ b/modules/overviews/app/components/project_life_cycles/sections/edit_dialog_component.html.erb@@ -0,0 +1,32 @@+<%=+ render(Primer::Alpha::Dialog.new(title: t("label_life_cycle_plural"),+ size: :medium_portrait,+ id: "edit-project-life-cycles-dialog")) do |d|+ d.with_header(variant: :large)+ d.with_body(classes: "Overlay-body_autocomplete_height") do+ render(::ProjectLifeCycles::Sections::EditComponent.new(model))+ end+ d.with_footer do+ component_collection do |footer_collection|+ footer_collection.with_component(Primer::ButtonComponent.new(+ data: {+ 'close-dialog-id': "edit-project-life-cycles-dialog"+ }+ )) do+ t("button_cancel")+ end+ footer_collection.with_component(Primer::ButtonComponent.new(+ scheme: :primary,+ type: :submit,+ form: "project-life-cycles-edit-form",+ data: {+ test_selector: 'save-project-life-cycles-button',+ turbo: true+ }+ )) do+ t("button_save")+ end+ end+ end+ end+%>diff --git a/modules/overviews/app/components/project_life_cycles/sections/edit_dialog_component.rb b/modules/overviews/app/components/project_life_cycles/sections/edit_dialog_component.rbnew file mode 100644index 00000000000..584b01af793--- /dev/null+++ b/modules/overviews/app/components/project_life_cycles/sections/edit_dialog_component.rb@@ -0,0 +1,37 @@+#-- 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+ class EditDialogComponent < ApplicationComponent+ include ApplicationHelper+ include OpTurbo::Streamable+ include OpPrimer::ComponentHelpers+ end+ end+enddiff --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.erbindex 00e6527f89f..ea3f87c3b8a 100644--- 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.erb@@ -3,12 +3,17 @@justify_content: :space_between,classes: 'op-project-life-cycle-container',data: {- test_selector: "project-life-cycle-#{@life_cycle_step.id}"+ test_selector: "project-life-cycle-#{model.id}"}) do |life_cycle_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 @life_cycle_step.name+ life_cycle_container.with_row(mb: 1, flex_layout: true, ) do |row|+ row.with_column(mr: 1, classes: icon_color_class) do+ render Primer::Beta::Octicon.new(icon:)+ end++ row.with_column do+ render(Primer::Beta::Text.new(font_weight: :bold)) do+ text+ endendenddiff --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.rbindex 0cff2b6d13a..4c2e552c8d8 100644--- 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.rb@@ -33,33 +33,46 @@ module ProjectLifeCyclesinclude ApplicationHelperinclude OpPrimer::ComponentHelpers- def initialize(life_cycle_step:)- super-- @life_cycle_step = life_cycle_step- end-privatedef not_set?- @life_cycle_step.not_set?+ model.not_set?enddef render_value- case @life_cycle_step+ case modelwhen Project::Gaterender(Primer::Beta::Text.new) do- concat helpers.format_date(@life_cycle_step.date)+ concat helpers.format_date(model.date)endwhen Project::Stagerender(Primer::Beta::Text.new) doconcat [- helpers.format_date(@life_cycle_step.start_date),- helpers.format_date(@life_cycle_step.end_date)+ helpers.format_date(model.start_date),+ helpers.format_date(model.end_date)].join(" - ")endendend++ def icon+ case model+ when Project::Stage+ :"git-commit"+ when Project::Gate+ :diamond+ else+ raise NotImplementedError, "Unknown model #{model.class} to render a LifeCycleForm with"+ end+ end++ def icon_color_class+ helpers.hl_inline_class("life_cycle_step_definition", model.definition)+ end++ def text+ model.name+ endendendenddiff --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 05fe5aa93fc..2724aaa0aaf 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@@ -4,7 +4,7 @@classes: 'op-project-life-cyle-section-container',test_selector: "project-life-cycle-section")) do |section|- section.with_title { t('label_life_cycle_plural') }+ section.with_title { t("label_life_cycle_plural") }if allowed_to_edit?section.with_action_icon(@@ -24,7 +24,7 @@margin = i == @life_cycle_steps.size - 1 ? 0 : 3details_container.with_row(mb: margin) dorender(ProjectLifeCycles::Sections::ProjectLifeCycles::ShowComponent.new(- life_cycle_step:+ life_cycle_step))endenddiff --git a/modules/overviews/app/controllers/overviews/overviews_controller.rb b/modules/overviews/app/controllers/overviews/overviews_controller.rbindex 62cb78ce110..c45c1390160 100644--- a/modules/overviews/app/controllers/overviews/overviews_controller.rb+++ b/modules/overviews/app/controllers/overviews/overviews_controller.rb@@ -83,10 +83,7 @@ module ::Overviewsdef project_life_cycles_dialogrespond_with_dialog(- ProjectCustomFields::Sections::EditDialogComponent.new(- project: @project,- project_custom_field_section: ProjectCustomFieldSection.first- )+ ProjectLifeCycles::Sections::EditDialogComponent.new(@project))end