-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
294 additions
and
1 deletion.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
app/components/settings/project_life_cycle_step_definitions/form_header_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
++#%> | ||
|
||
<% html_title t(:label_administration), | ||
t("settings.project_life_cycle_step_definitions.heading"), | ||
t("settings.project_life_cycle_step_definitions.#{heading_scope}.heading") %> | ||
|
||
<%= component_wrapper do | ||
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 | ||
end %> |
55 changes: 55 additions & 0 deletions
55
app/components/settings/project_life_cycle_step_definitions/form_header_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#-- 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 ApplicationHelper | ||
include MetaTagsHelper | ||
include OpPrimer::ComponentHelpers | ||
include OpTurbo::Streamable | ||
|
||
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") }, | ||
Check notice on line 49 in app/components/settings/project_life_cycle_step_definitions/form_header_component.rb GitHub Actions / rubocop[rubocop] app/components/settings/project_life_cycle_step_definitions/form_header_component.rb#L49 <Layout/LineLength>
Raw output
|
||
t("settings.project_life_cycle_step_definitions.#{heading_scope}.heading") | ||
] | ||
end | ||
end | ||
end | ||
end |
87 changes: 87 additions & 0 deletions
87
app/controllers/admin/settings/project_life_cycle_step_definitions_controller.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
40 changes: 40 additions & 0 deletions
40
app/views/admin/settings/project_life_cycle_step_definitions/form.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
%> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters