Commit 265e25cb by Bui Minh Duc

fix pull comment

parent c461871c
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
// Place all the styles related to the review_comments controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
...@@ -16,14 +16,4 @@ class PullsController < ApplicationController ...@@ -16,14 +16,4 @@ class PullsController < ApplicationController
{id: 2, type: "Medium"}, {id: 2, type: "Medium"},
{id: 3, type: "Large"}] {id: 3, type: "Large"}]
end end
def update
if !params[:rv_comment].nil?
@rv_comment = ReviewComment.find_by(id: params[:rv_comment][:id])
@rv_comment.score = params[:rv_comment][:score]
@rv_comment.save
render json: {comment: @rv_comment.id, score: @rv_comment.score}
end
end
end end
class ReviewCommentsController < ApplicationController
def update
@rv_comment = ReviewComment.find_by(id: params[:rv_comment][:id])
@rv_comment.score = params[:rv_comment][:score]
@rv_comment.save
render json: {comment: @rv_comment.id, score: @rv_comment.score}
end
end
module ReviewCommentsHelper
end
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
</div> </div>
<div class="panel-body"> <div class="panel-body">
<% @rv_comments.each do |rv_comment| %> <% @rv_comments.each do |rv_comment| %>
<%= form_for :rv_comment, method: :patch, html: { class: "form-inline rate-form" } do |f| %> <%= form_for :rv_comment, url: pull_review_comment_path(pull_id: @pull.id, id: rv_comment.id), method: :patch, html: { class: "form-inline rate-form" } do |f| %>
<div class="panel panel-default"> <div class="panel panel-default">
<%= f.hidden_field "id", value: rv_comment.id %> <%= f.hidden_field "id", value: rv_comment.id %>
<div class="panel-heading"> <div class="panel-heading">
...@@ -108,6 +108,7 @@ ...@@ -108,6 +108,7 @@
<%= f.submit "Submit", class: "btn btn-default", style: "float: right;" %> <%= f.submit "Submit", class: "btn btn-default", style: "float: right;" %>
</div> </div>
<div class="col-md-3" style="float: right;"> <div class="col-md-3" style="float: right;">
<% @comment = OpenStruct.new({ score: 0 }) %>
<%= f.select(:score, @options.collect { |x| [ x[:type], x[:id] ] }, {}, { class: 'form-control', style: "float: right;" }) %> <%= f.select(:score, @options.collect { |x| [ x[:type], x[:id] ] }, {}, { class: 'form-control', style: "float: right;" }) %>
</div> </div>
</div> </div>
...@@ -185,7 +186,6 @@ ...@@ -185,7 +186,6 @@
}); });
}); });
$(".btn-save").click(function() {
$(".rate-form").submit(function(event) { $(".rate-form").submit(function(event) {
var submitVar = $(this).serialize(); var submitVar = $(this).serialize();
$.ajax({ $.ajax({
...@@ -206,7 +206,6 @@ ...@@ -206,7 +206,6 @@
}); });
return false; return false;
}); });
});
</script> </script>
</div> </div>
...@@ -9,6 +9,7 @@ Rails.application.routes.draw do ...@@ -9,6 +9,7 @@ Rails.application.routes.draw do
resources :issues resources :issues
resources :pulls do resources :pulls do
resources :comments resources :comments
resources :review_comments
end end
resources :repositories resources :repositories
resources :comments resources :comments
......
...@@ -523,3 +523,8 @@ I, [2017-01-12T14:01:51.798510 #24037] INFO -- : Insert review comments ...@@ -523,3 +523,8 @@ I, [2017-01-12T14:01:51.798510 #24037] INFO -- : Insert review comments
I, [2017-01-12T14:02:25.461132 #24037] INFO -- : Finished task update in 141.885639132s I, [2017-01-12T14:02:25.461132 #24037] INFO -- : Finished task update in 141.885639132s
I, [2017-01-12T15:00:04.918096 #28801] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2"] I, [2017-01-12T15:00:04.918096 #28801] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2"]
I, [2017-01-12T15:00:04.921609 #28801] INFO -- : Insert issues I, [2017-01-12T15:00:04.921609 #28801] INFO -- : Insert issues
I, [2017-01-12T16:00:04.085646 #428] INFO -- : Begin task update ["socialtools", "arubaito-ex", "kuruma-ex", "arubaito_v2"]
I, [2017-01-12T16:00:04.088863 #428] INFO -- : Insert issues
I, [2017-01-12T16:01:26.415292 #428] INFO -- : Insert comments
I, [2017-01-12T16:01:52.210615 #428] INFO -- : Insert review comments
I, [2017-01-12T16:02:37.067253 #428] INFO -- : Finished task update in 153.136871445s
require 'test_helper'
class ReviewCommentsControllerTest < ActionDispatch::IntegrationTest
# test "the truth" do
# assert true
# end
end
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