handle search errors better in wardrobe

This commit is contained in:
Emi Matchu 2011-08-01 00:00:39 -04:00
parent 2f0b0743e8
commit be5bdb1eec
4 changed files with 53 additions and 25 deletions

View file

@ -20,6 +20,7 @@ class ItemsController < ApplicationController
rescue Item::SearchError rescue Item::SearchError
respond_to do |format| respond_to do |format|
format.html { flash.now[:alert] = $!.message } format.html { flash.now[:alert] = $!.message }
format.json { render :json => {:error => $!.message} }
format.js { render :json => {:error => $!.message}, :callback => params[:callback] } format.js { render :json => {:error => $!.message}, :callback => params[:callback] }
end end
end end

View file

@ -546,6 +546,10 @@ body.outfits-edit
.outfit-url .outfit-url
font-size: 75% font-size: 75%
#preview-search-form-error
+error
padding: .25em .5em
&.user-signed-in &.user-signed-in
#preview-sidebar-nav-outfits #preview-sidebar-nav-outfits
display: block display: block

View file

@ -210,18 +210,34 @@ function Wardrobe() {
Item.loadByQuery = function (query, offset, success, error) { Item.loadByQuery = function (query, offset, success, error) {
var page = Math.round(offset / Item.PER_PAGE) + 1; var page = Math.round(offset / Item.PER_PAGE) + 1;
$.getJSON('/items.json', {q: query, per_page: Item.PER_PAGE, page: page}, function (data) { $.ajax({
var items = [], item, item_data; url: '/items.json',
if(data.items) { data: {q: query, per_page: Item.PER_PAGE, page: page},
for(var i = 0; i < data.items.length; i++) { dataType: 'json',
item_data = data.items[i]; success: function (data) {
item = Item.find(item_data.id); var items = [], item, item_data;
item.update(item_data); if(data.items) {
items.push(item); for(var i = 0; i < data.items.length; i++) {
item_data = data.items[i];
item = Item.find(item_data.id);
item.update(item_data);
items.push(item);
}
success(items, data.total_pages, page);
} else if(data.error) {
error(data.error);
} }
success(items, data.total_pages, page); },
} else if(data.error) { error: function (xhr) {
error(data.error); console.log($.parseJSON(xhr.responseText));
try {
var json = $.parseJSON(xhr.responseText);
} catch(e) {
$.jGrowl("There was an error running that search, probably on our end. Try again?");
return false;
}
if(json.error) error(json.error);
} }
}); });
} }

View file

@ -650,7 +650,7 @@ body.closet_hangers-index #closet-hangers-contact {
/* line 33, ../../../app/stylesheets/closet_hangers/_index.sass */ /* line 33, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers-contact a, body.closet_hangers-index #closet-hangers-contact > span { body.closet_hangers-index #closet-hangers-contact a, body.closet_hangers-index #closet-hangers-contact > span {
text-decoration: none; text-decoration: none;
background-image: url('/images/neomail.png?1311877030'); background-image: url('/images/neomail.png?1312167956');
background-position: left center; background-position: left center;
background-repeat: no-repeat; background-repeat: no-repeat;
color: inherit; color: inherit;
@ -664,7 +664,7 @@ body.closet_hangers-index #closet-hangers-contact a:hover, body.closet_hangers-i
} }
/* line 44, ../../../app/stylesheets/closet_hangers/_index.sass */ /* line 44, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers-contact > span { body.closet_hangers-index #closet-hangers-contact > span {
background-image: url('/images/neomail_edit.png?1312153508'); background-image: url('/images/neomail_edit.png?1312167956');
} }
/* line 47, ../../../app/stylesheets/closet_hangers/_index.sass */ /* line 47, ../../../app/stylesheets/closet_hangers/_index.sass */
body.closet_hangers-index #closet-hangers-contact input[type=text], body.closet_hangers-index #closet-hangers-contact body.pets-bulk #bulk-pets-form textarea, body.pets-bulk #bulk-pets-form body.closet_hangers-index #closet-hangers-contact textarea { body.closet_hangers-index #closet-hangers-contact input[type=text], body.closet_hangers-index #closet-hangers-contact body.pets-bulk #bulk-pets-form textarea, body.pets-bulk #bulk-pets-form body.closet_hangers-index #closet-hangers-contact textarea {
@ -2413,7 +2413,7 @@ body.outfits-edit .object:hover ul, body.outfits-edit .object:hover .object-info
} }
/* line 419, ../../../app/stylesheets/outfits/_edit.sass */ /* line 419, ../../../app/stylesheets/outfits/_edit.sass */
body.outfits-edit .nc-icon { body.outfits-edit .nc-icon {
background: url('/images/nc.png?1311877029') no-repeat; background: url('/images/nc.png?1312167956') no-repeat;
height: 16px; height: 16px;
position: absolute; position: absolute;
right: 16px; right: 16px;
@ -3127,35 +3127,42 @@ body.outfits-edit form#save-outfit-form .outfit-star {
body.outfits-edit .outfit-url { body.outfits-edit .outfit-url {
font-size: 75%; font-size: 75%;
} }
/* line 550, ../../../app/stylesheets/outfits/_edit.sass */ /* line 549, ../../../app/stylesheets/outfits/_edit.sass */
body.outfits-edit #preview-search-form-error {
background: #fbe3e4;
border: 1px solid #fbc2c4;
color: #8a1f11;
padding: 0.25em 0.5em;
}
/* line 554, ../../../app/stylesheets/outfits/_edit.sass */
body.outfits-edit.user-signed-in #preview-sidebar-nav-outfits { body.outfits-edit.user-signed-in #preview-sidebar-nav-outfits {
display: block; display: block;
} }
/* line 552, ../../../app/stylesheets/outfits/_edit.sass */ /* line 556, ../../../app/stylesheets/outfits/_edit.sass */
body.outfits-edit.user-signed-in #save-outfit { body.outfits-edit.user-signed-in #save-outfit {
display: inline-block; display: inline-block;
} }
/* line 556, ../../../app/stylesheets/outfits/_edit.sass */ /* line 560, ../../../app/stylesheets/outfits/_edit.sass */
body.outfits-edit.user-signed-in #save-outfit-wrapper.active-outfit #save-outfit { body.outfits-edit.user-signed-in #save-outfit-wrapper.active-outfit #save-outfit {
display: none; display: none;
} }
/* line 558, ../../../app/stylesheets/outfits/_edit.sass */ /* line 562, ../../../app/stylesheets/outfits/_edit.sass */
body.outfits-edit.user-signed-in #save-outfit-wrapper.active-outfit #save-current-outfit, body.outfits-edit.user-signed-in #save-outfit-wrapper.active-outfit #save-outfit-copy { body.outfits-edit.user-signed-in #save-outfit-wrapper.active-outfit #save-current-outfit, body.outfits-edit.user-signed-in #save-outfit-wrapper.active-outfit #save-outfit-copy {
display: inline-block; display: inline-block;
} }
/* line 560, ../../../app/stylesheets/outfits/_edit.sass */ /* line 564, ../../../app/stylesheets/outfits/_edit.sass */
body.outfits-edit.user-signed-in #save-outfit-wrapper.active-outfit #current-outfit-permalink { body.outfits-edit.user-signed-in #save-outfit-wrapper.active-outfit #current-outfit-permalink {
display: inline-block; display: inline-block;
} }
/* line 563, ../../../app/stylesheets/outfits/_edit.sass */ /* line 567, ../../../app/stylesheets/outfits/_edit.sass */
body.outfits-edit.user-signed-in #save-outfit-wrapper.saving-outfit #save-outfit-form { body.outfits-edit.user-signed-in #save-outfit-wrapper.saving-outfit #save-outfit-form {
display: block; display: block;
} }
/* line 565, ../../../app/stylesheets/outfits/_edit.sass */ /* line 569, ../../../app/stylesheets/outfits/_edit.sass */
body.outfits-edit.user-signed-in #save-outfit-wrapper.saving-outfit #save-outfit, body.outfits-edit.user-signed-in #save-outfit-wrapper.saving-outfit #save-current-outfit, body.outfits-edit.user-signed-in #save-outfit-wrapper.saving-outfit #save-outfit-copy, body.outfits-edit.user-signed-in #save-outfit-wrapper.saving-outfit #current-outfit-permalink, body.outfits-edit.user-signed-in #save-outfit-wrapper.saving-outfit #shared-outfit-permalink, body.outfits-edit.user-signed-in #save-outfit-wrapper.saving-outfit #share-outfit, body.outfits-edit.user-signed-in #save-outfit-wrapper.saving-outfit #shared-outfit-url { body.outfits-edit.user-signed-in #save-outfit-wrapper.saving-outfit #save-outfit, body.outfits-edit.user-signed-in #save-outfit-wrapper.saving-outfit #save-current-outfit, body.outfits-edit.user-signed-in #save-outfit-wrapper.saving-outfit #save-outfit-copy, body.outfits-edit.user-signed-in #save-outfit-wrapper.saving-outfit #current-outfit-permalink, body.outfits-edit.user-signed-in #save-outfit-wrapper.saving-outfit #shared-outfit-permalink, body.outfits-edit.user-signed-in #save-outfit-wrapper.saving-outfit #share-outfit, body.outfits-edit.user-signed-in #save-outfit-wrapper.saving-outfit #shared-outfit-url {
display: none; display: none;
} }
/* line 567, ../../../app/stylesheets/outfits/_edit.sass */ /* line 571, ../../../app/stylesheets/outfits/_edit.sass */
body.outfits-edit.user-signed-in .preview-search-form-your-items { body.outfits-edit.user-signed-in .preview-search-form-your-items {
display: -moz-inline-box; display: -moz-inline-box;
-moz-box-orient: vertical; -moz-box-orient: vertical;
@ -3164,15 +3171,15 @@ body.outfits-edit.user-signed-in .preview-search-form-your-items {
*display: inline; *display: inline;
*vertical-align: auto; *vertical-align: auto;
} }
/* line 571, ../../../app/stylesheets/outfits/_edit.sass */ /* line 575, ../../../app/stylesheets/outfits/_edit.sass */
body.outfits-edit.user-not-signed-in #save-outfit-not-signed-in { body.outfits-edit.user-not-signed-in #save-outfit-not-signed-in {
display: inline-block; display: inline-block;
} }
/* line 575, ../../../app/stylesheets/outfits/_edit.sass */ /* line 579, ../../../app/stylesheets/outfits/_edit.sass */
body.outfits-edit #save-outfit-wrapper.shared-outfit #shared-outfit-permalink, body.outfits-edit #save-outfit-wrapper.shared-outfit #shared-outfit-url { body.outfits-edit #save-outfit-wrapper.shared-outfit #shared-outfit-permalink, body.outfits-edit #save-outfit-wrapper.shared-outfit #shared-outfit-url {
display: inline-block; display: inline-block;
} }
/* line 577, ../../../app/stylesheets/outfits/_edit.sass */ /* line 581, ../../../app/stylesheets/outfits/_edit.sass */
body.outfits-edit #save-outfit-wrapper.shared-outfit #current-outfit-permalink { body.outfits-edit #save-outfit-wrapper.shared-outfit #current-outfit-permalink {
display: none !important; display: none !important;
} }