Fix issue board related controllers to expose label priority per project

parent 3c2aaec1
......@@ -72,10 +72,10 @@ module Projects
def serialize_as_json(resource)
resource.as_json(
labels: true,
only: [:iid, :title, :confidential],
include: {
assignee: { only: [:id, :name, :username], methods: [:avatar_url] },
labels: { only: [:id, :title, :description, :color, :priority], methods: [:text_color] }
assignee: { only: [:id, :name, :username], methods: [:avatar_url] }
})
end
end
......
......@@ -76,9 +76,8 @@ module Projects
resource.as_json(
only: [:id, :list_type, :position],
methods: [:title],
include: {
label: { only: [:id, :title, :description, :color, :priority] }
})
label: true
)
end
end
end
......
......@@ -274,4 +274,16 @@ class Issue < ActiveRecord::Base
def check_for_spam?
project.public?
end
def as_json(options = {})
super(options).tap do |json|
if options.has_key?(:labels)
json[:labels] = labels.as_json(
project: project,
only: [:id, :title, :description, :color],
methods: [:text_color]
)
end
end
end
end
......@@ -133,6 +133,12 @@ class Label < ActiveRecord::Base
end
end
def as_json(options = {})
super(options).tap do |json|
json[:priority] = priorities.find_by(project: options[:project]).try(:priority) if options.has_key?(:project)
end
end
private
def cross_project_reference?(source_project, target_project)
......
......@@ -26,6 +26,17 @@ class List < ActiveRecord::Base
label? ? label.name : list_type.humanize
end
def as_json(options = {})
super(options).tap do |json|
if options.has_key?(:label)
json[:label] = label.as_json(
project: board.project,
only: [:id, :title, :description, :color]
)
end
end
end
private
def can_be_destroyed
......
......@@ -13,7 +13,7 @@
"enum": ["backlog", "label", "done"]
},
"label": {
"type": ["object"],
"type": ["object", "null"],
"required": [
"id",
"color",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment