diff --git a/app/assets/stylesheets/layout.css b/app/assets/stylesheets/layout.css index a53dbc0..b4a1fa5 100644 --- a/app/assets/stylesheets/layout.css +++ b/app/assets/stylesheets/layout.css @@ -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; } diff --git a/app/controllers/stats_controller.rb b/app/controllers/stats_controller.rb index 8bb6f78..c0ee6be 100644 --- a/app/controllers/stats_controller.rb +++ b/app/controllers/stats_controller.rb @@ -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) diff --git a/app/views/stats/edit.html.erb b/app/views/stats/edit.html.erb new file mode 100644 index 0000000..298d03a --- /dev/null +++ b/app/views/stats/edit.html.erb @@ -0,0 +1,19 @@ +<%= turbo_frame_tag :modal do %> +
+ <%= icon_link_to "fa-close", table_character_character_sheet_sections_path(@stat.character.table, @stat.character), + class: "icon-link" %> +

<%= @stat.name %>

+ <%= 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 %> +

<%= t(".dice_roll_types") %>

+

TODO: Add additional roll types here

+
+<% end %> diff --git a/app/views/stats/show.html.erb b/app/views/stats/show.html.erb index 7fd3db4..c6f94aa 100644 --- a/app/views/stats/show.html.erb +++ b/app/views/stats/show.html.erb @@ -1,7 +1,10 @@ <%= turbo_frame_tag :modal do %>
- <%= icon_link_to "fa-close", table_character_character_sheet_sections_path(@stat.character.table, @stat.character), - class: "icon-link" %> +
+ <%= 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" %> +

<%= @stat.name %>

<%= 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 %> diff --git a/config/locales/en.yml b/config/locales/en.yml index e7cb888..f082184 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -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! diff --git a/config/routes.rb b/config/routes.rb index d1a2546..2912b05 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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