Show character sheet on table

This commit is contained in:
Trevor Vallender 2024-06-13 13:39:50 +01:00
parent 2aef1b532c
commit d8a27f8e41
5 changed files with 11 additions and 9 deletions

View File

@ -7,6 +7,11 @@ class CharacterSheetSectionsController < ApplicationController
def index
@sections = @character.character_sheet_sections.top_level
@editable = ActiveModel::Type::Boolean.new.cast(params[:editable])
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
def new

View File

@ -22,11 +22,6 @@ class CharactersController < ApplicationController
end
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
def edit

View File

@ -3,9 +3,9 @@
<h2><%= @character.name %></h2>
<% if @editable %>
<%= link_to t(".stop_editing"), character_character_sheet_sections_path(editable: false) %>
<%= link_to t(".stop_editing"), url_for(editable: false) %>
<% else %>
<%= link_to t(".edit"), character_character_sheet_sections_path(editable: true) %>
<%= link_to t(".edit"), url_for(editable: true) %>
<% end %>
<div id="character_sheet">

View File

@ -4,7 +4,7 @@
<ul>
<li><%= link_to t(".overview"), @table %></li>
<% @characters.each do |character| %>
<li><%= link_to character.name, table_character_path(@table, character) %></li>
<li><%= link_to character.name, table_character_character_sheet_sections_path(@table, character) %></li>
<% end %>
<li><%= link_to t(".events"), table_events_path(@table) %></li>
</ul>

View File

@ -26,7 +26,9 @@ Rails.application.routes.draw do
resources :stats, only: [ :update, :destroy ]
resources :table_invites, only: [ :index, :edit, :update ]
resources :tables do
resources :characters, only: [ :show ]
resources :characters, only: [] do
resources :character_sheet_sections, only: [ :index ]
end
resources :events, only: [ :index ]
resources :table_invites, only: [ :new, :create ]
end