Browse Source

links for multiple

main
pvincent 5 days ago
parent
commit
84ee10a8d3
  1. 4
      app/controllers/notification_controller.rb
  2. 8
      app/views/notification/index.html.erb

4
app/controllers/notification_controller.rb

@ -5,12 +5,12 @@ class NotificationController < ApplicationController
def show_notice
# flash.alert = 'toto'
flash.alert = %w[titi toto]
flash.alert = %w[titi toto] if params[:multiple] == 'true'
redirect_to notification_index_path, notice: 'this is a notice'
end
def show_alert
flash.notice = ['<i>italic</i> <b>message</b>', 'normal <b>message</b>']
flash.notice = ['<i>italic</i> <b>message</b>', 'normal <b>message</b>'] if params[:multiple] == 'true'
redirect_to notification_index_path, alert: 'this is an alert'
end
end

8
app/views/notification/index.html.erb

@ -8,9 +8,15 @@
<li class="p-4 pb-2 text-xs opacity-60 tracking-wide">
<%= link_to 'Notice', notification_show_notice_path, class: 'btn btn-primary'%>
</li>
<li class="p-4 pb-2 text-xs opacity-60 tracking-wide">
<%= link_to 'Notice ++', notification_show_notice_path({multiple: true}), class: 'btn btn-primary'%>
</li>
<li class="p-4 pb-2 text-xs opacity-60 tracking-wide">
<%= link_to 'Alert', notification_show_alert_path, class: 'btn btn-secondary'%>
</li>
<li class="p-4 pb-2 text-xs opacity-60 tracking-wide">
<%= link_to 'Alert ++', notification_show_alert_path({multiple: true}), class: 'btn btn-secondary'%>
</li>
<li class="p-4 pb-2 text-xs opacity-60 tracking-wide">
<%= link_to 'Nothing', notification_index_path, class: 'btn btn-accent btn-outline'%>
</li>
@ -44,7 +50,7 @@
<li class="p-4 pb-2 text-xs opacity-60 tracking-wide">
<%= link_to 'Alert', "javascript: window.dispatchEvent(new CustomEvent('popup-toast', {detail: {
type: 'alert',
message: 'this is an alert'
message: 'this is an alert from Stimulus'
}}))", class: 'btn btn-secondary'%>
</li>
</ul>
Loading…
Cancel
Save