diff --git a/app/assets/javascripts/legislation.js.coffee b/app/assets/javascripts/legislation.js.coffee index cd4e90bc3..3eb53e6d2 100644 --- a/app/assets/javascripts/legislation.js.coffee +++ b/app/assets/javascripts/legislation.js.coffee @@ -4,7 +4,7 @@ App.Legislation = $('#js-toggle-debate').on click: -> $('#debate-show').toggle() - + $('#js-toggle-small-debate').on click: -> $('#debate-show').toggle() diff --git a/app/controllers/legislation/annotations_controller.rb b/app/controllers/legislation/annotations_controller.rb index 6f5069763..c97165e2a 100644 --- a/app/controllers/legislation/annotations_controller.rb +++ b/app/controllers/legislation/annotations_controller.rb @@ -1,7 +1,7 @@ class Legislation::AnnotationsController < ApplicationController skip_before_action :verify_authenticity_token - before_action :authenticate_user!, only: [:create] + before_action :authenticate_user!, only: [:create, :new_comment] before_action :convert_ranges_parameters, only: [:create] load_and_authorize_resource :process @@ -43,6 +43,7 @@ class Legislation::AnnotationsController < ApplicationController def comments @annotation = Legislation::Annotation.find(params[:annotation_id]) + @comment = @annotation.comments.new end def new @@ -51,6 +52,19 @@ class Legislation::AnnotationsController < ApplicationController end end + def new_comment + @draft_version = Legislation::DraftVersion.find(params[:draft_version_id]) + @annotation = @draft_version.annotations.find(params[:annotation_id]) + @comment = @annotation.comments.new(body: params[:comment][:body], user: current_user) + if @comment.save + @comment = @annotation.comments.new + end + + respond_to do |format| + format.js { render :comments } + end + end + private def annotation_params diff --git a/app/models/abilities/everyone.rb b/app/models/abilities/everyone.rb index ae3dc432d..4d44f14eb 100644 --- a/app/models/abilities/everyone.rb +++ b/app/models/abilities/everyone.rb @@ -20,7 +20,7 @@ module Abilities can [:read, :changes, :go_to_version], Legislation::DraftVersion can [:read], Legislation::Question can [:create], Legislation::Answer - can [:search, :comments, :read, :create], Legislation::Annotation + can [:search, :comments, :read, :create, :new_comment], Legislation::Annotation end end end diff --git a/app/views/legislation/annotations/_comments_box.html.erb b/app/views/legislation/annotations/_comments_box.html.erb index 4f33d45ef..2a543566c 100644 --- a/app/views/legislation/annotations/_comments_box.html.erb +++ b/app/views/legislation/annotations/_comments_box.html.erb @@ -1,12 +1,12 @@
<%= truncate comment.body, length: 250 %>
@@ -36,11 +36,39 @@ <% end %>