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

add form and new/edit actions

Ivan Kuchinaee3c30a10b6
diff --git a/app/components/settings/project_life_cycle_step_definitions/form_header_component.html.erb b/app/components/settings/project_life_cycle_step_definitions/form_header_component.html.erb
new file mode 100644
index 00000000000..8c2da7abe2e
--- /dev/null
+++ b/app/components/settings/project_life_cycle_step_definitions/form_header_component.html.erb
@@ -0,0 +1,38 @@
+<%#-- 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.
+
+++#%>
+
+<% html_title t(:label_administration),
+ t("settings.project_life_cycle_step_definitions.heading"),
+ t("settings.project_life_cycle_step_definitions.#{heading_scope}.heading") %>
+
+<%= render Primer::OpenProject::PageHeader.new do |header|
+ header.with_title { t("settings.project_life_cycle_step_definitions.#{heading_scope}.heading") }
+ header.with_description { t("settings.project_life_cycle_step_definitions.new.description") }
+ header.with_breadcrumbs(breadcrumbs_items)
+end %>
diff --git a/app/components/settings/project_life_cycle_step_definitions/form_header_component.rb b/app/components/settings/project_life_cycle_step_definitions/form_header_component.rb
new file mode 100644
index 00000000000..33164cc7cce
--- /dev/null
+++ b/app/components/settings/project_life_cycle_step_definitions/form_header_component.rb
@@ -0,0 +1,61 @@
+#-- 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 Settings
+ module ProjectLifeCycleStepDefinitions
+ class FormHeaderComponent < ApplicationComponent
+ include MetaTagsHelper
+
+ def heading_scope
+ action = model.persisted? ? :edit : :new
+
+ type = model.is_a?(Project::StageDefinition) ? :stage : :gate
+
+ "#{action}_#{type}"
+ end
+
+ def breadcrumbs_items
+ [
+ {
+ href: admin_index_path,
+ text: t("label_administration")
+ },
+ {
+ href: admin_settings_project_custom_fields_path,
+ text: t("label_project_plural")
+ },
+ {
+ href: admin_settings_project_life_cycle_step_definitions_path,
+ text: t("settings.project_life_cycle_step_definitions.heading")
+ },
+ t("settings.project_life_cycle_step_definitions.#{heading_scope}.heading")
+ ]
+ end
+ end
+ end
+end
diff --git a/app/controllers/admin/settings/project_life_cycle_step_definitions_controller.rb b/app/controllers/admin/settings/project_life_cycle_step_definitions_controller.rb
new file mode 100644
index 00000000000..1d7360c20fb
--- /dev/null
+++ b/app/controllers/admin/settings/project_life_cycle_step_definitions_controller.rb
@@ -0,0 +1,87 @@
+#-- 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 Admin::Settings
+ class ProjectLifeCycleStepDefinitionsController < ::Admin::SettingsController
+ menu_item :project_life_cycle_step_definitions_settings
+
+ before_action :check_feature_flag
+
+ before_action :find_definition, only: %i[edit update]
+
+ def new_stage
+ @definition = Project::StageDefinition.new
+
+ render :form
+ end
+
+ def new_gate
+ @definition = Project::GateDefinition.new
+
+ render :form
+ end
+
+ def edit
+ render :form
+ end
+
+ def create
+ @definition = Project::LifeCycleStepDefinition.new(definition_params)
+
+ if @definition.save
+ flash[:notice] = I18n.t(:notice_successful_create)
+ redirect_to action: :index
+ else
+ render :form, status: :unprocessable_entity
+ end
+ end
+
+ def update
+ if @definition.update(definition_params)
+ flash[:notice] = I18n.t(:notice_successful_update)
+ redirect_to action: :index
+ else
+ render :form, status: :unprocessable_entity
+ end
+ end
+
+ private
+
+ def check_feature_flag
+ render_404 unless OpenProject::FeatureDecisions.stages_and_gates_active?
+ end
+
+ def find_definition
+ @definition = Project::LifeCycleStepDefinition.find(params[:id])
+ end
+
+ def definition_params
+ params.require(:project_life_cycle_step_definition).permit(:type, :name, :color_id)
+ end
+ end
+end
diff --git a/app/forms/projects/life_cycle_step_definitions/form.rb b/app/forms/projects/life_cycle_step_definitions/form.rb
new file mode 100644
index 00000000000..56e39be9706
--- /dev/null
+++ b/app/forms/projects/life_cycle_step_definitions/form.rb
@@ -0,0 +1,58 @@
+#-- 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::LifeCycleStepDefinitions
+ class Form < ApplicationForm
+ form do |f|
+ f.hidden(name: :type) unless model.persisted?
+
+ f.text_field(
+ label: attribute_name(:name),
+ name: :name,
+ required: true,
+ input_width: :medium
+ )
+
+ f.color_select_list(
+ label: attribute_name(:color),
+ name: :color,
+ required: true
+ )
+
+ f.submit(
+ scheme: :primary,
+ name: :submit,
+ label: submit_label
+ )
+ end
+
+ def submit_label
+ I18n.t(model.persisted? ? :button_update : :button_create)
+ end
+ end
+end
diff --git a/app/views/admin/settings/project_life_cycle_step_definitions/form.html.erb b/app/views/admin/settings/project_life_cycle_step_definitions/form.html.erb
new file mode 100644
index 00000000000..571dadab443
--- /dev/null
+++ b/app/views/admin/settings/project_life_cycle_step_definitions/form.html.erb
@@ -0,0 +1,40 @@
+<%#-- 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.
+
+++#%>
+
+<%= render Settings::ProjectLifeCycleStepDefinitions::FormHeaderComponent.new(@definition) %>
+
+<%= error_messages_for @definition %>
+
+<%=
+ primer_form_with(
+ model: [:admin, :settings, @definition.becomes(Project::LifeCycleStepDefinition)]
+ ) do |f|
+ render Projects::LifeCycleStepDefinitions::Form.new(f)
+ end
+%>
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 835d2b69386..e5328e15e63 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -951,6 +951,9 @@ en:
project_custom_field:
is_required: "Required for all projects"
custom_field_section: Section
+ project/life_cycle_step_definition:
+ name: "Name"
+ color: "Color"
query:
column_names: "Columns"
relations_to_type_column: "Relations to %{type}"
@@ -3773,6 +3776,16 @@ en:
label_add_description: "Add lifecycle definition"
label_add_stage: "Stage"
label_add_gate: "Gate"
+ new:
+ description: "Changes to this project step will be reflected in all projects where it is enabled."
+ new_stage:
+ heading: "New stage"
+ new_gate:
+ heading: "New gate"
+ edit_stage:
+ heading: "Edit stage"
+ edit_gate:
+ heading: "Edit gate"
projects:
missing_dependencies: "Project module %{module} was checked which depends on %{dependencies}. You need to check these dependencies as well."
section_new_projects: "Settings for new projects"