Use "real" series name field when editing alt styles

Just a little improvement to the form, so when there's no series name,
the text field is empty—even though in most contexts we *pretend* it's
"<New?">
This commit is contained in:
Emi Matchu 2024-10-18 17:13:16 -07:00
parent 6b7c73870a
commit 23c083ff1d
4 changed files with 15 additions and 7 deletions

View file

@ -63,7 +63,7 @@ class AltStylesController < ApplicationController
protected
def alt_style_params
params.require(:alt_style).permit(:series_name, :thumbnail_url)
params.require(:alt_style).permit(:real_series_name, :thumbnail_url)
end
def find_color

View file

@ -35,13 +35,21 @@ class AltStyle < ApplicationRecord
# `fits:<New?>-faerie-draik` intentionally will not work, and the canonical
# filter name will be `fits:alt-style-IDNUMBER`, instead.
def series_name
self[:series_name] || "<New?>"
real_series_name || "<New?>"
end
def real_series_name=(new_series_name)
self[:series_name] = new_series_name
end
def real_series_name
self[:series_name]
end
# You can use this to check whether `series_name` is returning the actual
# value or its placeholder value.
def has_real_series_name?
self[:series_name].present?
def real_series_name?
real_series_name.present?
end
def adjective_name

View file

@ -367,7 +367,7 @@ class Item
# If the real series name has been set in the database by support
# staff, use that for the canonical filter text for this alt style.
# Otherwise, represent this alt style by ID.
if alt_style.has_real_series_name?
if alt_style.real_series_name?
series_name = alt_style.series_name.downcase
color_name = alt_style.color.name.downcase
species_name = alt_style.species.name.downcase

View file

@ -21,8 +21,8 @@
- @alt_style.errors.each do |error|
%li= error.full_message
%fieldset
= f.label :series_name, "Series"
= f.text_field :series_name
= f.label :real_series_name, "Series"
= f.text_field :real_series_name
= f.label :thumbnail_url, "Thumbnail"
.thumbnail-field
- if @alt_style.thumbnail_url?