This commit is contained in:
parent
e53d6cd763
commit
267279df2d
|
@ -4,8 +4,8 @@ class Api::V1::Issues::IssueTagsController < Api::V1::BaseController
|
||||||
before_action :require_operate_above, only: [:create, :update, :destroy]
|
before_action :require_operate_above, only: [:create, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@issue_tags = @project.issue_tags.order("#{order_by} #{order_direction}")
|
|
||||||
@issue_tags = @issue_tags.ransack(name_cont: params[:keyword]).result if params[:keyword].present?
|
@issue_tags = @issue_tags.ransack(name_cont: params[:keyword]).result if params[:keyword].present?
|
||||||
|
@issue_tags = @project.issue_tags.reorder("#{sort_by} #{sort_direction}")
|
||||||
if params[:only_name]
|
if params[:only_name]
|
||||||
@issue_tags = kaminary_select_paginate(@issue_tags.select(:id, :name, :color))
|
@issue_tags = kaminary_select_paginate(@issue_tags.select(:id, :name, :color))
|
||||||
else
|
else
|
||||||
|
@ -43,16 +43,16 @@ class Api::V1::Issues::IssueTagsController < Api::V1::BaseController
|
||||||
|
|
||||||
|
|
||||||
private
|
private
|
||||||
def order_by
|
def sort_by
|
||||||
order_by = params.fetch(:order_by, "created_at")
|
sort_by = params.fetch(:sort_by, "created_at")
|
||||||
order_by = IssueTag.column_names.include?(order_by) ? order_by : "created_at"
|
sort_by = IssueTag.column_names.include?(sort_by) ? sort_by : "created_at"
|
||||||
order_by
|
sort_by
|
||||||
end
|
end
|
||||||
|
|
||||||
def order_direction
|
def sort_direction
|
||||||
order_direction = params.fetch(:order_direction, "desc").downcase
|
sort_direction = params.fetch(:sort_direction, "desc").downcase
|
||||||
order_direction = %w(desc asc).include?(order_direction) ? order_direction : "desc"
|
sort_direction = %w(desc asc).include?(sort_direction) ? sort_direction : "desc"
|
||||||
order_direction
|
sort_direction
|
||||||
end
|
end
|
||||||
|
|
||||||
def issue_tag_params
|
def issue_tag_params
|
||||||
|
|
|
@ -70,9 +70,9 @@ class Api::V1::Issues::ListService < ApplicationService
|
||||||
# keyword
|
# keyword
|
||||||
issues = issues.ransack(subject_or_description_cont: keyword).result if keyword.present?
|
issues = issues.ransack(subject_or_description_cont: keyword).result if keyword.present?
|
||||||
|
|
||||||
@total_issues_count = issues.size
|
@total_issues_count = issues.distinct.size
|
||||||
@closed_issues_count = issues.closed.size
|
@closed_issues_count = issues.closed.distinct.size
|
||||||
@opened_issues_count = issues.opened.size
|
@opened_issues_count = issues.opened.distinct.size
|
||||||
|
|
||||||
case category
|
case category
|
||||||
when 'closed'
|
when 'closed'
|
||||||
|
|
Loading…
Reference in New Issue