diff --git a/app/views/hooks/redmine_hearts/_view_journals_update_js_bottom.js.erb b/app/views/hooks/redmine_hearts/_view_journals_update_js_bottom.js.erb new file mode 100644 index 0000000..b34e642 --- /dev/null +++ b/app/views/hooks/redmine_hearts/_view_journals_update_js_bottom.js.erb @@ -0,0 +1,6 @@ +<%# frozen_string_literal: true %> +<% self.class.send :include, HeartsHelper %> +(function() { + const link = "<%= escape_javascript(heart_link_with_counter(@journal, User.current)) %>"; + $(link).prependTo($("#change-<%= @journal.id %> .journal-actions")); +})(); diff --git a/lib/redmine_hearts/view_hook.rb b/lib/redmine_hearts/view_hook.rb index e8128bd..23f204a 100644 --- a/lib/redmine_hearts/view_hook.rb +++ b/lib/redmine_hearts/view_hook.rb @@ -52,6 +52,12 @@ def view_account_left_bottom(context={}) end end + def view_journals_update_js_bottom(context={}) + context[:controller].send(:render_to_string, { + :partial => "hooks/redmine_hearts/view_journals_update_js_bottom" + }) + end + private def heartable_subject(controller) subject = nil