mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 03:30:14 +00:00
move the identifier dialog action to identifier controller
This commit is contained in:
@@ -59,7 +59,7 @@ See COPYRIGHT and LICENSE files for more details.
|
||||
%>
|
||||
<%= render(Primer::Beta::Button.new(
|
||||
tag: :a,
|
||||
href: projects_identifier_dialog_path(project_id: project),
|
||||
href: identifier_update_dialog_project_identifier_path(project_id: project),
|
||||
data: { turbo_stream: true }
|
||||
)) { t("projects.settings.change_identifier") } %>
|
||||
<% end %>
|
||||
|
||||
@@ -34,6 +34,10 @@ class Projects::IdentifierController < ApplicationController
|
||||
before_action :find_project_by_project_id
|
||||
before_action :authorize
|
||||
|
||||
def identifier_update_dialog
|
||||
respond_with_dialog Projects::Settings::ChangeIdentifierDialogComponent.new(project: @project)
|
||||
end
|
||||
|
||||
def update
|
||||
service_call = Projects::UpdateService
|
||||
.new(user: current_user,
|
||||
@@ -43,11 +47,9 @@ class Projects::IdentifierController < ApplicationController
|
||||
if service_call.success?
|
||||
flash[:notice] = I18n.t(:notice_successful_update)
|
||||
redirect_to project_settings_general_path(@project)
|
||||
elsif OpenProject::FeatureDecisions.semantic_work_package_ids_active? # Handle error for the new modal
|
||||
else
|
||||
respond_with_dialog Projects::Settings::ChangeIdentifierDialogComponent.new(project: @project),
|
||||
status: :unprocessable_entity
|
||||
else # Handle error for the legacy standalone identifier setting page
|
||||
render action: "show", status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -34,12 +34,11 @@ class ProjectsController < ApplicationController
|
||||
menu_item :overview
|
||||
menu_item :roadmap, only: :roadmap
|
||||
|
||||
before_action :find_project, except: %i[index new create destroy destroy_info identifier_dialog]
|
||||
before_action :find_project_by_project_id, only: %i[identifier_dialog]
|
||||
before_action :find_project, except: %i[index new create destroy destroy_info]
|
||||
before_action :find_project_including_archived, only: %i[destroy destroy_info]
|
||||
before_action :load_query_or_deny_access, only: %i[index]
|
||||
before_action :authorize,
|
||||
only: %i[copy_form copy deactivate_work_package_attachments export_project_initiation_pdf identifier_dialog]
|
||||
only: %i[copy_form copy deactivate_work_package_attachments export_project_initiation_pdf]
|
||||
before_action :authorize_global, only: %i[new create]
|
||||
before_action :require_admin, only: %i[destroy destroy_info]
|
||||
before_action :find_optional_parent, only: :new
|
||||
@@ -162,10 +161,6 @@ class ProjectsController < ApplicationController
|
||||
respond_with_dialog Projects::DeleteDialogComponent.new(project: @project)
|
||||
end
|
||||
|
||||
def identifier_dialog
|
||||
respond_with_dialog Projects::Settings::ChangeIdentifierDialogComponent.new(project: @project)
|
||||
end
|
||||
|
||||
def deactivate_work_package_attachments
|
||||
call = Projects::UpdateService
|
||||
.new(user: current_user, model: @project, contract_class: Projects::SettingsContract)
|
||||
|
||||
@@ -48,7 +48,7 @@ class Project < ApplicationRecord
|
||||
SEMANTIC_IDENTIFIER_MAX_LENGTH = 10
|
||||
|
||||
# reserved identifiers
|
||||
RESERVED_IDENTIFIERS = %w[new menu queries filters identifier_dialog].freeze
|
||||
RESERVED_IDENTIFIERS = %w[new menu queries filters identifier_update_dialog].freeze
|
||||
|
||||
enum :workspace_type, {
|
||||
project: "project",
|
||||
|
||||
@@ -137,8 +137,7 @@ Rails.application.reloader.to_prepare do
|
||||
"projects/settings/subitems": %i[show update],
|
||||
"projects/settings/template": %i[show update toggle_template],
|
||||
"projects/templated": %i[create destroy],
|
||||
"projects/identifier": %i[show update update_identifier_dialog],
|
||||
projects: %i[identifier_dialog],
|
||||
"projects/identifier": %i[show update identifier_update_dialog],
|
||||
"projects/status": %i[update destroy]
|
||||
},
|
||||
permissible_on: :project,
|
||||
|
||||
+3
-4
@@ -283,9 +283,6 @@ Rails.application.routes.draw do
|
||||
namespace :projects do
|
||||
resource :menu, only: %i[show]
|
||||
resource :filters, only: %i[show]
|
||||
get "identifier_dialog", to: "/projects#identifier_dialog",
|
||||
as: :identifier_dialog,
|
||||
defaults: { format: :turbo_stream }
|
||||
end
|
||||
|
||||
%w[portfolio project program].each do |workspace_type|
|
||||
@@ -357,7 +354,9 @@ Rails.application.routes.draw do
|
||||
get :dialog
|
||||
end
|
||||
end
|
||||
resource :identifier, only: %i[show update], controller: "identifier"
|
||||
resource :identifier, only: %i[show update], controller: "identifier" do
|
||||
get :identifier_update_dialog, on: :member, defaults: { format: :turbo_stream }
|
||||
end
|
||||
resource :status, only: %i[update destroy], controller: "status"
|
||||
resource :creation_wizard, only: %i[show update], controller: "creation_wizard" do
|
||||
get :help_text, on: :member
|
||||
|
||||
Reference in New Issue
Block a user