add global reputations page
This commit is contained in:
3
app/assets/stylesheets/wow_reputations.scss
Normal file
3
app/assets/stylesheets/wow_reputations.scss
Normal file
@@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the WowReputation controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: https://sass-lang.com/
|
||||
9
app/controllers/wow_reputations_controller.rb
Normal file
9
app/controllers/wow_reputations_controller.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
class WowReputationsController < ProtectedController
|
||||
def index
|
||||
@pagy, @wow_reputations = pagy(WowReputation.non_meta_reputations, items: 20)
|
||||
end
|
||||
|
||||
def show
|
||||
@wow_reputation = WowReputation.find(params[:id])
|
||||
end
|
||||
end
|
||||
2
app/helpers/wow_reputations_helper.rb
Normal file
2
app/helpers/wow_reputations_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module WowReputationsHelper
|
||||
end
|
||||
@@ -11,5 +11,6 @@ class WowReputation < ApplicationRecord
|
||||
validates :name, presence: true
|
||||
validates :reputation_id, presence: true, uniqueness: true
|
||||
|
||||
scope :meta_reputations, -> { where(meta_wow_reputation: nil) }
|
||||
scope :meta_reputations, -> { where(description: nil) }
|
||||
scope :non_meta_reputations, -> { where.not(description: nil) }
|
||||
end
|
||||
|
||||
@@ -5,13 +5,16 @@
|
||||
<% if user_signed_in? %>
|
||||
<ul class="navbar-nav mb-2 mb-lg-0">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="<%= wow_characters_path %>"><%= t('layouts.navbar.characters') %></a>
|
||||
<a class="nav-link <%= 'active' if current_page?(wow_characters_path) %>" aria-current="page" href="<%= wow_characters_path %>"><%= t('layouts.navbar.characters') %></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="<%= wow_mounts_path %>"><%= t('layouts.navbar.mounts') %></a>
|
||||
<a class="nav-link <%= 'active' if current_page?(wow_mounts_path) %>" aria-current="page" href="<%= wow_mounts_path %>"><%= t('layouts.navbar.mounts') %></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" aria-current="page" href="<%= wow_pets_path %>"><%= t('layouts.navbar.pets') %></a>
|
||||
<a class="nav-link <%= 'active' if current_page?(wow_pets_path) %>" aria-current="page" href="<%= wow_pets_path %>"><%= t('layouts.navbar.pets') %></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <%= 'active' if current_page?(wow_reputations_path) %>" aria-current="page" href="<%= wow_reputations_path %>"><%= t('layouts.navbar.reputations') %></a>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
|
||||
|
||||
5
app/views/wow_reputations/_standing.html.erb
Normal file
5
app/views/wow_reputations/_standing.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<% if standing %>
|
||||
<%= link_to standing.wow_character.name, standing.wow_character %> - <%= standing.wow_reputation.wow_reputation_tier.wow_reputation_tier_levels.find_by(order: standing.tier)&.name %>
|
||||
<% else %>
|
||||
<%= t('wow_reputations.reputation_list.not_discovered') %>
|
||||
<% end %>
|
||||
22
app/views/wow_reputations/index.html.erb
Normal file
22
app/views/wow_reputations/index.html.erb
Normal file
@@ -0,0 +1,22 @@
|
||||
<h2>Reputations list</h2>
|
||||
|
||||
<table class="table table-hover table-dark table-image">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col"><%= t('wow_reputations.reputation_list.name') %></th>
|
||||
<th scope="col"><%= t('wow_reputations.reputation_list.description') %></th>
|
||||
<th scope="col"><%= t('wow_reputations.reputation_list.highest_reputation_character') %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @wow_reputations.each do |reputation| %>
|
||||
<tr>
|
||||
<td><%= reputation.name %></td>
|
||||
<td><%= reputation.description %></td>
|
||||
<td><%= render partial: 'wow_reputations/standing', locals: { standing: reputation.wow_standings.joins(:wow_character).where(wow_character: { user: current_user }).order(raw: :desc).first } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%== pagy_bootstrap_nav(@pagy) %>
|
||||
Reference in New Issue
Block a user