Allow editing of stats
This commit is contained in:
parent
1834854dc0
commit
2170122805
|
@ -129,6 +129,12 @@ hr {
|
|||
background-color: var(--inset-bg-color);
|
||||
}
|
||||
|
||||
.feature-box-icons {
|
||||
display: flex;
|
||||
gap: 1em;
|
||||
flex-direction: row-reverse;
|
||||
}
|
||||
|
||||
.feature-box h2 {
|
||||
text-align: center;
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
class StatsController < ApplicationController
|
||||
before_action :set_section, only: [ :new, :create ]
|
||||
before_action :set_character, only: [ :new, :create ]
|
||||
before_action :set_stat, only: [ :show, :update, :destroy ]
|
||||
before_action :set_stat, only: [ :show, :edit, :update, :destroy ]
|
||||
|
||||
def new
|
||||
@stat = @section.stats.new
|
||||
|
@ -21,6 +21,9 @@ class StatsController < ApplicationController
|
|||
def show
|
||||
end
|
||||
|
||||
def edit
|
||||
end
|
||||
|
||||
def update
|
||||
@editable = ActiveModel::Type::Boolean.new.cast(params[:editable])
|
||||
@stat.update!(stat_params)
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<%= turbo_frame_tag :modal do %>
|
||||
<div class="feature-box ">
|
||||
<%= icon_link_to "fa-close", table_character_character_sheet_sections_path(@stat.character.table, @stat.character),
|
||||
class: "icon-link" %>
|
||||
<h2><%= @stat.name %></h2>
|
||||
<%= form_with model: @stat, data: { controller: "auto-update" } do |f| %>
|
||||
<%= f.label :name %>
|
||||
<%= f.text_field :name %>
|
||||
<%= f.label :min_allowed, t(".min_allowed") %>
|
||||
<%= f.number_field :min_allowed %>
|
||||
<%= f.label :max_allowed, t(".max_allowed") %>
|
||||
<%= f.number_field :max_allowed %>
|
||||
<%= f.label :roll_command %>
|
||||
<%= f.text_field :roll_command %>
|
||||
<% end %>
|
||||
<h4><%= t(".dice_roll_types") %></h4>
|
||||
<p>TODO: Add additional roll types here</p>
|
||||
</div>
|
||||
<% end %>
|
|
@ -1,7 +1,10 @@
|
|||
<%= turbo_frame_tag :modal do %>
|
||||
<div class="feature-box stat">
|
||||
<%= icon_link_to "fa-close", table_character_character_sheet_sections_path(@stat.character.table, @stat.character),
|
||||
class: "icon-link" %>
|
||||
<div class="feature-box-icons">
|
||||
<%= icon_link_to "fa-close", table_character_character_sheet_sections_path(@stat.character.table, @stat.character),
|
||||
class: "icon-link" %>
|
||||
<%= icon_link_to "fa-edit", edit_stat_path(@stat), class: "icon-link" %>
|
||||
</div>
|
||||
<h2><%= @stat.name %></h2>
|
||||
<%= form_with model: @stat, class: "stat-form", data: { controller: "auto-update" } do |f| %>
|
||||
<%= f.number_field :value, min: @stat.min_allowed, max: @stat.max_allowed %>
|
||||
|
|
|
@ -151,6 +151,10 @@ en:
|
|||
confirm_delete: Are you sure you want to delete %{name}?
|
||||
new:
|
||||
create_stat: Create stat
|
||||
edit:
|
||||
dice_roll_types: Other rolls
|
||||
min_allowed: Minimum
|
||||
max_allowed: Maximum
|
||||
table_invite_mailer:
|
||||
invite_new_user:
|
||||
subject: You’ve been invited to join a game on Tabletop Companion!
|
||||
|
|
|
@ -28,7 +28,7 @@ Rails.application.routes.draw do
|
|||
resources :characters do
|
||||
resources :character_sheet_sections, only: [ :index, :new, :create ]
|
||||
end
|
||||
resources :stats, only: [ :show, :update, :destroy ]
|
||||
resources :stats, only: [ :show, :edit, :update, :destroy ]
|
||||
resources :table_invites, only: [ :index, :edit, :update ]
|
||||
resources :tables do
|
||||
resources :characters, only: [] do
|
||||
|
|
Loading…
Reference in New Issue