diff --git a/app/controllers/wow_characters_controller.rb b/app/controllers/wow_characters_controller.rb index ecc6616..3ab0c7e 100644 --- a/app/controllers/wow_characters_controller.rb +++ b/app/controllers/wow_characters_controller.rb @@ -7,5 +7,7 @@ class WowCharactersController < ProtectedController def show @wow_character = current_user.wow_characters.includes(wow_standings: { wow_reputation: { wow_reputation_tier: :wow_reputation_tier_levels }}).find(params[:id]) + meta_reputation_ids = @wow_character.wow_standings.map { |standing| standing.wow_reputation.meta_wow_reputation_id }.uniq + @meta_wow_reputations = WowReputation.find(meta_reputation_ids) end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0e0edb4..c2564db 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2,4 +2,19 @@ module ApplicationHelper include Pagy::Frontend + + def bootstrap_class_for_flash(flash_type) + case flash_type + when 'success' + 'alert-success' + when 'error' + 'alert-danger' + when 'alert' + 'alert-warning' + when 'notice' + 'alert-primary' + else + 'alert-secondary' + end + end end diff --git a/app/views/layouts/_flash.html.erb b/app/views/layouts/_flash.html.erb new file mode 100644 index 0000000..5f39ada --- /dev/null +++ b/app/views/layouts/_flash.html.erb @@ -0,0 +1,8 @@ +
+ <% flash.each do |type, msg| %> + + <% end %> +
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 7385d45..72582a8 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -13,8 +13,7 @@ <%= render 'layouts/navbar' %> -

<%= notice %>

-

<%= alert %>

+ <%= render partial: 'layouts/flash', flash: flash %>
<%= yield %>
diff --git a/app/views/wow_characters/_reputations.html.erb b/app/views/wow_characters/_reputations.html.erb index ff3fdb8..93c67c8 100644 --- a/app/views/wow_characters/_reputations.html.erb +++ b/app/views/wow_characters/_reputations.html.erb @@ -1,8 +1,25 @@ -

Reputation

+

Reputations

-<% standings.each do |standing| %> -
-
<%= standing.wow_reputation.name %>
- <%= render partial: 'wow_characters/standing', locals: { standing: standing, tier: standing.wow_reputation.wow_reputation_tier.wow_reputation_tier_levels[standing.tier] } %> +
+ <% standings.each do |reputation_group| %> +
+

+ +

+ +
+ <% end %>
-<% end %> diff --git a/app/views/wow_characters/show.html.erb b/app/views/wow_characters/show.html.erb index 4a70eb4..630246c 100644 --- a/app/views/wow_characters/show.html.erb +++ b/app/views/wow_characters/show.html.erb @@ -18,7 +18,7 @@
- <%= render partial: 'wow_characters/reputations', locals: { standings: @wow_character.wow_standings } %> + <%= render partial: 'wow_characters/reputations', locals: { standings: @wow_character.wow_standings.group_by { |standing| standing.wow_reputation.meta_wow_reputation_id }, meta_wow_reputations: @meta_wow_reputations } %>