Commit ebf91551 authored by Douwe Maan's avatar Douwe Maan Committed by Fatih Acet

Add data required for note form

parent e57093ff
...@@ -92,7 +92,7 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -92,7 +92,7 @@ class Projects::IssuesController < Projects::ApplicationController
respond_to do |format| respond_to do |format|
format.html format.html
format.json do format.json do
render json: IssueSerializer.new.represent(@issue) render json: serializer.represent(@issue)
end end
end end
end end
...@@ -152,7 +152,7 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -152,7 +152,7 @@ class Projects::IssuesController < Projects::ApplicationController
format.json do format.json do
if @issue.valid? if @issue.valid?
render json: IssueSerializer.new.represent(@issue) render json: serializer.represent(@issue)
else else
render json: { errors: @issue.errors.full_messages }, status: :unprocessable_entity render json: { errors: @issue.errors.full_messages }, status: :unprocessable_entity
end end
...@@ -308,4 +308,8 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -308,4 +308,8 @@ class Projects::IssuesController < Projects::ApplicationController
redirect_to new_user_session_path, notice: notice redirect_to new_user_session_path, notice: notice
end end
def serializer
IssueSerializer.new(current_user: current_user, project: issue.project)
end
end end
...@@ -35,7 +35,7 @@ module IssuablesHelper ...@@ -35,7 +35,7 @@ module IssuablesHelper
def serialize_issuable(issuable) def serialize_issuable(issuable)
case issuable case issuable
when Issue when Issue
IssueSerializer.new.represent(issuable).to_json IssueSerializer.new(current_user: current_user, project: issuable.project).represent(issuable).to_json
when MergeRequest when MergeRequest
MergeRequestSerializer MergeRequestSerializer
.new(current_user: current_user, project: issuable.project) .new(current_user: current_user, project: issuable.project)
......
...@@ -15,4 +15,6 @@ class IssuableEntity < Grape::Entity ...@@ -15,4 +15,6 @@ class IssuableEntity < Grape::Entity
expose :total_time_spent expose :total_time_spent
expose :human_time_estimate expose :human_time_estimate
expose :human_total_time_spent expose :human_total_time_spent
expose :milestone, using: API::Entities::Milestone
expose :labels, using: LabelEntity
end end
...@@ -7,10 +7,26 @@ class IssueEntity < IssuableEntity ...@@ -7,10 +7,26 @@ class IssueEntity < IssuableEntity
expose :due_date expose :due_date
expose :moved_to_id expose :moved_to_id
expose :project_id expose :project_id
expose :milestone, using: API::Entities::Milestone
expose :labels, using: LabelEntity
expose :web_url do |issue| expose :web_url do |issue|
project_issue_path(issue.project, issue) project_issue_path(issue.project, issue)
end end
expose :current_user do
expose :can_create_note do |issue|
can?(request.current_user, :create_note, issue.project)
end
expose :can_update do |issue|
can?(request.current_user, :update_issue, issue)
end
end
expose :create_note_path do |issue|
namespace_project_notes_path(issue.project.namespace, issue.project, noteable_type: 'Issue', noteable_id: issue.id, target_type: 'issue', target_id: issue.id)
end
expose :preview_note_path do |issue|
preview_markdown_path(issue.project, quick_actions_target_type: 'Issue', quick_actions_target_id: issue.id)
end
end end
class UserSerializer < BaseSerializer
entity UserEntity
end
...@@ -12,3 +12,9 @@ ...@@ -12,3 +12,9 @@
/ #notes{style: "margin-top: 150px"} / #notes{style: "margin-top: 150px"}
/ = render 'shared/notes/notes_with_form', :autocomplete => true / = render 'shared/notes/notes_with_form', :autocomplete => true
:javascript
window.gl.issueData = #{serialize_issuable(@issue)};
window.gl.currentUserData = #{UserSerializer.new.represent(current_user).to_json};
%section#note-form{ data: { new_session_path: new_session_path(:user, redirect_to_referer: 'yes') } }
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