Render flash messages for html and turbo_stream

This commit is contained in:
2024-01-14 03:19:20 +01:00
parent a4f113ad48
commit 8d63ed62ea
4 changed files with 17 additions and 13 deletions

View File

@@ -1,4 +1,5 @@
module ApplicationHelper
# TODO: replace legacy content_tag with tag.tagname
class TabularFormBuilder < ActionView::Helpers::FormBuilder
(field_helpers - [:label]).each do |selector|
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
@@ -88,6 +89,15 @@ module ApplicationHelper
image_element_to(:link, name, image, options, html_options)
end
def render_flash_messages
flash.map do |entry, message|
tag.div class: "flash #{entry}" do
tag.div(sanitize(message)) + tag.button(sanitize("&times;"), tabindex: -1,
onclick: "this.parentElement.style.display='none';")
end
end.join.html_safe
end
private
def image_element_to(type, name, image = nil, options = nil, html_options = {})