新增:标记管理接口,以及列表下拉框搜索参数
This commit is contained in:
parent
2899f3b18e
commit
2a8e0d2be8
|
@ -5,7 +5,8 @@ class Api::V1::Issues::AssignersController < Api::V1::BaseController
|
||||||
# 负责人列表
|
# 负责人列表
|
||||||
def index
|
def index
|
||||||
@assigners = User.joins(assigned_issues: :project).where(projects: {id: @project&.id})
|
@assigners = User.joins(assigned_issues: :project).where(projects: {id: @project&.id})
|
||||||
@assigners = @assigners.order("users.id=#{current_user.id} desc, issue_assigners.created_at desc").distinct
|
@assigners = @assigners.order("users.id=#{current_user.id} desc").distinct
|
||||||
|
@assigners = @assigners.ransack(login_or_nickname_cont: params[:keyword]).result if params[:keyword].present?
|
||||||
@assigners = kaminary_select_paginate(@assigners)
|
@assigners = kaminary_select_paginate(@assigners)
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -5,6 +5,7 @@ class Api::V1::Issues::AuthorsController < Api::V1::BaseController
|
||||||
def index
|
def index
|
||||||
@authors = User.joins(issues: :project).where(projects: {id: @project&.id})
|
@authors = User.joins(issues: :project).where(projects: {id: @project&.id})
|
||||||
@authors = @authors.order("users.id=#{current_user.id} desc").distinct
|
@authors = @authors.order("users.id=#{current_user.id} desc").distinct
|
||||||
|
@authors = @authors.ransack(login_or_nickname_cont: params[:keyword]).result if params[:keyword].present?
|
||||||
@authors = kaminary_select_paginate(@authors)
|
@authors = kaminary_select_paginate(@authors)
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -4,6 +4,7 @@ class Api::V1::Issues::IssuePrioritiesController < Api::V1::BaseController
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@priorities = IssuePriority.order(position: :asc)
|
@priorities = IssuePriority.order(position: :asc)
|
||||||
|
@priorities = @priorities.ransack(name_cont: params[:keyword]).result if params[:keyword]
|
||||||
@priorities = kaminary_select_paginate(@priorities)
|
@priorities = kaminary_select_paginate(@priorities)
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,13 +1,42 @@
|
||||||
class Api::V1::Issues::IssueTagsController < Api::V1::BaseController
|
class Api::V1::Issues::IssueTagsController < Api::V1::BaseController
|
||||||
|
|
||||||
before_action :require_public_and_member_above, only: [:index]
|
before_action :require_public_and_member_above, only: [:index, :create, :update, :destroy]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@issue_tags = @project.issue_tags.order("#{order_by} #{order_direction}")
|
@issue_tags = @project.issue_tags.order("#{order_by} #{order_direction}")
|
||||||
|
@issue_tags = @issue_tags.ransack(name_cont: params[:keyword]).result if params[:keyword].present?
|
||||||
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
|
||||||
@issue_tags = kaminari_paginate(@issue_tags)
|
@issue_tags = kaminari_paginate(@issue_tags.includes(:project, :user))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def create
|
||||||
|
@issue_tag = @project.issue_tags.new(issue_tag_params)
|
||||||
|
if @issue_tag.save!
|
||||||
|
render_ok
|
||||||
|
else
|
||||||
|
render_error("创建标记失败!")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
before_action :load_issue_tag, only: [:update, :destroy]
|
||||||
|
|
||||||
|
def update
|
||||||
|
@issue_tag.attributes = issue_tag_params
|
||||||
|
if @issue_tag.save!
|
||||||
|
render_ok
|
||||||
|
else
|
||||||
|
render_error("更新标记失败!")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def destroy
|
||||||
|
if @issue_tag.destroy!
|
||||||
|
render_ok
|
||||||
|
else
|
||||||
|
render_error("删除标记失败!")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -24,4 +53,12 @@ class Api::V1::Issues::IssueTagsController < Api::V1::BaseController
|
||||||
order_direction = %w(desc asc).include?(order_direction) ? order_direction : "desc"
|
order_direction = %w(desc asc).include?(order_direction) ? order_direction : "desc"
|
||||||
order_direction
|
order_direction
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def issue_tag_params
|
||||||
|
params.permit(:name, :description, :color)
|
||||||
|
end
|
||||||
|
|
||||||
|
def load_issue_tag
|
||||||
|
@issue_tag = @project.issue_tags.find_by_id(params[:id])
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -8,6 +8,7 @@ class Api::V1::Issues::MilestonesController < Api::V1::BaseController
|
||||||
else
|
else
|
||||||
@milestones = @project.versions.includes(:issues)
|
@milestones = @project.versions.includes(:issues)
|
||||||
end
|
end
|
||||||
|
@milestones = @milestones.ransack(name_or_description_cont: params[:keyword]).result if params[:keyword].present?
|
||||||
@milestones = kaminary_select_paginate(@milestones)
|
@milestones = kaminary_select_paginate(@milestones)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ class Api::V1::Issues::StatuesController < Api::V1::BaseController
|
||||||
# 状态列表
|
# 状态列表
|
||||||
def index
|
def index
|
||||||
@statues = IssueStatus.order("position asc")
|
@statues = IssueStatus.order("position asc")
|
||||||
|
@statues = @statues.ransack(name_cont: params[:keyword]).result if params[:keyword].present?
|
||||||
@statues = kaminary_select_paginate(@statues)
|
@statues = kaminary_select_paginate(@statues)
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -24,5 +24,6 @@ class IssueTag < ApplicationRecord
|
||||||
has_many :issue_tags_relates, dependent: :destroy
|
has_many :issue_tags_relates, dependent: :destroy
|
||||||
has_many :issues, through: :issue_tags_relates
|
has_many :issues, through: :issue_tags_relates
|
||||||
belongs_to :project, optional: true, counter_cache: true
|
belongs_to :project, optional: true, counter_cache: true
|
||||||
|
belongs_to :user, optional: true
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Users::RegisterService < ApplicationService
|
||||||
namespace = strip(@namespace)
|
namespace = strip(@namespace)
|
||||||
password = strip(@password)
|
password = strip(@password)
|
||||||
|
|
||||||
# Rails.logger.info "Users::RegisterService params: ##### #{params} "
|
Rails.logger.info "Users::RegisterService params: ##### #{params} "
|
||||||
|
|
||||||
email, phone =
|
email, phone =
|
||||||
if register_type == 1
|
if register_type == 1
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
json.(tag, :name, :description, :color, :issues_count)
|
||||||
|
json.project do
|
||||||
|
if tag.project.present?
|
||||||
|
json.partial! "api/v1/projects/simple_detail", project: tag.project
|
||||||
|
else
|
||||||
|
json.nil!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
json.user do
|
||||||
|
if tag.user.present?
|
||||||
|
json.partial! "api/v1/users/simple_user", user: tag.user
|
||||||
|
else
|
||||||
|
json.nil!
|
||||||
|
end
|
||||||
|
end
|
||||||
|
json.created_at tag.created_at.strftime("%Y-%m-%d %H:%M")
|
||||||
|
json.updated_at tag.updated_at.strftime("%Y-%m-%d %H:%M")
|
|
@ -2,5 +2,7 @@ json.total_count @issue_tags.total_count
|
||||||
json.issue_tags @issue_tags.each do |tag|
|
json.issue_tags @issue_tags.each do |tag|
|
||||||
if params[:only_name]
|
if params[:only_name]
|
||||||
json.partial! "simple_detail", locals: {tag: tag}
|
json.partial! "simple_detail", locals: {tag: tag}
|
||||||
|
else
|
||||||
|
json.partial! "detail", locals: {tag: tag}
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -32,7 +32,7 @@ defaults format: :json do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
scope module: :issues do
|
scope module: :issues do
|
||||||
resources :issue_tags, only: [:index]
|
resources :issue_tags, except: [:new, :edit]
|
||||||
resources :milestones, except: [:new, :edit]
|
resources :milestones, except: [:new, :edit]
|
||||||
resources :issue_statues, only: [:index], controller: '/api/v1/issues/statues'
|
resources :issue_statues, only: [:index], controller: '/api/v1/issues/statues'
|
||||||
resources :issue_authors, only: [:index], controller: '/api/v1/issues/authors'
|
resources :issue_authors, only: [:index], controller: '/api/v1/issues/authors'
|
||||||
|
|
Loading…
Reference in New Issue