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]
|
||||
font-size: .85em
|
||||
|
||||
label
|
||||
> label, .field-name
|
||||
font-weight: bold
|
||||
&:has(+ .radio-field)
|
||||
align-self: start
|
||||
|
||||
.thumbnail-field
|
||||
display: flex
|
||||
|
@ -34,6 +36,11 @@
|
|||
input
|
||||
flex: 1 0 20ch
|
||||
|
||||
.radio-field
|
||||
display: flex
|
||||
flex-direction: column
|
||||
gap: .25em
|
||||
|
||||
.field_with_errors
|
||||
display: contents
|
||||
|
||||
|
|
|
@ -67,13 +67,20 @@
|
|||
background: #FEEBC8
|
||||
color: #7B341E
|
||||
|
||||
.support-form
|
||||
grid-area: support
|
||||
font-size: 85%
|
||||
text-align: left
|
||||
|
||||
.user-lists-info
|
||||
grid-area: lists
|
||||
font-size: 85%
|
||||
text-align: left
|
||||
|
||||
.user-lists-form-opener
|
||||
&::after
|
||||
display: flex
|
||||
gap: 1em
|
||||
|
||||
a::after
|
||||
content: " ›"
|
||||
|
||||
.user-lists-form
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
class ItemsController < ApplicationController
|
||||
before_action :set_query
|
||||
before_action :support_staff_only, except: [:index, :show, :sources]
|
||||
rescue_from Item::Search::Error, :with => :search_error
|
||||
|
||||
def index
|
||||
|
@ -112,6 +113,21 @@ class ItemsController < ApplicationController
|
|||
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
|
||||
# Load all the items, then group them by source.
|
||||
item_ids = params[:ids].split(",")
|
||||
|
@ -164,6 +180,14 @@ class ItemsController < ApplicationController
|
|||
|
||||
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)
|
||||
current_user.assign_closeted_to_items!(items) if user_signed_in?
|
||||
end
|
||||
|
|
|
@ -46,6 +46,8 @@
|
|||
= link_to t('items.show.closet_hangers.button'),
|
||||
user_closet_hangers_path(current_user),
|
||||
class: 'user-lists-form-opener'
|
||||
- if support_staff?
|
||||
= link_to "Edit", edit_item_path(item)
|
||||
|
||||
- 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
|
||||
|
|
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')
|
||||
|
||||
# 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',
|
||||
only: [:index], constraints: {type: /offering|seeking/}
|
||||
|
||||
|
|
Loading…
Reference in a new issue