Add tab logic to tables
This commit is contained in:
parent
1b90ed389f
commit
c2c733fcec
|
@ -22,6 +22,11 @@ class CharactersController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
|
if params[:table_id].present?
|
||||||
|
@table = Current.user.tables.find(params[:table_id])
|
||||||
|
@characters = Current.user.characters.where(table: @table)
|
||||||
|
render layout: "table"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
class TablesController < ApplicationController
|
class TablesController < ApplicationController
|
||||||
before_action :set_table, only: [ :show, :edit, :update, :destroy ]
|
before_action :set_table, only: [ :show, :edit, :update, :destroy ]
|
||||||
|
before_action :set_characters, only: [ :show ]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@tables = Current.user.tables
|
@tables = Current.user.tables
|
||||||
|
@ -9,6 +10,7 @@ class TablesController < ApplicationController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@table_invites = @table.table_invites.not_responded
|
@table_invites = @table.table_invites.not_responded
|
||||||
|
render layout: "table"
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
|
@ -52,6 +54,10 @@ class TablesController < ApplicationController
|
||||||
@table = Current.user.tables.find(params[:id])
|
@table = Current.user.tables.find(params[:id])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_characters
|
||||||
|
@characters = Current.user.characters.where(table: @table)
|
||||||
|
end
|
||||||
|
|
||||||
def table_params
|
def table_params
|
||||||
params.require(:table).permit(
|
params.require(:table).permit(
|
||||||
:name,
|
:name,
|
||||||
|
|
|
@ -35,7 +35,8 @@
|
||||||
<main>
|
<main>
|
||||||
<%= render partial: "shared/flash_messages" %>
|
<%= render partial: "shared/flash_messages" %>
|
||||||
<%= yield(:submenu) if content_for?(:submenu) %>
|
<%= yield(:submenu) if content_for?(:submenu) %>
|
||||||
<%= yield %>
|
<%= yield(:main) if content_for?(:main) %>
|
||||||
|
<%= yield unless content_for?(:main) %>
|
||||||
</main>
|
</main>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
<% content_for :submenu do %>
|
||||||
|
<h2><%= @table.name %></h2>
|
||||||
|
<nav>
|
||||||
|
<ul>
|
||||||
|
<li><%= link_to t(".overview"), @table %></li>
|
||||||
|
<% @characters.each do |character| %>
|
||||||
|
<li><%= link_to character.name, table_character_path(@table, character) %></li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<% content_for :main do %>
|
||||||
|
<%= turbo_frame_tag("table-content") do %>
|
||||||
|
<%= yield %>
|
||||||
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
|
<%= render template: "layouts/application" %>
|
|
@ -1,7 +1,5 @@
|
||||||
<% content_for :title, @table.name %>
|
<% content_for :title, @table.name %>
|
||||||
|
|
||||||
<h2><%= @table.name %></h2>
|
|
||||||
|
|
||||||
<%= link_to t(".invite_user"), new_table_table_invite_path(@table) %>
|
<%= link_to t(".invite_user"), new_table_table_invite_path(@table) %>
|
||||||
<%= link_to t(".edit_table"), edit_table_path(@table) %>
|
<%= link_to t(".edit_table"), edit_table_path(@table) %>
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,8 @@ en:
|
||||||
See you soon,
|
See you soon,
|
||||||
The Tabletop Companion team
|
The Tabletop Companion team
|
||||||
sign_off_html: "<p>See you soon,<br>The Tabletop Companion team</p>"
|
sign_off_html: "<p>See you soon,<br>The Tabletop Companion team</p>"
|
||||||
|
table:
|
||||||
|
overview: Overview
|
||||||
account_verifications:
|
account_verifications:
|
||||||
show:
|
show:
|
||||||
success: "Thanks for verifying your email address! You can now log in."
|
success: "Thanks for verifying your email address! You can now log in."
|
||||||
|
|
|
@ -26,6 +26,7 @@ Rails.application.routes.draw do
|
||||||
resources :stats, only: [ :update, :destroy ]
|
resources :stats, only: [ :update, :destroy ]
|
||||||
resources :table_invites, only: [ :index, :edit, :update ]
|
resources :table_invites, only: [ :index, :edit, :update ]
|
||||||
resources :tables do
|
resources :tables do
|
||||||
|
resources :characters, only: [ :show ]
|
||||||
resources :table_invites, only: [ :new, :create ]
|
resources :table_invites, only: [ :new, :create ]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue