finally let people remove all items from the list at once.

I've been doing this manually via email for a long time,
since building new stuff in the logged-in world was a pain in the old env.

But now here we are! Finally, finally :)
This commit is contained in:
Matchu 2015-07-19 12:35:49 -04:00
parent 625f1ee8b4
commit dcf254a78d
6 changed files with 58 additions and 9 deletions

View file

@ -4,10 +4,23 @@ class ClosetHangersController < ApplicationController
before_filter :find_user, :only => [:index, :petpage, :update_quantities]
def destroy
@closet_hanger = current_user.closet_hangers.find params[:id]
@closet_hanger.destroy
@item = @closet_hanger.item
closet_hanger_destroyed
if params[:list_id]
@closet_list = current_user.find_closet_list_by_id_or_null_owned params[:list_id]
@closet_list.hangers.destroy_all
respond_to do |format|
format.html {
flash[:success] = t("closet_hangers.destroy_all.success")
redirect_back!(user_closet_hangers_path(current_user))
}
format.json { render :json => true }
end
else
@closet_hanger = current_user.closet_hangers.find params[:id]
@closet_hanger.destroy
@item = @closet_hanger.item
closet_hanger_destroyed
end
end
def index

View file

@ -89,7 +89,26 @@ class User < ActiveRecord::Base
end
def null_closet_list(owned)
owned ? ClosetList::NullOwned.new(self) : ClosetList::NullWanted.new(self)
owned ? null_owned_list : null_wanted_list
end
def null_owned_list
ClosetList::NullOwned.new(self)
end
def null_wanted_list
ClosetList::NullWanted.new(self)
end
def find_closet_list_by_id_or_null_owned(id_or_owned)
id_or_owned_str = id_or_owned.to_s
if id_or_owned_str == 'true'
null_owned_list
elsif id_or_owned_str == 'false'
null_wanted_list
else
self.closet_lists.find id_or_owned
end
end
def neopets_usernames

View file

@ -73,6 +73,10 @@
closet_visibility_choices(:human_name)
= f.submit t('.unlisted.submit')
= closet_visibility_descriptions
.closet-list-controls
= form_tag user_closet_hangers_path(@user), method: :delete do
= hidden_field_tag :list_id, owned
= submit_tag t('.remove_all.submit'), confirm: t('.remove_all.confirm')
- if has_lists?(owned)
%h4= t '.unlisted.header'
- if !@public_perspective

View file

@ -9,6 +9,9 @@
= link_to t('.edit'), edit_user_closet_list_path(closet_list.user_id, closet_list)
= form_tag user_closet_list_path(closet_list.user_id, closet_list), :method => 'delete' do
= submit_tag t('.delete'), :confirm => closet_list_delete_confirmation(closet_list)
= form_tag user_closet_hangers_path(@user), method: :delete do
= hidden_field_tag :list_id, closet_list.id
= submit_tag t('.remove_all.submit'), confirm: t('.remove_all.confirm')
%h4= closet_list.name
- if show_controls

View file

@ -96,6 +96,9 @@ en:
owned: Success! You do not own the %{item_name}.
wanted: Success! You do not want the %{item_name}.
destroy_all:
success: Success! Removed all items from the list.
index:
title_for:
you: Your Items
@ -124,6 +127,9 @@ en:
submit: Save
header: (Not in a list)
empty: There aren't any items here.
remove_all:
confirm: 'Remove all items from this list?'
submit: Remove all
autocomplete:
add_item_html: Add <strong>%{item_name}</strong>
add_to_list_html: Add to <strong>%{list_name}</strong>
@ -179,11 +185,14 @@ en:
delete: Delete
delete_confirmation:
owned:
Are you sure you want to delete "%{list_name}"? Even if you do, we'll
remember that you own these items.
Are you sure you want to delete "%{list_name}"?
If you do, we'll move these items into Items You Own, not in a list.
wanted:
Are you sure you want to delete "%{list_name}"? Even if you do, we'll
remember that you want these items.
Are you sure you want to delete "%{list_name}"?
If you do, we'll move these items into Items You Want, not in a list.
remove_all:
confirm: 'Remove all items from this list?'
submit: Remove all
empty: This list is empty.
trading_neomail_warning_html:
You've marked this list as Trading, so folks will discover it via Dress

View file

@ -66,6 +66,7 @@ OpenneoImpressItems::Application.routes.draw do
resources :closet_hangers, :only => [:index, :update, :destroy], :path => 'closet' do
collection do
get :petpage
delete :destroy
end
end
resources :closet_lists, :only => [:new, :create, :edit, :update, :destroy], :path => 'closet/lists'