Compare commits
No commits in common. "985e3584aa896bc5a0df9adb58f54b75224b50c4" and "c5435ac41273e5e8438d0b57ebb8477461f79811" have entirely different histories.
985e3584aa
...
c5435ac412
|
@ -1 +1 @@
|
|||
ruby-3.3.3
|
||||
ruby-3.3.1
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# syntax = docker/dockerfile:1
|
||||
|
||||
# Make sure RUBY_VERSION matches the Ruby version in .ruby-version and Gemfile
|
||||
ARG RUBY_VERSION=3.3.3
|
||||
ARG RUBY_VERSION=3.3.1
|
||||
FROM registry.docker.com/library/ruby:$RUBY_VERSION-slim as base
|
||||
|
||||
# Rails app lives here
|
||||
|
|
|
@ -348,7 +348,7 @@ DEPENDENCIES
|
|||
web-console
|
||||
|
||||
RUBY VERSION
|
||||
ruby 3.3.3p89
|
||||
ruby 3.3.1p55
|
||||
|
||||
BUNDLED WITH
|
||||
2.5.3
|
||||
|
|
|
@ -70,9 +70,6 @@
|
|||
padding: .5em;
|
||||
}
|
||||
input, .stat-value {
|
||||
padding: .5em;
|
||||
color: var(--text-color);
|
||||
background-color: var(--input-background);
|
||||
text-align: center;
|
||||
font-size: 3em;
|
||||
width: 2.5em;
|
||||
|
|
|
@ -3,7 +3,7 @@ form, fieldset {
|
|||
gap: 1rem;
|
||||
grid-template-columns: 1fr 2fr;
|
||||
|
||||
input, label {
|
||||
input, label, .stat-value {
|
||||
padding: .5em;
|
||||
}
|
||||
|
||||
|
@ -44,4 +44,9 @@ form, fieldset {
|
|||
form.stat-form, form.counter-form {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.stat-value {
|
||||
color: var(--text-color);
|
||||
background-color: var(--input-background);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,12 +7,10 @@ class CountersController < ApplicationController
|
|||
|
||||
def new
|
||||
@counter = @section.counters.new
|
||||
@counter.build_character_sheet_feature
|
||||
end
|
||||
|
||||
def create
|
||||
@counter = @section.counters.new(counter_params)
|
||||
@editable = true
|
||||
unless @counter.save
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
|
@ -44,9 +42,7 @@ class CountersController < ApplicationController
|
|||
params.require(:counter).permit(
|
||||
:name,
|
||||
:value,
|
||||
character_sheet_feature_attributes: [
|
||||
:id, :featurable_id, :featurable_type, :character_sheet_section_id, :_destroy,
|
||||
],
|
||||
:character_sheet_section_id,
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,8 +5,6 @@ class DiceRollsController < ApplicationController
|
|||
|
||||
def create
|
||||
rollable = dice_roll_params[:rollable_type].constantize.find(dice_roll_params[:rollable_id])
|
||||
return head :bad_request if rollable.roll_command.blank?
|
||||
|
||||
@table.dice_rolls.create!(
|
||||
rollable:,
|
||||
result: DiceRoller.new(rollable.roll_command, stat: rollable).roll,
|
||||
|
|
|
@ -7,12 +7,10 @@ class StatsController < ApplicationController
|
|||
|
||||
def new
|
||||
@stat = @section.stats.new
|
||||
@stat.build_character_sheet_feature
|
||||
end
|
||||
|
||||
def create
|
||||
@stat = @section.stats.new(stat_params)
|
||||
@editable = true
|
||||
unless @stat.save
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
|
@ -46,9 +44,7 @@ class StatsController < ApplicationController
|
|||
:name,
|
||||
:value,
|
||||
:roll_command,
|
||||
character_sheet_feature_attributes: [
|
||||
:id, :featurable_id, :featurable_type, :character_sheet_section_id, :_destroy,
|
||||
],
|
||||
:character_sheet_section_id,
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class TextFieldsController < ApplicationController
|
||||
before_action :set_section, only: [ :new, :create ]
|
||||
before_action :set_character, only: [ :new, :create ]
|
||||
before_action :set_text_field, only: [ :update, :destroy ]
|
||||
|
||||
def new
|
||||
@text_field = @section.text_fields.new
|
||||
@text_field.build_character_sheet_feature
|
||||
end
|
||||
|
||||
def create
|
||||
@text_field = @section.text_fields.new(text_field_params)
|
||||
@editable = true
|
||||
unless @text_field.save
|
||||
render :new, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
@text_field.update(text_field_params)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@id = helpers.dom_id(@text_field)
|
||||
@text_field.destroy
|
||||
end
|
||||
|
||||
private
|
||||
def set_character
|
||||
@character = @section.character
|
||||
end
|
||||
|
||||
def set_section
|
||||
@section = Current.user.character_sheet_sections.find(params[:character_sheet_section_id])
|
||||
end
|
||||
|
||||
def set_text_field
|
||||
@text_field = Current.user.text_fields.find(params[:id])
|
||||
end
|
||||
|
||||
def text_field_params
|
||||
params.require(:text_field).permit(
|
||||
:name,
|
||||
:content,
|
||||
:character_sheet_section_id,
|
||||
character_sheet_feature_attributes: [
|
||||
:id, :featurable_id, :featurable_type, :character_sheet_section_id, :_destroy,
|
||||
],
|
||||
)
|
||||
end
|
||||
end
|
|
@ -1,69 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CharacterSheetFeature < ApplicationRecord
|
||||
belongs_to :character_sheet_section
|
||||
belongs_to :featurable, polymorphic: true
|
||||
|
||||
validates :order_index, presence: true,
|
||||
numericality: { only_integer: true, greater_than: 0 },
|
||||
uniqueness: { scope: :character_sheet_section_id }
|
||||
|
||||
validates :slug, presence: true,
|
||||
length: { maximum: 100 },
|
||||
uniqueness: { scope: :character_sheet_section_id }
|
||||
|
||||
before_validation :set_slug
|
||||
before_validation :set_order_index
|
||||
|
||||
def move(to:)
|
||||
return if to == order_index
|
||||
|
||||
unless character_sheet_section.character_sheet_features.exists?(order_index: to)
|
||||
update!(order_index: to)
|
||||
return
|
||||
end
|
||||
|
||||
if to < order_index
|
||||
character_sheet_section.character_sheet_features.where(order_index: to...order_index)
|
||||
.update_all("order_index = order_index + 1")
|
||||
else
|
||||
character_sheet_section.character_sheet_features.where(order_index: (order_index+1)..to)
|
||||
.update_all("order_index = order_index - 1")
|
||||
end
|
||||
|
||||
update!(order_index: to)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_order_index
|
||||
return if order_index.present?
|
||||
|
||||
if character_sheet_section.character_sheet_features.any?
|
||||
self.order_index = character_sheet_section.character_sheet_features.order_index(:order_index).last.order_index + 1
|
||||
else
|
||||
self.order_index = 1
|
||||
end
|
||||
end
|
||||
|
||||
def set_slug
|
||||
return if slug.present? || featurable.name.blank?
|
||||
|
||||
slug = if character_sheet_section.parent_section.present?
|
||||
[
|
||||
character_sheet_section.parent_section.name.parameterize,
|
||||
featurable.name.parameterize,
|
||||
].join("-")
|
||||
else
|
||||
slug = featurable.name.parameterize
|
||||
end
|
||||
|
||||
suffix = 2
|
||||
while CharacterSheetFeature.exists?(slug:)
|
||||
slug = "#{slug}-#{suffix}"
|
||||
suffix += 1
|
||||
end
|
||||
|
||||
self.slug = slug
|
||||
end
|
||||
end
|
|
@ -7,13 +7,8 @@ class CharacterSheetSection < ApplicationRecord
|
|||
has_many :character_sheet_subsections, class_name: "CharacterSheetSection",
|
||||
foreign_key: :parent_section_id,
|
||||
dependent: :destroy
|
||||
has_many :character_sheet_features
|
||||
has_many :counters, dependent: :destroy, through: :character_sheet_features,
|
||||
source: :featurable, source_type: "Counter"
|
||||
has_many :stats, dependent: :destroy, through: :character_sheet_features,
|
||||
source: :featurable, source_type: "Stat"
|
||||
has_many :text_fields, dependent: :destroy, through: :character_sheet_features,
|
||||
source: :featurable, source_type: "TextField"
|
||||
has_many :counters, dependent: :destroy
|
||||
has_many :stats, dependent: :destroy
|
||||
|
||||
validates :name, presence: true,
|
||||
length: { maximum: 255 }
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module Sluggable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
validates :slug, presence: true,
|
||||
length: { maximum: 100 },
|
||||
uniqueness: { scope: :character_sheet_section_id }
|
||||
|
||||
before_validation :set_slug
|
||||
|
||||
private
|
||||
|
||||
def set_slug
|
||||
return if slug.present? || name.blank?
|
||||
|
||||
slug = if character_sheet_section.parent_section.present?
|
||||
[
|
||||
character_sheet_section.parent_section.name.parameterize,
|
||||
name.parameterize,
|
||||
].join("-")
|
||||
else
|
||||
slug = name.parameterize
|
||||
end
|
||||
|
||||
suffix = 2
|
||||
while Stat.exists?(slug:)
|
||||
slug = "#{slug}-#{suffix}"
|
||||
suffix += 1
|
||||
end
|
||||
|
||||
self.slug = slug
|
||||
end
|
||||
end
|
||||
end
|
|
@ -1,12 +1,14 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Counter < ApplicationRecord
|
||||
has_one :character_sheet_feature, as: :featurable
|
||||
has_one :character_sheet_section, through: :character_sheet_feature
|
||||
accepts_nested_attributes_for :character_sheet_feature, allow_destroy: true
|
||||
include Sluggable
|
||||
|
||||
belongs_to :character_sheet_section
|
||||
|
||||
validates :name, presence: true,
|
||||
length: { maximum: 100 }
|
||||
length: { maximum: 100 },
|
||||
uniqueness: { scope: :character_sheet_section_id }
|
||||
validates :value, presence: true,
|
||||
numericality: true
|
||||
before_validation :set_slug
|
||||
end
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Stat < ApplicationRecord
|
||||
has_one :character_sheet_feature, as: :featurable
|
||||
has_one :character_sheet_section, through: :character_sheet_feature
|
||||
accepts_nested_attributes_for :character_sheet_feature, allow_destroy: true
|
||||
include Sluggable
|
||||
|
||||
belongs_to :character_sheet_section
|
||||
has_one :character, through: :character_sheet_section
|
||||
has_many :dice_rolls, as: :rollable, dependent: :destroy
|
||||
|
||||
validates :name, presence: true,
|
||||
length: { maximum: 100 }
|
||||
length: { maximum: 100 },
|
||||
uniqueness: { scope: :character_sheet_section_id }
|
||||
validates :slug, presence: true,
|
||||
length: { maximum: 100 },
|
||||
uniqueness: true
|
||||
validates :value, presence: true,
|
||||
numericality: true
|
||||
validate :validate_roll_command
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class TextField < ApplicationRecord
|
||||
has_one :character_sheet_feature, as: :featurable
|
||||
has_one :character_sheet_section, through: :character_sheet_feature
|
||||
accepts_nested_attributes_for :character_sheet_feature, allow_destroy: true
|
||||
|
||||
has_rich_text :content
|
||||
|
||||
validates :name, presence: true,
|
||||
length: { maximum: 100 }
|
||||
end
|
|
@ -12,7 +12,6 @@ class User < ApplicationRecord
|
|||
has_many :counters, through: :character_sheet_sections
|
||||
has_many :stats, through: :character_sheet_sections
|
||||
has_many :tables, through: :players
|
||||
has_many :text_fields, through: :character_sheet_sections
|
||||
has_rich_text :profile
|
||||
has_one_attached :avatar do |attachable|
|
||||
attachable.variant :standard, resize_to_limit: [ 100, 100 ], preprocessed: true
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
<%= render character_sheet_feature.featurable %>
|
|
@ -4,8 +4,14 @@
|
|||
<h4><%= character_sheet_section.name %></h4>
|
||||
|
||||
<div class="content">
|
||||
<div id="<%= dom_id(character_sheet_section) %>_features" class="stats">
|
||||
<%= render character_sheet_section.character_sheet_features.order(:order_index) %>
|
||||
<div id="<%= dom_id(character_sheet_section) %>_stats" class="stats">
|
||||
<%= render character_sheet_section.stats %>
|
||||
</div>
|
||||
<div id="<%= dom_id(character_sheet_section) %>_counters" class="counters">
|
||||
<%= render character_sheet_section.counters %>
|
||||
</div>
|
||||
<div id="<%= dom_id(character_sheet_section) %>_sections">
|
||||
<%= render character_sheet_section.character_sheet_subsections %>
|
||||
</div>
|
||||
<% if @editable %>
|
||||
<div id="<%= dom_id(character_sheet_section) %>_add_section">
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
new_character_sheet_section_stat_path(section), data: { turbo_stream: true }, class: "add-stat" %>
|
||||
<%= link_to t(".add_counter"),
|
||||
new_character_sheet_section_counter_path(section), data: { turbo_stream: true }, class: "add-counter" %>
|
||||
<%= link_to t(".add_text_field"),
|
||||
new_character_sheet_section_text_field_path(section), data: { turbo_stream: true }, class: "add-text-field" %>
|
||||
<% end %>
|
||||
<% unless id == "character_sheet_add_section" %>
|
||||
<%= link_to t(".delete_section", name: section.name), character_sheet_section_path(section),
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
<section class="inset">
|
||||
<%= form_with model: @counter, url: character_sheet_section_counters_path(@section) do |f| %>
|
||||
<% if @counter.new_record? %>
|
||||
<%= f.fields_for :character_sheet_feature do |ff| %>
|
||||
<%= ff.hidden_field :featurable_id, value: @counter.id %>
|
||||
<%= ff.hidden_field :character_sheet_section_id, value: @section.id %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= f.hidden_field :character_sheet_section_id, value: @section.id %>
|
||||
|
||||
<%= f.label :name %>
|
||||
<%= f.text_field :name %>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<% content_target = "#{dom_id(@section)}_features" %>
|
||||
<%= content_target = "#{dom_id(@section)}_counters" %>
|
||||
<%= turbo_stream.append(content_target) do %>
|
||||
<%= render @counter %>
|
||||
<% end %>
|
||||
|
||||
<% form_target = "#{dom_id(@section)}_add_section" %>
|
||||
<%= form_target = "#{dom_id(@section)}_add_section" %>
|
||||
<%= turbo_stream.replace(form_target) do %>
|
||||
<div id="<%= dom_id(@section) %>_add_section">
|
||||
<div id="#{dom_id(@section)}_add_section">
|
||||
<%= render partial: "character_sheet_sections/edit_links", locals: { section: @section, parent: @section.parent_section, id: nil} %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<% target = "#{dom_id(@section)}_add_section" %>
|
||||
<% target = "#{dom_id(@counter.character_sheet_section)}_add_section" %>
|
||||
<%= turbo_stream.replace(target) do %>
|
||||
<div id="<%= target %>">
|
||||
<%= render partial: "form", locals: { button_text: t(".create_counter") } %>
|
||||
|
|
|
@ -1,11 +1,6 @@
|
|||
<section class="inset">
|
||||
<%= form_with model: @stat, url: character_sheet_section_stats_path(@section) do |f| %>
|
||||
<% if @stat.new_record? %>
|
||||
<%= f.fields_for :character_sheet_feature do |ff| %>
|
||||
<%= ff.hidden_field :featurable_id, value: @stat.id %>
|
||||
<%= ff.hidden_field :character_sheet_section_id, value: @section.id %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= f.hidden_field :character_sheet_section_id, value: @section.id %>
|
||||
|
||||
<%= f.label :name %>
|
||||
<%= f.text_field :name %>
|
||||
|
|
|
@ -8,14 +8,12 @@
|
|||
<%= form_with model: stat, class: "stat-form", data: { controller: "auto-update" } do |f| %>
|
||||
<%= f.number_field :value %>
|
||||
<% end %>
|
||||
<% elsif stat.roll_command.present? %>
|
||||
<% else %>
|
||||
<%= form_with model: DiceRoll.new, url: table_dice_rolls_path(stat.character.table), class: "stat-form",
|
||||
data: { controller: "dice-roll" } do |f| %>
|
||||
<%= f.hidden_field :rollable_type, value: "Stat" %>
|
||||
<%= f.hidden_field :rollable_id, value: stat.id %>
|
||||
<div class="stat-value" data-action="click->dice-roll#rollDice"><%= stat.value %></div>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<div class="stat-value"><%= stat.value %></div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<%= content_target = "#{dom_id(@section)}_features" %>
|
||||
<%= content_target = "#{dom_id(@section)}_stats" %>
|
||||
<%= turbo_stream.append(content_target) do %>
|
||||
<%= render @stat %>
|
||||
<% end %>
|
||||
|
||||
<%= form_target = "#{dom_id(@section)}_add_section" %>
|
||||
<%= turbo_stream.replace(form_target) do %>
|
||||
<div id="<%= dom_id(@section) %>_add_section">
|
||||
<div id="#{dom_id(@section)}_add_section">
|
||||
<%= render partial: "character_sheet_sections/edit_links", locals: { section: @section, parent: @section.parent_section, id: nil} %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<% target = "#{dom_id(@section)}_add_section" %>
|
||||
<% target = "#{dom_id(@stat.character_sheet_section)}_add_section" %>
|
||||
<%= turbo_stream.replace(target) do %>
|
||||
<div id="<%= target %>">
|
||||
<%= render partial: "form", locals: { button_text: t(".create_stat") } %>
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
<section class="inset">
|
||||
<%= form_with model: @text_field, url: character_sheet_section_text_fields_path(@section) do |f| %>
|
||||
<% if @text_field.new_record? %>
|
||||
<%= f.fields_for :character_sheet_feature do |ff| %>
|
||||
<%= ff.hidden_field :featurable_id, value: @text_field.id %>
|
||||
<%= ff.hidden_field :character_sheet_section_id, value: @section.id %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= f.label :name %>
|
||||
<%= f.text_field :name %>
|
||||
<%= display_form_errors(@section, :name) %>
|
||||
|
||||
<%= f.submit button_text %>
|
||||
<% end %>
|
||||
</section>
|
|
@ -1,17 +0,0 @@
|
|||
<div class="text-field" id="<%= dom_id(text_field) %>">
|
||||
<% if @editable %>
|
||||
<%= link_to t(".delete"), text_field,
|
||||
data: { turbo_method: :delete, turbo_confirm: t(".confirm_delete", name: text_field.name) } %>
|
||||
<% end %>
|
||||
|
||||
<h6><%= text_field.name %></h6>
|
||||
<% if @editable %>
|
||||
<%= form_with model: text_field, class: "text-field-form" do |f| %>
|
||||
<%= f.rich_text_area :content %>
|
||||
<%= f.submit t(".save") %>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<p><%= text_field.content %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
<% content_target = "#{dom_id(@section)}_features" %>
|
||||
<%= turbo_stream.append(content_target) do %>
|
||||
<%= render @text_field %>
|
||||
<% end %>
|
||||
|
||||
<% form_target = "#{dom_id(@section)}_add_section" %>
|
||||
<%= turbo_stream.replace(form_target) do %>
|
||||
<div id="<% dom_id(@section) %>_add_section">
|
||||
<%= render partial: "character_sheet_sections/edit_links", locals: { section: @section, parent: @section.parent_section, id: nil} %>
|
||||
</div>
|
||||
<% end %>
|
|
@ -1 +0,0 @@
|
|||
<%= turbo_stream.remove @id %>
|
|
@ -1,6 +0,0 @@
|
|||
<% target = "#{dom_id(@section)}_add_section" %>
|
||||
<%= turbo_stream.replace(target) do %>
|
||||
<div id="<%= target %>">
|
||||
<%= render partial: "form", locals: { button_text: t(".create_text_field") } %>
|
||||
</div>
|
||||
<% end %>
|
|
@ -1,3 +0,0 @@
|
|||
<%= turbo_stream.replace dom_id(@text_field) do %>
|
||||
<%= render @text_field %>
|
||||
<% end %>
|
|
@ -65,7 +65,6 @@ en:
|
|||
confirm_delete: Are you sure you want to delete this section?
|
||||
add_stat: Add stat
|
||||
add_counter: Add counter
|
||||
add_text_field: Add text field
|
||||
index:
|
||||
edit: Edit character sheet
|
||||
stop_editing: Stop editing
|
||||
|
@ -214,13 +213,6 @@ en:
|
|||
destroy:
|
||||
success: Deleted table “%{name}”.
|
||||
error: Failed to delete table.
|
||||
text_fields:
|
||||
text_field:
|
||||
delete: Delete text field
|
||||
confirm_delete: Are you sure you want to delete %{name}?
|
||||
save: Save
|
||||
new:
|
||||
create_text_field: Create text field
|
||||
users:
|
||||
validations:
|
||||
email_format: "must be a valid email address"
|
||||
|
|
|
@ -18,7 +18,6 @@ Rails.application.routes.draw do
|
|||
resources :character_sheet_sections, only: [ :destroy ] do
|
||||
resources :counters, only: [ :new, :create ]
|
||||
resources :stats, only: [ :new, :create ]
|
||||
resources :text_fields, only: [ :new, :create ]
|
||||
end
|
||||
resources :characters do
|
||||
resources :character_sheet_sections, only: [ :index, :new, :create ]
|
||||
|
@ -34,7 +33,6 @@ Rails.application.routes.draw do
|
|||
resources :events, only: [ :index ]
|
||||
resources :table_invites, only: [ :new, :create ]
|
||||
end
|
||||
resources :text_fields, only: [ :update, :destroy ]
|
||||
|
||||
resources :admin, only: [ :index ]
|
||||
namespace :admin do
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateTextFields < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
create_table :text_fields do |t|
|
||||
t.belongs_to :character_sheet_section, null: false, foreign_key: true
|
||||
t.string :name, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
add_check_constraint :text_fields, "length(name) <= 100", name: "chk_text_field_name_max_length"
|
||||
end
|
||||
end
|
|
@ -1,25 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class CreateCharacterSheetFeatures < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
create_table :character_sheet_features, primary_key: [ :character_sheet_section_id, :featurable_id ] do |t|
|
||||
t.belongs_to :character_sheet_section, null: false, foreign_key: true
|
||||
t.belongs_to :featurable, null: false, polymorphic: true
|
||||
t.integer :order, null: false
|
||||
t.string :slug, null: false
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
|
||||
remove_column :counters, :character_sheet_section_id, :integer
|
||||
remove_column :stats, :character_sheet_section_id, :integer
|
||||
remove_column :text_fields, :character_sheet_section_id, :integer
|
||||
|
||||
remove_column :counters, :order_index, :integer
|
||||
remove_column :stats, :order_index, :integer
|
||||
remove_column :text_fields, :order_index, :integer
|
||||
|
||||
remove_column :counters, :slug, :string
|
||||
remove_column :stats, :slug, :string
|
||||
end
|
||||
end
|
|
@ -1,7 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class RenameOrderColumn < ActiveRecord::Migration[7.1]
|
||||
def change
|
||||
rename_column :character_sheet_features, :order, :order_index
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_06_17_151532) do
|
||||
ActiveRecord::Schema[7.1].define(version: 2024_06_13_072942) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
||||
|
@ -52,18 +52,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_06_17_151532) do
|
|||
t.index ["blob_id", "variation_digest"], name: "index_active_storage_variant_records_uniqueness", unique: true
|
||||
end
|
||||
|
||||
create_table "character_sheet_features", primary_key: ["character_sheet_section_id", "featurable_id"], force: :cascade do |t|
|
||||
t.bigint "character_sheet_section_id", null: false
|
||||
t.string "featurable_type", null: false
|
||||
t.bigint "featurable_id", null: false
|
||||
t.integer "order_index", null: false
|
||||
t.string "slug", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["character_sheet_section_id"], name: "index_character_sheet_features_on_character_sheet_section_id"
|
||||
t.index ["featurable_type", "featurable_id"], name: "index_character_sheet_features_on_featurable"
|
||||
end
|
||||
|
||||
create_table "character_sheet_sections", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.bigint "character_id", null: false
|
||||
|
@ -90,10 +78,16 @@ ActiveRecord::Schema[7.1].define(version: 2024_06_17_151532) do
|
|||
|
||||
create_table "counters", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.string "slug", null: false
|
||||
t.integer "value", default: 0, null: false
|
||||
t.bigint "character_sheet_section_id", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["character_sheet_section_id"], name: "index_counters_on_character_sheet_section_id"
|
||||
t.index ["name", "character_sheet_section_id"], name: "index_counters_on_name_and_character_sheet_section_id", unique: true
|
||||
t.index ["slug"], name: "index_counters_on_slug", unique: true
|
||||
t.check_constraint "length(name::text) <= 100", name: "chk_counter_name_max_length"
|
||||
t.check_constraint "length(slug::text) <= 100", name: "chk_counter_slug_max_length"
|
||||
end
|
||||
|
||||
create_table "dice_rolls", force: :cascade do |t|
|
||||
|
@ -242,11 +236,17 @@ ActiveRecord::Schema[7.1].define(version: 2024_06_17_151532) do
|
|||
|
||||
create_table "stats", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.string "slug", null: false
|
||||
t.bigint "character_sheet_section_id", null: false
|
||||
t.integer "value", default: 0, null: false
|
||||
t.string "roll_command"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["character_sheet_section_id"], name: "index_stats_on_character_sheet_section_id"
|
||||
t.index ["name", "character_sheet_section_id"], name: "index_stats_on_name_and_character_sheet_section_id", unique: true
|
||||
t.index ["slug"], name: "index_stats_on_slug", unique: true
|
||||
t.check_constraint "length(name::text) <= 100", name: "chk_stat_name_max_length"
|
||||
t.check_constraint "length(slug::text) <= 100", name: "chk_stat_slug_max_length"
|
||||
end
|
||||
|
||||
create_table "table_invites", force: :cascade do |t|
|
||||
|
@ -276,13 +276,6 @@ ActiveRecord::Schema[7.1].define(version: 2024_06_17_151532) do
|
|||
t.check_constraint "length(slug::text) <= 100", name: "chk_table_slug_max_length"
|
||||
end
|
||||
|
||||
create_table "text_fields", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.check_constraint "length(name::text) <= 100", name: "chk_text_field_name_max_length"
|
||||
end
|
||||
|
||||
create_table "users", force: :cascade do |t|
|
||||
t.string "username", limit: 20, null: false
|
||||
t.string "password_digest", limit: 200, null: false
|
||||
|
@ -303,12 +296,12 @@ ActiveRecord::Schema[7.1].define(version: 2024_06_17_151532) do
|
|||
|
||||
add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id"
|
||||
add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id"
|
||||
add_foreign_key "character_sheet_features", "character_sheet_sections"
|
||||
add_foreign_key "character_sheet_sections", "character_sheet_sections", column: "parent_section_id"
|
||||
add_foreign_key "character_sheet_sections", "characters"
|
||||
add_foreign_key "characters", "game_systems"
|
||||
add_foreign_key "characters", "tables"
|
||||
add_foreign_key "characters", "users"
|
||||
add_foreign_key "counters", "character_sheet_sections"
|
||||
add_foreign_key "dice_rolls", "tables"
|
||||
add_foreign_key "players", "tables"
|
||||
add_foreign_key "players", "users"
|
||||
|
@ -318,6 +311,7 @@ ActiveRecord::Schema[7.1].define(version: 2024_06_17_151532) do
|
|||
add_foreign_key "solid_queue_ready_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
|
||||
add_foreign_key "solid_queue_recurring_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
|
||||
add_foreign_key "solid_queue_scheduled_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade
|
||||
add_foreign_key "stats", "character_sheet_sections"
|
||||
add_foreign_key "table_invites", "tables"
|
||||
add_foreign_key "tables", "game_systems"
|
||||
add_foreign_key "tables", "users", column: "owner_id"
|
||||
|
|
|
@ -2,8 +2,3 @@ one:
|
|||
record: trevor (User)
|
||||
name: profile
|
||||
body: <p>I am just <strong>so awesome</strong></p>
|
||||
|
||||
two:
|
||||
record: background (TextField)
|
||||
name: content
|
||||
body: <p>Rhino-Man</p>
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
DEFAULTS: &DEFAULTS
|
||||
slug: $LABEL
|
||||
|
||||
stats-strength:
|
||||
<<: *DEFAULTS
|
||||
character_sheet_section: stats
|
||||
featurable: strength (Stat)
|
||||
order_index: 1
|
||||
|
||||
counter:
|
||||
<<: *DEFAULTS
|
||||
character_sheet_section: counters
|
||||
featurable: hp (Counter)
|
||||
order_index: 2
|
||||
|
||||
text_field:
|
||||
<<: *DEFAULTS
|
||||
character_sheet_section: info
|
||||
featurable: background (TextField)
|
||||
order_index: 3
|
|
@ -10,7 +10,3 @@ subsection:
|
|||
name: Subsection
|
||||
character: nardren
|
||||
parent_section: stats
|
||||
|
||||
info:
|
||||
name: Info
|
||||
character: nardren
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
hp:
|
||||
name: HP
|
||||
value: 10
|
||||
slug: hp
|
||||
character_sheet_section: counters
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
strength:
|
||||
name: Strength
|
||||
slug: strength
|
||||
character_sheet_section: stats
|
||||
value: 10
|
||||
roll_command: d20+self
|
||||
|
|
|
@ -1,2 +0,0 @@
|
|||
background:
|
||||
name: Background
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "test_helper"
|
||||
|
||||
class CharacterSheetFeatureTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
|
@ -13,16 +13,14 @@ class StatTest < ActiveSupport::TestCase
|
|||
|
||||
test "saving generates appropriate slug" do
|
||||
stat = Stat.create(name: "Foo", character_sheet_section: character_sheet_sections(:subsection))
|
||||
assert_equal "stats-foo", stat.character_sheet_feature.slug
|
||||
assert_equal "stats-foo", stat.slug
|
||||
end
|
||||
|
||||
test "generates unique slug always" do
|
||||
existing_stat = Stat.first
|
||||
stat = Stat.create(name: existing_stat.name)
|
||||
stat.build_character_sheet_feature(character_sheet_section: character_sheet_sections(:subsection))
|
||||
stat.valid?
|
||||
assert_not_equal existing_stat.character_sheet_feature.slug, stat.character_sheet_feature.slug
|
||||
assert_equal "#{existing_stat.character_sheet_feature.slug}-2", stat.character_sheet_feature.slug
|
||||
stat = Stat.create(name: existing_stat.name, character_sheet_section: existing_stat.character_sheet_section)
|
||||
assert_not_equal existing_stat.slug, stat.slug
|
||||
assert_equal "#{existing_stat.slug}-2", stat.slug
|
||||
end
|
||||
|
||||
test "rolls with roll_command" do
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "test_helper"
|
||||
|
||||
class TextFieldTest < ActiveSupport::TestCase
|
||||
test "name must exist" do
|
||||
assert_must_exist(text_fields(:background), :name)
|
||||
end
|
||||
end
|
8
todo.md
8
todo.md
|
@ -1,11 +1,9 @@
|
|||
- set orders on sheets
|
||||
- easily edit text fields without entering edit mode
|
||||
- add roll command to counters (e.g. luck)
|
||||
- test for rolls controller & system tests
|
||||
- Show individual dice on dice roll
|
||||
- customise trix bar
|
||||
- table notifications for rolls
|
||||
- roll on click
|
||||
- Sheets
|
||||
- Lists
|
||||
- Text fields
|
||||
- Weapons/spells
|
||||
- Character avatars
|
||||
- default avatars
|
||||
|
|
Loading…
Reference in New Issue