diff --git a/app/controllers/api/pm/issues_controller.rb b/app/controllers/api/pm/issues_controller.rb index 0d00d93eb..c9192ad94 100644 --- a/app/controllers/api/pm/issues_controller.rb +++ b/app/controllers/api/pm/issues_controller.rb @@ -1,7 +1,7 @@ class Api::Pm::IssuesController < Api::Pm::BaseController before_action :require_login, except: [:index] before_action :load_project - before_action :load_issue, only: %i[show update destroy link_index] + before_action :load_issue, only: %i[show update destroy link_index link_issues] before_action :load_issues, only: %i[batch_update batch_destroy] before_action :check_issue_operate_permission, only: %i[update destroy] @@ -32,6 +32,19 @@ class Api::Pm::IssuesController < Api::Pm::BaseController render 'api/v1/issues/index' end + def link_issues + pm_issue_type = params[:pm_issue_type] || [1, 2, 3] + not_join_id = Issue.where(root_id: @issue.id).pluck(:id) + not_join_id << @issue.id + object_issues = Issue.where( + pm_project_id: params[:pm_project_id], + root_id: nil, + pm_issue_type: pm_issue_type + ).where.not(id: not_join_id) + @issues = kaminari_paginate(object_issues) + render 'api/v1/issues/index' + end + def show @issue.associate_attachment_container diff --git a/config/routes/api.rb b/config/routes/api.rb index 2a08425c4..3a9b4ed88 100644 --- a/config/routes/api.rb +++ b/config/routes/api.rb @@ -11,6 +11,7 @@ defaults format: :json do end member do get :link_index + get :link_issues end resources :issue_links