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:
parent
625f1ee8b4
commit
dcf254a78d
6 changed files with 58 additions and 9 deletions
|
@ -4,11 +4,24 @@ class ClosetHangersController < ApplicationController
|
||||||
before_filter :find_user, :only => [:index, :petpage, :update_quantities]
|
before_filter :find_user, :only => [:index, :petpage, :update_quantities]
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
|
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 = current_user.closet_hangers.find params[:id]
|
||||||
@closet_hanger.destroy
|
@closet_hanger.destroy
|
||||||
@item = @closet_hanger.item
|
@item = @closet_hanger.item
|
||||||
closet_hanger_destroyed
|
closet_hanger_destroyed
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@public_perspective = params.has_key?(:public) || !user_is?(@user)
|
@public_perspective = params.has_key?(:public) || !user_is?(@user)
|
||||||
|
|
|
@ -89,7 +89,26 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
def null_closet_list(owned)
|
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
|
end
|
||||||
|
|
||||||
def neopets_usernames
|
def neopets_usernames
|
||||||
|
|
|
@ -73,6 +73,10 @@
|
||||||
closet_visibility_choices(:human_name)
|
closet_visibility_choices(:human_name)
|
||||||
= f.submit t('.unlisted.submit')
|
= f.submit t('.unlisted.submit')
|
||||||
= closet_visibility_descriptions
|
= 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)
|
- if has_lists?(owned)
|
||||||
%h4= t '.unlisted.header'
|
%h4= t '.unlisted.header'
|
||||||
- if !@public_perspective
|
- if !@public_perspective
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
= link_to t('.edit'), edit_user_closet_list_path(closet_list.user_id, closet_list)
|
= 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
|
= 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)
|
= 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
|
%h4= closet_list.name
|
||||||
|
|
||||||
- if show_controls
|
- if show_controls
|
||||||
|
|
|
@ -96,6 +96,9 @@ en:
|
||||||
owned: Success! You do not own the %{item_name}.
|
owned: Success! You do not own the %{item_name}.
|
||||||
wanted: Success! You do not want the %{item_name}.
|
wanted: Success! You do not want the %{item_name}.
|
||||||
|
|
||||||
|
destroy_all:
|
||||||
|
success: Success! Removed all items from the list.
|
||||||
|
|
||||||
index:
|
index:
|
||||||
title_for:
|
title_for:
|
||||||
you: Your Items
|
you: Your Items
|
||||||
|
@ -124,6 +127,9 @@ en:
|
||||||
submit: Save
|
submit: Save
|
||||||
header: (Not in a list)
|
header: (Not in a list)
|
||||||
empty: There aren't any items here.
|
empty: There aren't any items here.
|
||||||
|
remove_all:
|
||||||
|
confirm: 'Remove all items from this list?'
|
||||||
|
submit: Remove all
|
||||||
autocomplete:
|
autocomplete:
|
||||||
add_item_html: Add <strong>%{item_name}</strong>
|
add_item_html: Add <strong>%{item_name}</strong>
|
||||||
add_to_list_html: Add to <strong>%{list_name}</strong>
|
add_to_list_html: Add to <strong>%{list_name}</strong>
|
||||||
|
@ -179,11 +185,14 @@ en:
|
||||||
delete: Delete
|
delete: Delete
|
||||||
delete_confirmation:
|
delete_confirmation:
|
||||||
owned:
|
owned:
|
||||||
Are you sure you want to delete "%{list_name}"? Even if you do, we'll
|
Are you sure you want to delete "%{list_name}"?
|
||||||
remember that you own these items.
|
If you do, we'll move these items into Items You Own, not in a list.
|
||||||
wanted:
|
wanted:
|
||||||
Are you sure you want to delete "%{list_name}"? Even if you do, we'll
|
Are you sure you want to delete "%{list_name}"?
|
||||||
remember that you want these items.
|
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.
|
empty: This list is empty.
|
||||||
trading_neomail_warning_html:
|
trading_neomail_warning_html:
|
||||||
You've marked this list as Trading, so folks will discover it via Dress
|
You've marked this list as Trading, so folks will discover it via Dress
|
||||||
|
|
|
@ -66,6 +66,7 @@ OpenneoImpressItems::Application.routes.draw do
|
||||||
resources :closet_hangers, :only => [:index, :update, :destroy], :path => 'closet' do
|
resources :closet_hangers, :only => [:index, :update, :destroy], :path => 'closet' do
|
||||||
collection do
|
collection do
|
||||||
get :petpage
|
get :petpage
|
||||||
|
delete :destroy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
resources :closet_lists, :only => [:new, :create, :edit, :update, :destroy], :path => 'closet/lists'
|
resources :closet_lists, :only => [:new, :create, :edit, :update, :destroy], :path => 'closet/lists'
|
||||||
|
|
Loading…
Reference in a new issue