diff --git a/app/assets/stylesheets/pet_states/edit.sass b/app/assets/stylesheets/pet_states/edit.sass index 727d4ed56..616176379 100644 --- a/app/assets/stylesheets/pet_states/edit.sass +++ b/app/assets/stylesheets/pet_states/edit.sass @@ -3,3 +3,13 @@ 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 diff --git a/app/controllers/pet_states_controller.rb b/app/controllers/pet_states_controller.rb index bc9aed56d..cd988d9c9 100644 --- a/app/controllers/pet_states_controller.rb +++ b/app/controllers/pet_states_controller.rb @@ -19,6 +19,7 @@ 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 diff --git a/app/models/pet_type.rb b/app/models/pet_type.rb index 3c6dda412..08606c4a3 100644 --- a/app/models/pet_type.rb +++ b/app/models/pet_type.rb @@ -137,6 +137,10 @@ 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("-") diff --git a/app/views/pet_states/edit.html.haml b/app/views/pet_states/edit.html.haml index 9a407baed..79d302c0d 100644 --- a/app/views/pet_states/edit.html.haml +++ b/app/views/pet_states/edit.html.haml @@ -26,6 +26,11 @@ = 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?"