From 23c083ff1d0056b3c56e42795823db468039c615 Mon Sep 17 00:00:00 2001 From: Emi Matchu Date: Fri, 18 Oct 2024 17:13:16 -0700 Subject: [PATCH] Use "real" series name field when editing alt styles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 " --- app/controllers/alt_styles_controller.rb | 2 +- app/models/alt_style.rb | 14 +++++++++++--- app/models/item/search/query.rb | 2 +- app/views/alt_styles/edit.html.haml | 4 ++-- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/controllers/alt_styles_controller.rb b/app/controllers/alt_styles_controller.rb index 060128a9..93a10c46 100644 --- a/app/controllers/alt_styles_controller.rb +++ b/app/controllers/alt_styles_controller.rb @@ -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 diff --git a/app/models/alt_style.rb b/app/models/alt_style.rb index d017fac8..edb5e64c 100644 --- a/app/models/alt_style.rb +++ b/app/models/alt_style.rb @@ -35,13 +35,21 @@ class AltStyle < ApplicationRecord # `fits:-faerie-draik` intentionally will not work, and the canonical # filter name will be `fits:alt-style-IDNUMBER`, instead. def series_name - self[:series_name] || "" + real_series_name || "" + 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 diff --git a/app/models/item/search/query.rb b/app/models/item/search/query.rb index 5e46b23d..e34c8c9c 100644 --- a/app/models/item/search/query.rb +++ b/app/models/item/search/query.rb @@ -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 diff --git a/app/views/alt_styles/edit.html.haml b/app/views/alt_styles/edit.html.haml index aa6e09b7..0b061bde 100644 --- a/app/views/alt_styles/edit.html.haml +++ b/app/views/alt_styles/edit.html.haml @@ -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?