Extract partial to refresh flag actions
Now that we're rendering `shared/flag_actions` everywhere, we can use the same code in all cases.
This commit is contained in:
@@ -36,14 +36,14 @@ class CommentsController < ApplicationController
|
|||||||
Flag.flag(current_user, @comment)
|
Flag.flag(current_user, @comment)
|
||||||
set_comment_flags(@comment)
|
set_comment_flags(@comment)
|
||||||
|
|
||||||
render "comments/_refresh_flag_actions"
|
render "shared/_refresh_flag_actions", locals: { flaggable: @comment, divider: true }
|
||||||
end
|
end
|
||||||
|
|
||||||
def unflag
|
def unflag
|
||||||
Flag.unflag(current_user, @comment)
|
Flag.unflag(current_user, @comment)
|
||||||
set_comment_flags(@comment)
|
set_comment_flags(@comment)
|
||||||
|
|
||||||
render "comments/_refresh_flag_actions"
|
render "shared/_refresh_flag_actions", locals: { flaggable: @comment, divider: true }
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -4,13 +4,13 @@ module FlagActions
|
|||||||
def flag
|
def flag
|
||||||
Flag.flag(current_user, flaggable)
|
Flag.flag(current_user, flaggable)
|
||||||
|
|
||||||
render "_refresh_flag_actions"
|
render "shared/_refresh_flag_actions", locals: { flaggable: flaggable }
|
||||||
end
|
end
|
||||||
|
|
||||||
def unflag
|
def unflag
|
||||||
Flag.unflag(current_user, flaggable)
|
Flag.unflag(current_user, flaggable)
|
||||||
|
|
||||||
render "_refresh_flag_actions"
|
render "shared/_refresh_flag_actions", locals: { flaggable: flaggable }
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
App.Flaggable.update("<%= dom_id(@investment) %>", "<%= j render("shared/flag_actions", flaggable: @investment) %>")
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
App.Flaggable.update("<%= dom_id(@comment) %>", "<%= j render("shared/flag_actions", flaggable: @comment, divider: true) %>");
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
App.Flaggable.update("<%= dom_id(@debate) %>", "<%= j render("shared/flag_actions", flaggable: @debate) %>");
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
App.Flaggable.update("<%= dom_id(@proposal) %>", "<%= j render("shared/flag_actions", flaggable: @proposal) %>");
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
App.Flaggable.update("<%= dom_id(@proposal) %>", "<%= j render("shared/flag_actions", flaggable: @proposal) %>")
|
|
||||||
3
app/views/shared/_refresh_flag_actions.js.erb
Normal file
3
app/views/shared/_refresh_flag_actions.js.erb
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
App.Flaggable.update("<%= dom_id(flaggable) %>",
|
||||||
|
"<%= j render("shared/flag_actions", flaggable: flaggable, divider: local_assigns[:divider]) %>"
|
||||||
|
);
|
||||||
Reference in New Issue
Block a user