Add issue sidebar and toggle_subscription endpoint in board issues data
This commit is contained in:
parent
bd026b6a28
commit
d2699aea57
|
@ -84,6 +84,7 @@ module Boards
|
||||||
resource.as_json(
|
resource.as_json(
|
||||||
only: [:id, :iid, :project_id, :title, :confidential, :due_date, :relative_position],
|
only: [:id, :iid, :project_id, :title, :confidential, :due_date, :relative_position],
|
||||||
labels: true,
|
labels: true,
|
||||||
|
sidebar_endpoints: true,
|
||||||
include: {
|
include: {
|
||||||
project: { only: [:id, :path] },
|
project: { only: [:id, :path] },
|
||||||
assignees: { only: [:id, :name, :username], methods: [:avatar_url] },
|
assignees: { only: [:id, :name, :username], methods: [:avatar_url] },
|
||||||
|
|
|
@ -246,7 +246,12 @@ class Issue < ActiveRecord::Base
|
||||||
|
|
||||||
def as_json(options = {})
|
def as_json(options = {})
|
||||||
super(options).tap do |json|
|
super(options).tap do |json|
|
||||||
json[:subscribed] = subscribed?(options[:user], project) if options.key?(:user) && options[:user]
|
if options.key?(:sidebar_endpoints) && project
|
||||||
|
url_helper = Gitlab::Routing.url_helpers
|
||||||
|
|
||||||
|
json.merge!(issue_sidebar_endpoint: url_helper.project_issue_path(project, self, format: :json, serializer: 'sidebar'),
|
||||||
|
toggle_subscription_endpoint: url_helper.toggle_subscription_project_issue_path(project, self))
|
||||||
|
end
|
||||||
|
|
||||||
if options.key?(:labels)
|
if options.key?(:labels)
|
||||||
json[:labels] = labels.as_json(
|
json[:labels] = labels.as_json(
|
||||||
|
|
|
@ -13,6 +13,8 @@
|
||||||
"confidential": { "type": "boolean" },
|
"confidential": { "type": "boolean" },
|
||||||
"due_date": { "type": ["date", "null"] },
|
"due_date": { "type": ["date", "null"] },
|
||||||
"relative_position": { "type": "integer" },
|
"relative_position": { "type": "integer" },
|
||||||
|
"issue_sidebar_endpoint": { "type": "string" },
|
||||||
|
"toggle_subscription_endpoint": { "type": "string" },
|
||||||
"project": {
|
"project": {
|
||||||
"id": { "type": "integer" },
|
"id": { "type": "integer" },
|
||||||
"path": { "type": "string" }
|
"path": { "type": "string" }
|
||||||
|
|
Loading…
Reference in New Issue