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:
Javi Martín
2020-07-07 22:22:22 +02:00
parent 4f30720593
commit a5f1245b7e
8 changed files with 7 additions and 9 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -1 +0,0 @@
App.Flaggable.update("<%= dom_id(@investment) %>", "<%= j render("shared/flag_actions", flaggable: @investment) %>")

View File

@@ -1 +0,0 @@
App.Flaggable.update("<%= dom_id(@comment) %>", "<%= j render("shared/flag_actions", flaggable: @comment, divider: true) %>");

View File

@@ -1 +0,0 @@
App.Flaggable.update("<%= dom_id(@debate) %>", "<%= j render("shared/flag_actions", flaggable: @debate) %>");

View File

@@ -1 +0,0 @@
App.Flaggable.update("<%= dom_id(@proposal) %>", "<%= j render("shared/flag_actions", flaggable: @proposal) %>");

View File

@@ -1 +0,0 @@
App.Flaggable.update("<%= dom_id(@proposal) %>", "<%= j render("shared/flag_actions", flaggable: @proposal) %>")

View File

@@ -0,0 +1,3 @@
App.Flaggable.update("<%= dom_id(flaggable) %>",
"<%= j render("shared/flag_actions", flaggable: flaggable, divider: local_assigns[:divider]) %>"
);