Fix issue board related controllers to expose label priority per project

parent 3c2aaec1
...@@ -72,10 +72,10 @@ module Projects ...@@ -72,10 +72,10 @@ module Projects
def serialize_as_json(resource) def serialize_as_json(resource)
resource.as_json( resource.as_json(
labels: true,
only: [:iid, :title, :confidential], only: [:iid, :title, :confidential],
include: { include: {
assignee: { only: [:id, :name, :username], methods: [:avatar_url] }, assignee: { only: [:id, :name, :username], methods: [:avatar_url] }
labels: { only: [:id, :title, :description, :color, :priority], methods: [:text_color] }
}) })
end end
end end
......
...@@ -76,9 +76,8 @@ module Projects ...@@ -76,9 +76,8 @@ module Projects
resource.as_json( resource.as_json(
only: [:id, :list_type, :position], only: [:id, :list_type, :position],
methods: [:title], methods: [:title],
include: { label: true
label: { only: [:id, :title, :description, :color, :priority] } )
})
end end
end end
end end
......
...@@ -274,4 +274,16 @@ class Issue < ActiveRecord::Base ...@@ -274,4 +274,16 @@ class Issue < ActiveRecord::Base
def check_for_spam? def check_for_spam?
project.public? project.public?
end 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 end
...@@ -133,6 +133,12 @@ class Label < ActiveRecord::Base ...@@ -133,6 +133,12 @@ class Label < ActiveRecord::Base
end end
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 private
def cross_project_reference?(source_project, target_project) def cross_project_reference?(source_project, target_project)
......
...@@ -26,6 +26,17 @@ class List < ActiveRecord::Base ...@@ -26,6 +26,17 @@ class List < ActiveRecord::Base
label? ? label.name : list_type.humanize label? ? label.name : list_type.humanize
end 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 private
def can_be_destroyed def can_be_destroyed
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
"enum": ["backlog", "label", "done"] "enum": ["backlog", "label", "done"]
}, },
"label": { "label": {
"type": ["object"], "type": ["object", "null"],
"required": [ "required": [
"id", "id",
"color", "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