-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy path_flash.html.erb
More file actions
40 lines (39 loc) · 1.46 KB
/
_flash.html.erb
File metadata and controls
40 lines (39 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<% # https://api.rubyonrails.org/classes/ActionDispatch/Flash.html %>
<% if flash[:notice] || flash[:errors] || alert || notice %>
<div class="grid-row margin-bottom-3">
<div class="grid-col-12">
<% if flash[:notice] || notice %>
<%= render AlertComponent.new(type: "success", message: flash[:notice] || notice) %>
<% end %>
<% if flash[:errors] || alert %>
<%= render AlertComponent.new(type: "error") do |c| %>
<% c.with_body do %>
<% if flash[:errors] %>
<h3 class="usa-alert__heading">
<%= t "flash.error_heading", count: flash[:errors].count %>
</h3>
<% end %>
<div class="usa-alert__text">
<% if alert %>
<%= alert %>
<% elsif flash[:errors].count == 0 %>
<p><%= t('flash.error_fallback') %></p>
<button class="usa-button usa-button--outline" onclick="location.reload();">
<%= t('flash.reload_page') %>
</button>
<% elsif flash[:errors].count == 1 %>
<%= flash[:errors].first %>
<% else %>
<ul class="usa-list">
<% flash[:errors].each do |error| %>
<li><%= error %></li>
<% end %>
</ul>
<% end %>
</div>
<% end %>
<% end %>
<% end %>
</div>
</div>
<% end %>