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 menu, handle moving and destroying
Ivan Kuchin418374f7bf4a
diff --git a/app/components/settings/project_life_cycle_step_definitions/index_component.html.erb b/app/components/settings/project_life_cycle_step_definitions/index_component.html.erbindex 3780a5e3e8e..21160383e14 100644--- a/app/components/settings/project_life_cycle_step_definitions/index_component.html.erb+++ b/app/components/settings/project_life_cycle_step_definitions/index_component.html.erb@@ -69,7 +69,11 @@ See COPYRIGHT and LICENSE files for more details.elsedefinitions.each do |definition|component.with_row(data: { "projects--settings--border-box-filter-target": "searchItem" }) do- render(Settings::ProjectLifeCycleStepDefinitions::RowComponent.new(definition))+ render(Settings::ProjectLifeCycleStepDefinitions::RowComponent.new(+ definition,+ first?: definition == definitions.first,+ last?: definition == definitions.last,+ ))endendenddiff --git a/app/components/settings/project_life_cycle_step_definitions/row_component.html.erb b/app/components/settings/project_life_cycle_step_definitions/row_component.html.erbindex ec8642a03b8..83b6773ae6d 100644--- a/app/components/settings/project_life_cycle_step_definitions/row_component.html.erb+++ b/app/components/settings/project_life_cycle_step_definitions/row_component.html.erb@@ -46,5 +46,40 @@ See COPYRIGHT and LICENSE files for more details.render(Primer::Beta::Text.new) { t("project.count", count: definition.project_count) }endend+ row_container.with_column do+ render(Primer::Alpha::ActionMenu.new) do |menu|+ menu.with_show_button(icon: "kebab-horizontal", "aria-label": t(:button_actions), scheme: :invisible)++ menu.with_item(+ label: t(:label_edit),+ href: edit_admin_settings_project_life_cycle_step_definition_path(definition)+ ) do |item|+ item.with_leading_visual_icon(icon: :pencil)+ end++ unless first?+ move_action(menu:, move_to: :highest, label: t("label_agenda_item_move_to_top"), icon: "move-to-top")+ move_action(menu:, move_to: :higher, label: t("label_agenda_item_move_up"), icon: "chevron-up")+ end+ unless last?+ move_action(menu:, move_to: :lower, label: t("label_agenda_item_move_down"), icon: "chevron-down")+ move_action(menu:, move_to: :lowest, label: t("label_agenda_item_move_to_bottom"), icon: "move-to-bottom")+ end++ menu.with_item(+ label: t(:text_destroy),+ scheme: :danger,+ href: admin_settings_project_life_cycle_step_definition_path(definition),+ form_arguments: {+ method: :delete,+ data: {+ confirm: t("text_are_you_sure_with_project_life_cycle_step")+ }+ }+ ) do |item|+ item.with_leading_visual_icon(icon: :trash)+ end+ end+ endend%>diff --git a/app/components/settings/project_life_cycle_step_definitions/row_component.rb b/app/components/settings/project_life_cycle_step_definitions/row_component.rbindex 9d2ae086248..1f165751a6c 100644--- a/app/components/settings/project_life_cycle_step_definitions/row_component.rb+++ b/app/components/settings/project_life_cycle_step_definitions/row_component.rb@@ -32,6 +32,22 @@ module Settingsinclude OpPrimer::ComponentHelpersalias_method :definition, :model++ options :first?, :last?++ private++ def move_action(menu:, move_to:, label:, icon:)+ menu.with_item(+ label:,+ href: move_admin_settings_project_life_cycle_step_definition_path(definition, move_to:),+ form_arguments: {+ method: :patch+ }+ ) do |item|+ item.with_leading_visual_icon(icon:)+ end+ endendendenddiff --git a/app/controllers/admin/settings/project_life_cycle_step_definitions_controller.rb b/app/controllers/admin/settings/project_life_cycle_step_definitions_controller.rbindex 6afae30c38d..30c5f31f37b 100644--- a/app/controllers/admin/settings/project_life_cycle_step_definitions_controller.rb+++ b/app/controllers/admin/settings/project_life_cycle_step_definitions_controller.rb@@ -33,7 +33,7 @@ module Admin::Settingsbefore_action :check_feature_flagbefore_action :find_definitions, only: %i[index]- before_action :find_definition, only: %i[edit update]+ before_action :find_definition, only: %i[edit update destroy move]def index; end@@ -73,6 +73,28 @@ module Admin::Settingsendend+ def destroy+ if @definition.destroy+ flash[:notice] = I18n.t(:notice_successful_delete)+ else+ # TODO: handle better+ flash[:error] = I18n.t(:notice_bad_request)+ end++ redirect_to action: :index+ end++ def move+ if @definition.update(params.permit(:move_to))+ flash[:notice] = I18n.t(:notice_successful_update)+ else+ # TODO: handle better+ flash[:error] = I18n.t(:notice_bad_request)+ end++ redirect_to action: :index+ end+privatedef check_feature_flagdiff --git a/config/locales/en.yml b/config/locales/en.ymlindex 16d48fbec46..6f6a63d212c 100644--- a/config/locales/en.yml+++ b/config/locales/en.yml@@ -3827,6 +3827,7 @@ en:text_are_you_sure_continue: "Are you sure you want to continue?"text_are_you_sure_with_children: "Delete work package and all child work packages?"text_are_you_sure_with_project_custom_fields: "Deleting this attribute will also delete its values in all projects. Are you sure you want to do this?"+ text_are_you_sure_with_project_life_cycle_step: "Deleting this step will also delete its usages in all projects. Are you sure you want to do this?"text_assign_to_project: "Assign to the project"text_form_configuration: >You can customize which fields will be displayed in work package forms.diff --git a/config/routes.rb b/config/routes.rbindex 010880a0eac..0422fcab42a 100644--- a/config/routes.rb+++ b/config/routes.rb@@ -515,11 +515,14 @@ Rails.application.routes.draw doresource :projects, controller: "/admin/settings/projects_settings", only: %i[show update]resource :new_project, controller: "/admin/settings/new_project_settings", only: %i[show update]resources :project_life_cycle_step_definitions, controller: "/admin/settings/project_life_cycle_step_definitions",- only: %i[index create edit update] do+ only: %i[index create edit update destroy] docollection doget :new_stageget :new_gateend+ member do+ patch :move+ endendresources :project_custom_fields, controller: "/admin/settings/project_custom_fields" domember do