Add edit page for items, to set modeling status for done/glitchy items
This commit is contained in:
parent
388bb9a251
commit
3937ba354f
6 changed files with 88 additions and 5 deletions
|
@ -19,8 +19,10 @@
|
||||||
input[type=url]
|
input[type=url]
|
||||||
font-size: .85em
|
font-size: .85em
|
||||||
|
|
||||||
label
|
> label, .field-name
|
||||||
font-weight: bold
|
font-weight: bold
|
||||||
|
&:has(+ .radio-field)
|
||||||
|
align-self: start
|
||||||
|
|
||||||
.thumbnail-field
|
.thumbnail-field
|
||||||
display: flex
|
display: flex
|
||||||
|
@ -34,6 +36,11 @@
|
||||||
input
|
input
|
||||||
flex: 1 0 20ch
|
flex: 1 0 20ch
|
||||||
|
|
||||||
|
.radio-field
|
||||||
|
display: flex
|
||||||
|
flex-direction: column
|
||||||
|
gap: .25em
|
||||||
|
|
||||||
.field_with_errors
|
.field_with_errors
|
||||||
display: contents
|
display: contents
|
||||||
|
|
||||||
|
|
|
@ -67,14 +67,21 @@
|
||||||
background: #FEEBC8
|
background: #FEEBC8
|
||||||
color: #7B341E
|
color: #7B341E
|
||||||
|
|
||||||
|
.support-form
|
||||||
|
grid-area: support
|
||||||
|
font-size: 85%
|
||||||
|
text-align: left
|
||||||
|
|
||||||
.user-lists-info
|
.user-lists-info
|
||||||
grid-area: lists
|
grid-area: lists
|
||||||
font-size: 85%
|
font-size: 85%
|
||||||
text-align: left
|
text-align: left
|
||||||
|
|
||||||
.user-lists-form-opener
|
display: flex
|
||||||
&::after
|
gap: 1em
|
||||||
content: " ›"
|
|
||||||
|
a::after
|
||||||
|
content: " ›"
|
||||||
|
|
||||||
.user-lists-form
|
.user-lists-form
|
||||||
background: $background-color
|
background: $background-color
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
class ItemsController < ApplicationController
|
class ItemsController < ApplicationController
|
||||||
before_action :set_query
|
before_action :set_query
|
||||||
|
before_action :support_staff_only, except: [:index, :show, :sources]
|
||||||
rescue_from Item::Search::Error, :with => :search_error
|
rescue_from Item::Search::Error, :with => :search_error
|
||||||
|
|
||||||
def index
|
def index
|
||||||
|
@ -112,6 +113,21 @@ class ItemsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def edit
|
||||||
|
@item = Item.find params[:id]
|
||||||
|
render layout: "application"
|
||||||
|
end
|
||||||
|
|
||||||
|
def update
|
||||||
|
@item = Item.find params[:id]
|
||||||
|
if @item.update(item_params)
|
||||||
|
flash[:notice] = "\"#{@item.name}\" successfully saved!"
|
||||||
|
redirect_to @item
|
||||||
|
else
|
||||||
|
render action: "edit", layout: "application"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def sources
|
def sources
|
||||||
# Load all the items, then group them by source.
|
# Load all the items, then group them by source.
|
||||||
item_ids = params[:ids].split(",")
|
item_ids = params[:ids].split(",")
|
||||||
|
@ -164,6 +180,14 @@ class ItemsController < ApplicationController
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
def item_params
|
||||||
|
params.require(:item).permit(
|
||||||
|
:name, :thumbnail_url, :description, :modeling_status_hint
|
||||||
|
).tap do |p|
|
||||||
|
p[:modeling_status_hint] = nil if p[:modeling_status_hint] == ""
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def assign_closeted!(items)
|
def assign_closeted!(items)
|
||||||
current_user.assign_closeted_to_items!(items) if user_signed_in?
|
current_user.assign_closeted_to_items!(items) if user_signed_in?
|
||||||
end
|
end
|
||||||
|
|
|
@ -46,6 +46,8 @@
|
||||||
= link_to t('items.show.closet_hangers.button'),
|
= link_to t('items.show.closet_hangers.button'),
|
||||||
user_closet_hangers_path(current_user),
|
user_closet_hangers_path(current_user),
|
||||||
class: 'user-lists-form-opener'
|
class: 'user-lists-form-opener'
|
||||||
|
- if support_staff?
|
||||||
|
= link_to "Edit", edit_item_path(item)
|
||||||
|
|
||||||
- if user_signed_in?
|
- if user_signed_in?
|
||||||
= form_tag update_quantities_user_item_closet_hangers_path(user_id: current_user, item_id: item), method: :put, class: 'user-lists-form', hidden: item_header_user_lists_form_state != "open" do
|
= form_tag update_quantities_user_item_closet_hangers_path(user_id: current_user, item_id: item), method: :put, class: 'user-lists-form', hidden: item_header_user_lists_form_state != "open" do
|
||||||
|
|
43
app/views/items/edit.html.haml
Normal file
43
app/views/items/edit.html.haml
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
- title "Editing \"#{@item.name}\""
|
||||||
|
- use_responsive_design
|
||||||
|
|
||||||
|
%h1#title Editing "#{@item.name}"
|
||||||
|
|
||||||
|
:markdown
|
||||||
|
Heads up: the modeling process controls many of these fields by default! If
|
||||||
|
you change something, but it doesn't match what we're seeing on Neopets.com,
|
||||||
|
it will probably be reverted automatically when someone models it.
|
||||||
|
|
||||||
|
= form_with model: @item, class: "support-form" do |f|
|
||||||
|
- if @item.errors.any?
|
||||||
|
%p
|
||||||
|
Could not save:
|
||||||
|
%ul.errors
|
||||||
|
- @item.errors.each do |error|
|
||||||
|
%li= error.full_message
|
||||||
|
%fieldset
|
||||||
|
= f.label :name
|
||||||
|
= f.text_field :name
|
||||||
|
= f.label :thumbnail_url, "Thumbnail"
|
||||||
|
.thumbnail-field
|
||||||
|
- if @item.thumbnail_url?
|
||||||
|
= image_tag @item.thumbnail_url
|
||||||
|
= f.url_field :thumbnail_url
|
||||||
|
= f.label :description
|
||||||
|
= f.text_field :description
|
||||||
|
.field-name Modeling status
|
||||||
|
.radio-field
|
||||||
|
%label{title: "If we fit two or more species of a standard color, assume we also fit the other standard-color pets that were released at the time.\nRepeat for special colors like Baby and Maraquan."}
|
||||||
|
= f.radio_button :modeling_status_hint, ""
|
||||||
|
Automatic: Fits 2+ species → Should fit all
|
||||||
|
%label{title: "Use this when e.g. there simply is no Acara version of the item."}
|
||||||
|
= f.radio_button :modeling_status_hint, "done"
|
||||||
|
Done: Neopets.com is missing some models
|
||||||
|
%label{title: "Use this when e.g. this fits the Blue Vandagyre even though it's a Maraquan item.\nBehaves identically to Done, but helps us remember why we did this!"}
|
||||||
|
= f.radio_button :modeling_status_hint, "glitchy"
|
||||||
|
Glitchy: Neopets.com has <em>too many</em> models
|
||||||
|
.actions
|
||||||
|
= f.submit "Save changes"
|
||||||
|
|
||||||
|
- content_for :stylesheets do
|
||||||
|
= page_stylesheet_link_tag "application/support-form"
|
|
@ -19,7 +19,7 @@ OpenneoImpressItems::Application.routes.draw do
|
||||||
get '/users/current-user/outfits', to: redirect('/your-outfits')
|
get '/users/current-user/outfits', to: redirect('/your-outfits')
|
||||||
|
|
||||||
# Our customization data! Both the item pages, and JSON API endpoints.
|
# Our customization data! Both the item pages, and JSON API endpoints.
|
||||||
resources :items, :only => [:index, :show] do
|
resources :items, only: [:index, :show, :edit, :update] do
|
||||||
resources :trades, path: 'trades/:type', controller: 'item_trades',
|
resources :trades, path: 'trades/:type', controller: 'item_trades',
|
||||||
only: [:index], constraints: {type: /offering|seeking/}
|
only: [:index], constraints: {type: /offering|seeking/}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue