Add layers table to pet appearance edit page
Gonna add some more functionality here too, but right now we at least have this!
This commit is contained in:
parent
c32a495780
commit
d92e3288ab
8 changed files with 101 additions and 12 deletions
|
@ -1,5 +1,5 @@
|
||||||
outfit-viewer
|
support-outfit-viewer
|
||||||
margin: 0 auto
|
margin-block: 1em
|
||||||
|
|
||||||
.fields li[data-type=radio-grid]
|
.fields li[data-type=radio-grid]
|
||||||
--num-columns: 3
|
--num-columns: 3
|
||||||
|
|
31
app/assets/stylesheets/pet_states/support-outfit-viewer.sass
Normal file
31
app/assets/stylesheets/pet_states/support-outfit-viewer.sass
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
@import "../partials/clean/constants"
|
||||||
|
|
||||||
|
support-outfit-viewer
|
||||||
|
display: flex
|
||||||
|
gap: 2em
|
||||||
|
flex-wrap: wrap
|
||||||
|
justify-content: center
|
||||||
|
|
||||||
|
outfit-viewer
|
||||||
|
flex: 0 0 auto
|
||||||
|
border: 1px solid $module-border-color
|
||||||
|
border-radius: 1em
|
||||||
|
|
||||||
|
> table
|
||||||
|
flex: 0 0 auto
|
||||||
|
border-collapse: collapse
|
||||||
|
table-layout: fixed
|
||||||
|
border-radius: .5em
|
||||||
|
|
||||||
|
th, td
|
||||||
|
border: 1px solid $soft-border-color
|
||||||
|
font-size: .85em
|
||||||
|
padding: .25em .5em
|
||||||
|
text-align: left
|
||||||
|
|
||||||
|
> tbody
|
||||||
|
> tr > :nth-child(3) // links column
|
||||||
|
ul
|
||||||
|
list-style-type: none
|
||||||
|
display: flex
|
||||||
|
gap: .5em
|
|
@ -1,6 +1,7 @@
|
||||||
class PetStatesController < ApplicationController
|
class PetStatesController < ApplicationController
|
||||||
before_action :find_pet_state
|
|
||||||
before_action :support_staff_only
|
before_action :support_staff_only
|
||||||
|
before_action :find_pet_state
|
||||||
|
before_action :preload_assets
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
end
|
end
|
||||||
|
@ -22,6 +23,10 @@ class PetStatesController < ApplicationController
|
||||||
@reference_pet_type = @pet_type.reference
|
@reference_pet_type = @pet_type.reference
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def preload_assets
|
||||||
|
SwfAsset.preload_manifests @pet_state.swf_assets
|
||||||
|
end
|
||||||
|
|
||||||
def pet_state_params
|
def pet_state_params
|
||||||
params.require(:pet_state).permit(:pose, :glitched)
|
params.require(:pet_state).permit(:pose, :glitched)
|
||||||
end
|
end
|
||||||
|
|
|
@ -65,11 +65,25 @@ module OutfitsHelper
|
||||||
text_field_tag 'name', nil, options
|
text_field_tag 'name', nil, options
|
||||||
end
|
end
|
||||||
|
|
||||||
def outfit_viewer(outfit=nil, pet_state: nil, **html_options)
|
def outfit_viewer(...)
|
||||||
outfit = Outfit.new(pet_state:) if outfit.nil? && pet_state.present?
|
render partial: "outfit_viewer",
|
||||||
raise "outfit_viewer must have outfit or pet state" if outfit.nil?
|
locals: parse_outfit_viewer_options(...)
|
||||||
|
end
|
||||||
|
|
||||||
render partial: "outfit_viewer", locals: {outfit:, html_options:}
|
def support_outfit_viewer(...)
|
||||||
|
render partial: "support_outfit_viewer",
|
||||||
|
locals: parse_outfit_viewer_options(...)
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def parse_outfit_viewer_options(outfit=nil, pet_state: nil, **html_options)
|
||||||
|
outfit = Outfit.new(pet_state:) if outfit.nil? && pet_state.present?
|
||||||
|
|
||||||
|
if outfit.nil?
|
||||||
|
raise ArgumentError, "outfit viewer must have outfit or pet state"
|
||||||
|
end
|
||||||
|
|
||||||
|
{outfit:, html_options:}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ class SwfAsset < ApplicationRecord
|
||||||
{
|
{
|
||||||
swf: url,
|
swf: url,
|
||||||
png: image_url,
|
png: image_url,
|
||||||
svg: manifest_asset_urls[:svg],
|
svg: svg_url,
|
||||||
canvas_library: manifest_asset_urls[:js],
|
canvas_library: manifest_asset_urls[:js],
|
||||||
manifest: manifest_url,
|
manifest: manifest_url,
|
||||||
}
|
}
|
||||||
|
@ -186,6 +186,18 @@ class SwfAsset < ApplicationRecord
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def image_url?
|
||||||
|
image_url.present?
|
||||||
|
end
|
||||||
|
|
||||||
|
def svg_url
|
||||||
|
manifest_asset_urls[:svg]
|
||||||
|
end
|
||||||
|
|
||||||
|
def svg_url?
|
||||||
|
svg_url.present?
|
||||||
|
end
|
||||||
|
|
||||||
def canvas_movie?
|
def canvas_movie?
|
||||||
canvas_movie_library_url.present?
|
canvas_movie_library_url.present?
|
||||||
end
|
end
|
||||||
|
|
25
app/views/pet_states/_support_outfit_viewer.html.haml
Normal file
25
app/views/pet_states/_support_outfit_viewer.html.haml
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
= content_tag "support-outfit-viewer", **html_options do
|
||||||
|
= outfit_viewer outfit
|
||||||
|
%table
|
||||||
|
%thead
|
||||||
|
%tr
|
||||||
|
%th{scope: "col"} DTI ID
|
||||||
|
%th{scope: "col"} Zone
|
||||||
|
%th{scope: "col"} Links
|
||||||
|
%tbody
|
||||||
|
- outfit.visible_layers.each do |swf_asset|
|
||||||
|
%tr
|
||||||
|
%th{scope: "row"}
|
||||||
|
= swf_asset.id
|
||||||
|
%td
|
||||||
|
= swf_asset.zone.label
|
||||||
|
(##{swf_asset.zone.id})
|
||||||
|
%td
|
||||||
|
%ul
|
||||||
|
- if swf_asset.image_url?
|
||||||
|
%li= link_to "PNG", swf_asset.image_url, target: "_blank"
|
||||||
|
- if swf_asset.svg_url?
|
||||||
|
%li= link_to "SVG", swf_asset.svg_url, target: "_blank"
|
||||||
|
%li= link_to "SWF", swf_asset.url, target: "_blank"
|
||||||
|
- if swf_asset.manifest_url?
|
||||||
|
%li= link_to "Manifest", swf_asset.manifest_url, target: "_blank"
|
|
@ -6,16 +6,16 @@
|
||||||
= link_to "Rainbow Pool", pet_types_path
|
= link_to "Rainbow Pool", pet_types_path
|
||||||
%li
|
%li
|
||||||
= link_to @pet_type.possibly_new_color.human_name,
|
= link_to @pet_type.possibly_new_color.human_name,
|
||||||
pet_types_path(color: @pet_type.possibly_new_color.human_name)
|
pet_types_path(color: @pet_type.possibly_new_color.human_name)
|
||||||
%li{"data-relation-to-prev": "sibling"}
|
%li{"data-relation-to-prev": "sibling"}
|
||||||
= link_to @pet_type.possibly_new_species.human_name,
|
= link_to @pet_type.possibly_new_species.human_name,
|
||||||
pet_types_path(species: @pet_type.possibly_new_species.human_name)
|
pet_types_path(species: @pet_type.possibly_new_species.human_name)
|
||||||
%li
|
%li
|
||||||
= link_to "Appearances", @pet_type
|
= link_to "Appearances", @pet_type
|
||||||
%li
|
%li
|
||||||
\##{@pet_state.id}
|
\##{@pet_state.id}
|
||||||
|
|
||||||
= outfit_viewer pet_state: @pet_state
|
= support_outfit_viewer pet_state: @pet_state
|
||||||
|
|
||||||
= support_form_with model: [@pet_type, @pet_state] do |f|
|
= support_form_with model: [@pet_type, @pet_state] do |f|
|
||||||
= f.errors
|
= f.errors
|
||||||
|
@ -47,7 +47,9 @@
|
||||||
= stylesheet_link_tag "application/breadcrumbs"
|
= stylesheet_link_tag "application/breadcrumbs"
|
||||||
= stylesheet_link_tag "application/outfit-viewer"
|
= stylesheet_link_tag "application/outfit-viewer"
|
||||||
= stylesheet_link_tag "application/support-form"
|
= stylesheet_link_tag "application/support-form"
|
||||||
|
= stylesheet_link_tag "pet_states/support-outfit-viewer"
|
||||||
= page_stylesheet_link_tag "pet_states/edit"
|
= page_stylesheet_link_tag "pet_states/edit"
|
||||||
|
|
||||||
- content_for :javascripts do
|
- content_for :javascripts do
|
||||||
= javascript_include_tag "outfit-viewer"
|
= javascript_include_tag "outfit-viewer"
|
||||||
|
= javascript_include_tag "pet_states/support-outfit-viewer"
|
||||||
|
|
Loading…
Reference in a new issue