|
|
|
@@ -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 |