Compare commits

..

No commits in common. "d9bf4f745b12f7a9cd06b72eb0e036b0b3db01e8" and "fdbfa3c03fd849034b8167678c8e2b519361553c" have entirely different histories.

15 changed files with 48 additions and 124 deletions

View file

@ -66,10 +66,7 @@ gem "async-http", "~> 0.75.0", require: false
gem "thread-local", "~> 1.1", require: false
# For debugging.
group :development do
gem 'debug', '~> 1.9.2'
gem 'web-console', '~> 4.2'
end
gem 'web-console', '~> 4.2', group: :development
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '~> 1.16', require: false

View file

@ -134,9 +134,6 @@ GEM
crass (1.0.6)
csv (3.3.0)
date (3.3.4)
debug (1.9.2)
irb (~> 1.10)
reline (>= 0.3.8)
devise (4.9.4)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
@ -524,7 +521,6 @@ DEPENDENCIES
async (~> 2.17)
async-http (~> 0.75.0)
bootsnap (~> 1.16)
debug (~> 1.9.2)
devise (~> 4.9, >= 4.9.2)
devise-encryptable (~> 0.2.0)
dotenv-rails (~> 2.8, >= 2.8.1)

View file

@ -44,10 +44,6 @@
grid-template-columns: repeat(var(--num-columns, 1), 1fr)
gap: .25em
li
display: flex
align-items: stretch // Give the bubbles equal heights!
label
display: flex
align-items: center
@ -55,7 +51,6 @@
padding: .5em 1em
border: 1px solid $soft-border-color
border-radius: 1em
flex: 1 1 auto
input
margin: 0
@ -94,9 +89,9 @@
align-items: center
gap: 1em
.go-to-next
display: flex
align-items: center
gap: .25em
font-size: .85em
font-style: italic
label
display: flex
align-items: center
gap: .25em
font-size: .85em
font-style: italic

View file

@ -3,13 +3,3 @@ outfit-viewer
.fields li[data-type=radio-grid]
--num-columns: 3
.reference-link
display: flex
align-items: center
gap: .5em
padding-inline: .5em
img
height: 2em
width: auto

View file

@ -8,7 +8,7 @@ class PetStatesController < ApplicationController
def update
if @pet_state.update(pet_state_params)
flash[:notice] = "Pet appearance \##{@pet_state.id} successfully saved!"
redirect_to destination_after_save
redirect_to @pet_type
else
render action: :edit, status: :bad_request
end
@ -19,35 +19,9 @@ class PetStatesController < ApplicationController
def find_pet_state
@pet_type = PetType.find_by_param!(params[:pet_type_name])
@pet_state = @pet_type.pet_states.find(params[:id])
@reference_pet_type = @pet_type.reference
end
def pet_state_params
params.require(:pet_state).permit(:pose, :glitched)
end
def destination_after_save
if params[:next] == "unlabeled-appearance"
next_unlabeled_appearance_path
else
@pet_type
end
end
def next_unlabeled_appearance_path
# Rather than just getting the newest unlabeled pet state, prioritize the
# newest *pet type*. This better matches the user's perception of what the
# newest state is, because the Rainbow Pool UI is grouped by pet type!
unlabeled_appearance = PetState.needs_labeling.newest_pet_type.newest.first
if unlabeled_appearance
edit_pet_type_pet_state_path(
unlabeled_appearance.pet_type,
unlabeled_appearance,
next: "unlabeled-appearance"
)
else
@pet_type
end
end
end

View file

