新增:项目标记接口
This commit is contained in:
parent
af67d984b4
commit
fe972f1141
|
@ -0,0 +1,27 @@
|
|||
class Api::V1::Issues::IssueTagsController < Api::V1::BaseController
|
||||
|
||||
before_action :require_public_and_member_above, only: [:index]
|
||||
|
||||
def index
|
||||
@issue_tags = @project.issue_tags.order("#{order_by} #{order_direction}")
|
||||
if params[:only_name]
|
||||
@issue_tags = kaminary_select_paginate(@issue_tags.select(:id, :name))
|
||||
else
|
||||
@issue_tags = kaminari_paginate(@issue_tags)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
def order_by
|
||||
order_by = params.fetch(:order_by, "created_at")
|
||||
order_by = IssueTag.column_names.include?(order_by) ? order_by : "created_at"
|
||||
order_by
|
||||
end
|
||||
|
||||
def order_direction
|
||||
order_direction = params.fetch(:order_direction, "desc").downcase
|
||||
order_direction = %w(desc asc).include?(order_direction) ? order_direction : "desc"
|
||||
order_direction
|
||||
end
|
||||
end
|
|
@ -0,0 +1 @@
|
|||
json.(tag, :id, :name)
|
|
@ -0,0 +1,6 @@
|
|||
json.total_count @issue_tags.total_count
|
||||
json.issue_tags @issue_tags.each do |tag|
|
||||
if params[:only_name]
|
||||
json.partial! "simple_detail", locals: {tag: tag}
|
||||
end
|
||||
end
|
|
@ -29,6 +29,7 @@ defaults format: :json do
|
|||
scope module: :projects do
|
||||
resources :issues
|
||||
scope module: :issues do
|
||||
resources :issue_tags, only: [:index]
|
||||
resources :milestones, except: [:new, :edit]
|
||||
resources :issue_statues, only: [:index], controller: '/api/v1/issues/statues'
|
||||
resources :issue_authors, only: [:index], controller: '/api/v1/issues/authors'
|
||||
|
|
Loading…
Reference in New Issue