mp_index for issue_priorities issue_tags issue_statues
This commit is contained in:
parent
d19c94666a
commit
472499e278
|
@ -7,4 +7,12 @@ class Api::V1::Issues::IssuePrioritiesController < Api::V1::BaseController
|
||||||
@priorities = @priorities.ransack(name_cont: params[:keyword]).result if params[:keyword]
|
@priorities = @priorities.ransack(name_cont: params[:keyword]).result if params[:keyword]
|
||||||
@priorities = kaminary_select_paginate(@priorities)
|
@priorities = kaminary_select_paginate(@priorities)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mp_index
|
||||||
|
@priorities = IssuePriority.order(position: :asc)
|
||||||
|
@priorities = @priorities.ransack(name_cont: params[:keyword]).result if params[:keyword]
|
||||||
|
@priorities = kaminary_select_paginate(@priorities)
|
||||||
|
render "index"
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
|
@ -1,5 +1,5 @@
|
||||||
class Api::V1::Issues::IssueTagsController < Api::V1::BaseController
|
class Api::V1::Issues::IssueTagsController < Api::V1::BaseController
|
||||||
before_action :require_login, except: [:index]
|
before_action :require_login, except: [:index, :mp_index]
|
||||||
before_action :require_public_and_member_above, only: [:index]
|
before_action :require_public_and_member_above, only: [:index]
|
||||||
before_action :require_operate_above, only: [:create, :update, :destroy]
|
before_action :require_operate_above, only: [:create, :update, :destroy]
|
||||||
|
|
||||||
|
@ -13,6 +13,11 @@ class Api::V1::Issues::IssueTagsController < Api::V1::BaseController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mp_index
|
||||||
|
@issue_tags = IssueTag.init_mp_issues_tags
|
||||||
|
render_ok(@issue_tags)
|
||||||
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@issue_tag = @project.issue_tags.new(issue_tag_params)
|
@issue_tag = @project.issue_tags.new(issue_tag_params)
|
||||||
if @issue_tag.save!
|
if @issue_tag.save!
|
||||||
|
|
|
@ -8,4 +8,11 @@ class Api::V1::Issues::StatuesController < Api::V1::BaseController
|
||||||
@statues = @statues.ransack(name_cont: params[:keyword]).result if params[:keyword].present?
|
@statues = @statues.ransack(name_cont: params[:keyword]).result if params[:keyword].present?
|
||||||
@statues = kaminary_select_paginate(@statues)
|
@statues = kaminary_select_paginate(@statues)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def mp_index
|
||||||
|
@statues = IssueStatus.order("position asc")
|
||||||
|
@statues = @statues.ransack(name_cont: params[:keyword]).result if params[:keyword].present?
|
||||||
|
@statues = kaminary_select_paginate(@statues)
|
||||||
|
render "index"
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -32,18 +32,7 @@ class IssueTag < ApplicationRecord
|
||||||
validates :name, uniqueness: {scope: :project_id, message: "已存在" }
|
validates :name, uniqueness: {scope: :project_id, message: "已存在" }
|
||||||
|
|
||||||
def self.init_data(project_id)
|
def self.init_data(project_id)
|
||||||
data = [
|
data = init_issue_tag_data
|
||||||
["缺陷", "表示存在意外问题或错误", "#d92d4c"],
|
|
||||||
["功能", "表示新功能申请", "#ee955a"],
|
|
||||||
["疑问", "表示存在疑惑", "#2d6ddc"],
|
|
||||||
["支持", "表示特定功能或特定需求", "#019549"],
|
|
||||||
["任务", "表示需要分配的任务", "#c1a30d"],
|
|
||||||
["协助", "表示需要社区用户协助", "#2a0dc1"],
|
|
||||||
["搁置", "表示此问题暂时不会继续处理", "#892794"],
|
|
||||||
["文档", "表示文档材料补充", "#9ed600"],
|
|
||||||
["测试", "表示需要测试的需求", "#2897b9"],
|
|
||||||
["重复", "表示已存在类似的疑修", "#bb5332"]
|
|
||||||
]
|
|
||||||
data.each do |item|
|
data.each do |item|
|
||||||
next if IssueTag.exists?(project_id: project_id, name: item[0])
|
next if IssueTag.exists?(project_id: project_id, name: item[0])
|
||||||
IssueTag.create!(project_id: project_id, name: item[0], description: item[1], color: item[2])
|
IssueTag.create!(project_id: project_id, name: item[0], description: item[1], color: item[2])
|
||||||
|
@ -57,6 +46,34 @@ class IssueTag < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
def self.init_issue_tag_data
|
||||||
|
[
|
||||||
|
["缺陷", "表示存在意外问题或错误", "#d92d4c"],
|
||||||
|
["功能", "表示新功能申请", "#ee955a"],
|
||||||
|
["疑问", "表示存在疑惑", "#2d6ddc"],
|
||||||
|
["支持", "表示特定功能或特定需求", "#019549"],
|
||||||
|
["任务", "表示需要分配的任务", "#c1a30d"],
|
||||||
|
["协助", "表示需要社区用户协助", "#2a0dc1"],
|
||||||
|
["搁置", "表示此问题暂时不会继续处理", "#892794"],
|
||||||
|
["文档", "表示文档材料补充", "#9ed600"],
|
||||||
|
["测试", "表示需要测试的需求", "#2897b9"],
|
||||||
|
["重复", "表示已存在类似的疑修", "#bb5332"]
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.init_mp_issues_tags
|
||||||
|
data = {"total_count": 10,}
|
||||||
|
data["issue_tags"] = init_issue_tag_data.map{|item|
|
||||||
|
{
|
||||||
|
"name": item[0],
|
||||||
|
"description": item[1],
|
||||||
|
"color": item[2],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
def to_builder
|
def to_builder
|
||||||
Jbuilder.new do |tag|
|
Jbuilder.new do |tag|
|
||||||
tag.(self, :id, :name, :description)
|
tag.(self, :id, :name, :description)
|
||||||
|
|
|
@ -55,12 +55,24 @@ defaults format: :json do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
scope module: :issues do
|
scope module: :issues do
|
||||||
resources :issue_tags, except: [:new, :edit]
|
resources :issue_tags, except: [:new, :edit] do
|
||||||
|
collection do
|
||||||
|
get :mp_index
|
||||||
|
end
|
||||||
|
end
|
||||||
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' do
|
||||||
|
collection do
|
||||||
|
get :mp_index
|
||||||
|
end
|
||||||
|
end
|
||||||
resources :issue_authors, only: [:index], controller: '/api/v1/issues/authors'
|
resources :issue_authors, only: [:index], controller: '/api/v1/issues/authors'
|
||||||
resources :issue_assigners, only: [:index], controller: '/api/v1/issues/assigners'
|
resources :issue_assigners, only: [:index], controller: '/api/v1/issues/assigners'
|
||||||
resources :issue_priorities, only: [:index]
|
resources :issue_priorities, only: [:index] do
|
||||||
|
collection do
|
||||||
|
get :mp_index
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# projects文件夹下的
|
# projects文件夹下的
|
||||||
|
|
Loading…
Reference in New Issue