@ -1,29 +1,44 @@
module SupportFormHelper
class SupportFormBuilder < ActionView::Helpers::FormBuilder
attr_reader :template
delegate :capture, :check_box_tag, :content_tag, :params, :render,
to: :template, private: true
delegate :concat, :content_tag, :image_tag, to: :template, private: true
def errors
render partial: "application/support_form/errors", locals: {form: self}
return nil if object.errors.empty?
error_list = content_tag(:ul) do
object.errors.each do |error|
concat content_tag(:li, error.full_message)
end
end
content_tag(:p) do
concat "Could not save:"
concat error_list
end
end
def fields(&block)
content_tag(:ul, class: "fields", &block)
end
def field(**options, &block)
content_tag(:li, **options, &block)
def field(**kwargs, &block)
content_tag(:li, **kwargs, &block)
end
def radio_fieldset(legend, **options, &block)
render partial: "application/support_form/radio_fieldset",
locals: {form: self, legend:, options:, content: capture(&block)}
def radio_fieldset(legend, **kwargs, &block)
kwargs.reverse_merge!("data-type": "radio")
field(**kwargs) do
content_tag(:fieldset) do
concat content_tag(:legend, legend)
concat content_tag(:ul, &block)
end
end
end
def radio_field(**options, &block)
def radio_field(**kwargs, &block)
content_tag(:li) do
content_tag(:label, **options, &block)
content_tag(:label, **kwargs, &block)
end
end
@ -32,29 +47,19 @@ module SupportFormHelper
end
def thumbnail_input(method)
render partial: "application/support_form/thumbnail_input",
locals: {form: self, method:}
end
def actions(&block)
content_tag(:section, class: "actions", &block)
end
def go_to_next_field(**options, &block)
content_tag(:label, class: "go-to-next", **options, &block)
end
def go_to_next_check_box(value)
check_box_tag "next", value, checked: params[:next] == value
url = object.send(method)
content_tag(:div, class: "thumbnail-input") do
concat image_tag(url, alt: "Thumbnail") if url.present?
concat url_field(method)
end
end
end
def support_form_with(**options, &block)
form_with(
def support_form_with(**kwargs, &block)
kwargs.merge!(
builder: SupportFormBuilder,
**options,
class: ["support-form", options[:class]],
&block
class: ["support-form", kwargs[:class]],
)
form_with(**kwargs, &block)
end
end

View file

@ -17,11 +17,6 @@ class PetState < ApplicationRecord
alias_method :swf_asset_ids_from_association, :swf_asset_ids
scope :newest, -> { order(created_at: :desc) }
scope :newest_pet_type, -> { joins(:pet_type).merge(PetType.newest) }
scope :unlabeled, -> { with_pose("UNKNOWN") }
scope :needs_labeling, -> { unlabeled.where(glitched: false) }
# A simple ordering that tries to bring reliable pet states to the front.
scope :emotion_order, -> {
order(Arel.sql(

View file

@ -15,7 +15,6 @@ class PetType < ApplicationRecord
species = Species.find_by_name!(species_name)
where(color_id: color.id, species_id: species.id)
}
scope :newest, -> { order(created_at: :desc) }
scope :preferring_species, ->(species_id) {
joins(:species).order([Arel.sql("species_id = ? DESC"), species_id])
}
@ -137,10 +136,6 @@ class PetType < ApplicationRecord
pet_states.count { |ps| ps.pose == "UNKNOWN" }
end
def reference
PetType.where(species_id: species).basic.merge(Color.alphabetical).first
end
def self.find_by_param!(param)
raise ActiveRecord::RecordNotFound unless param.include?("-")
color_param, _, species_param = param.rpartition("-")

View file

@ -26,10 +26,11 @@
= f.label :thumbnail_url, "Thumbnail"
= f.thumbnail_input :thumbnail_url
= f.actions do
.actions
= f.submit "Save changes"
= f.go_to_next_field title: "If checked, takes you to the next unlabeled pet style, if any. Useful for labeling in bulk!" do
= f.go_to_next_check_box "unlabeled-style"
%label{title: "If checked, takes you to the next unlabeled pet style, if any. Useful for labeling in bulk!"}
= check_box_tag "next", "unlabeled-style",
checked: params[:next] == "unlabeled-style"
Then: Go to unlabeled style
- content_for :stylesheets do

View file

@ -1,7 +0,0 @@
- if form.object.errors.any?
%section.errors
Could not save:
%ul
- form.object.errors.each do |error|
%li= error.full_message

View file

@ -1,4 +0,0 @@
= form.field("data-type": "radio", **options) do
%fieldset
%legend= legend
%ul= content

View file

@ -1,5 +0,0 @@
- url = form.object.send(method)
.thumbnail-input
- if url.present?
= image_tag url, alt: "Thumbnail"
= form.url_field method

View file

@ -51,7 +51,7 @@
= f.radio_button :explicitly_body_specific, true
Body-specific: Fits all species differently
= f.actions do
.actions
= f.submit "Save changes"
- content_for :stylesheets do

View file

@ -26,22 +26,14 @@
= f.radio_field do
= f.radio_button :pose, pose
= pose_name(pose)
- if @reference_pet_type
= link_to @reference_pet_type, target: "_blank", class: "reference-link" do
= pet_type_image @reference_pet_type, :happy, :face
%span Reference: #{@reference_pet_type.human_name}
= external_link_icon
= f.field do
= f.label :glitched, "Gliched?"
= f.select :glitched, [["✅ Not marked as Glitched", false],
["👾 Yes, it's bad news bonko'd", true]]
= f.actions do
.actions
= f.submit "Save changes"
= f.go_to_next_field title: "If checked, takes you to the first unlabeled appearance in the database, if any. Useful for labeling in bulk!" do
= f.go_to_next_check_box "unlabeled-appearance"
Then: Go to unlabeled appearance
- content_for :stylesheets do
= stylesheet_link_tag "application/breadcrumbs"

Binary file not shown.