advanced search by pet type fit :)
This commit is contained in:
parent
e5771e6f1d
commit
44ff466a64
6 changed files with 38 additions and 24 deletions
|
@ -1160,8 +1160,8 @@ View.Search = function (wardrobe) {
|
||||||
nc: $('#advanced-search-nc').val(),
|
nc: $('#advanced-search-nc').val(),
|
||||||
occupies: $('#advanced-search-occupies').val(),
|
occupies: $('#advanced-search-occupies').val(),
|
||||||
restricts: $('#advanced-search-restricts').val(),
|
restricts: $('#advanced-search-restricts').val(),
|
||||||
species: $('#advanced-search-species').is(':checked') ?
|
fits: $('#advanced-search-autofilter').is(':checked') ?
|
||||||
wardrobe.outfits.getPetType().species_id : null,
|
wardrobe.outfits.getPetType().id : null,
|
||||||
owns: $('#advanced-search-owns').is(':checked'),
|
owns: $('#advanced-search-owns').is(':checked'),
|
||||||
wants: $('#advanced-search-wants').is(':checked')
|
wants: $('#advanced-search-wants').is(':checked')
|
||||||
};
|
};
|
||||||
|
@ -1318,7 +1318,7 @@ View.Search = function (wardrobe) {
|
||||||
var petType = wardrobe.outfits.getPetType();
|
var petType = wardrobe.outfits.getPetType();
|
||||||
var speciesName = attrs.species[petType.species_id].name.toLowerCase();
|
var speciesName = attrs.species[petType.species_id].name.toLowerCase();
|
||||||
var colorName = attrs.color[petType.color_id].unfunny_name.toLowerCase();
|
var colorName = attrs.color[petType.color_id].unfunny_name.toLowerCase();
|
||||||
return 'fits:' + speciesName + '-' + colorName;
|
return 'fits:' + colorName + '-' + speciesName;
|
||||||
}
|
}
|
||||||
|
|
||||||
function addAutofilter(query) {
|
function addAutofilter(query) {
|
||||||
|
@ -1328,15 +1328,19 @@ View.Search = function (wardrobe) {
|
||||||
return query;
|
return query;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var autofilterLabels = $('label[for=preview-search-autofilter],' +
|
||||||
|
'label[for=advanced-search-autofilter]');
|
||||||
|
var autofilterSpeciesFields = autofilterLabels.find('.species');
|
||||||
|
var autofilterColorFields = autofilterLabels.find('.color');
|
||||||
function updatePetAttributes() {
|
function updatePetAttributes() {
|
||||||
if (attrs !== null) {
|
if (attrs !== null) {
|
||||||
var petType = wardrobe.outfits.getPetType();
|
var petType = wardrobe.outfits.getPetType();
|
||||||
|
|
||||||
var speciesName = attrs.species[petType.species_id].name;
|
var speciesName = attrs.species[petType.species_id].name;
|
||||||
$('label[for=advanced-search-species] span').text(speciesName);
|
autofilterSpeciesFields.text(speciesName);
|
||||||
$('label[for=preview-search-autofilter] .species').text(speciesName);
|
|
||||||
|
|
||||||
var colorName = attrs.color[petType.color_id].name;
|
var colorName = attrs.color[petType.color_id].name;
|
||||||
$('label[for=preview-search-autofilter] .color').text(colorName);
|
autofilterColorFields.text(colorName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1330,8 +1330,8 @@ function Wardrobe() {
|
||||||
if (query.restricts)
|
if (query.restricts)
|
||||||
filters.push({key: "restricted_zone_set_name", value: query.restricts,
|
filters.push({key: "restricted_zone_set_name", value: query.restricts,
|
||||||
is_positive: true});
|
is_positive: true});
|
||||||
if (query.species)
|
if (query.fits)
|
||||||
filters.push({key: "species_support_id", value: query.species,
|
filters.push({key: "fits_pet_type", value: query.fits,
|
||||||
is_positive: true});
|
is_positive: true});
|
||||||
if (query.owns)
|
if (query.owns)
|
||||||
filters.push({key: "user_closet_hanger_ownership", value: true,
|
filters.push({key: "user_closet_hanger_ownership", value: true,
|
||||||
|
|
|
@ -69,10 +69,10 @@ _user_closet_hanger_ownerships:
|
||||||
_negative_user_closet_hanger_ownerships:
|
_negative_user_closet_hanger_ownerships:
|
||||||
*user_closet_hangers_ownership_partial
|
*user_closet_hangers_ownership_partial
|
||||||
|
|
||||||
_body_ids:
|
_fits_pet_types:
|
||||||
*body_id_partial
|
*body_id_partial
|
||||||
|
|
||||||
_negative_body_ids:
|
_negative_fits_pet_types:
|
||||||
*body_id_partial
|
*body_id_partial
|
||||||
|
|
||||||
item_search:
|
item_search:
|
||||||
|
@ -88,13 +88,13 @@ item_search:
|
||||||
- <<_occupied_zone_ids= ~>>
|
- <<_occupied_zone_ids= ~>>
|
||||||
- <<_restricted_zone_ids= ~>>
|
- <<_restricted_zone_ids= ~>>
|
||||||
- <<_user_closet_hanger_ownerships= ~>>
|
- <<_user_closet_hanger_ownerships= ~>>
|
||||||
- <<_body_ids= ~>>
|
- <<_fits_pet_types= ~>>
|
||||||
must_not:
|
must_not:
|
||||||
- <<_negative_names= ~>>
|
- <<_negative_names= ~>>
|
||||||
- <<_negative_species_support_ids= ~>>
|
- <<_negative_species_support_ids= ~>>
|
||||||
- <<_negative_occupied_zone_ids= ~>>
|
- <<_negative_occupied_zone_ids= ~>>
|
||||||
- <<_negative_restricted_zone_ids= ~>>
|
- <<_negative_restricted_zone_ids= ~>>
|
||||||
- <<_negative_user_closet_hanger_ownerships= ~>>
|
- <<_negative_user_closet_hanger_ownerships= ~>>
|
||||||
- <<_negative_body_ids= ~>>
|
- <<_negative_fits_pet_types= ~>>
|
||||||
sort:
|
sort:
|
||||||
- name.<<locale>>.untouched
|
- name.<<locale>>.untouched
|
||||||
|
|
|
@ -12,7 +12,7 @@ class Item
|
||||||
:restricted_zone_id => Fields::SetField,
|
:restricted_zone_id => Fields::SetField,
|
||||||
:name => Fields::SetField,
|
:name => Fields::SetField,
|
||||||
:user_closet_hanger_ownership => Fields::SetField,
|
:user_closet_hanger_ownership => Fields::SetField,
|
||||||
:body_id => Fields::SetField
|
:fits_pet_type => Fields::SetField
|
||||||
}
|
}
|
||||||
FIELD_KEYS = FIELD_CLASSES.keys
|
FIELD_KEYS = FIELD_CLASSES.keys
|
||||||
|
|
||||||
|
@ -95,11 +95,11 @@ class Item
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
[:_body_ids, :_negative_body_ids].each do |key|
|
[:_fits_pet_types, :_negative_fits_pet_types].each do |key|
|
||||||
if final_flex_params[key]
|
if final_flex_params[key]
|
||||||
final_flex_params[key].each do |entry|
|
final_flex_params[key].each do |entry|
|
||||||
# These are pet types at first. Yikes, dem hax.
|
# These are pet types at first. Yikes, dem hax.
|
||||||
entry[:body_id] = entry[:body_id].body_id
|
entry[:body_id] = entry[:fits_pet_type].body_id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -206,7 +206,7 @@ class Item
|
||||||
:occupied_zone_id => :zone,
|
:occupied_zone_id => :zone,
|
||||||
:restricted_zone_id => :zone,
|
:restricted_zone_id => :zone,
|
||||||
:user_closet_hanger_ownership => :ownership,
|
:user_closet_hanger_ownership => :ownership,
|
||||||
:body_id => :pet_type
|
:fits_pet_type => :pet_type
|
||||||
}
|
}
|
||||||
|
|
||||||
TEXT_FILTER_EXPR = /([+-]?)(?:(\p{Word}+):)?(?:"([^"]+)"|(\S+))/
|
TEXT_FILTER_EXPR = /([+-]?)(?:(\p{Word}+):)?(?:"([^"]+)"|(\S+))/
|
||||||
|
@ -286,6 +286,13 @@ class Item
|
||||||
if key == :user_closet_hanger_ownership
|
if key == :user_closet_hanger_ownership
|
||||||
value = (value == 'true')
|
value = (value == 'true')
|
||||||
end
|
end
|
||||||
|
if key == :fits_pet_type
|
||||||
|
begin
|
||||||
|
value = PetType.find(value)
|
||||||
|
rescue ActiveRecord::RecordNotFound
|
||||||
|
Item::Search.error 'not_found.pet_type_id', id: value
|
||||||
|
end
|
||||||
|
end
|
||||||
is_positive = filter_params[:is_positive] == 'true'
|
is_positive = filter_params[:is_positive] == 'true'
|
||||||
Filter.new(key, value, is_positive)
|
Filter.new(key, value, is_positive)
|
||||||
end
|
end
|
||||||
|
|
|
@ -146,10 +146,12 @@
|
||||||
%div
|
%div
|
||||||
%ul
|
%ul
|
||||||
%li.checkbox
|
%li.checkbox
|
||||||
%input{type: 'checkbox', id: 'advanced-search-species'}
|
%input{type: 'checkbox', id: 'advanced-search-autofilter',
|
||||||
%label{for: 'advanced-search-species'}
|
checked: true}
|
||||||
= t '.search.advanced.species_html',
|
%label{for: 'advanced-search-autofilter'}
|
||||||
species: content_tag('span', '')
|
= t '.search.autofilter_html',
|
||||||
|
species: content_tag('span', '', {:class => 'species'}),
|
||||||
|
color: content_tag('span', '', {:class => 'color'})
|
||||||
%li.checkbox.must-log-in
|
%li.checkbox.must-log-in
|
||||||
%input{type: 'checkbox', id: 'advanced-search-owns', disabled: true}
|
%input{type: 'checkbox', id: 'advanced-search-owns', disabled: true}
|
||||||
%label{for: 'advanced-search-owns'}= t '.search.advanced.owns'
|
%label{for: 'advanced-search-owns'}= t '.search.advanced.owns'
|
||||||
|
|
|
@ -365,6 +365,7 @@ en:
|
||||||
user:wants?
|
user:wants?
|
||||||
pet_type: We have no record of the %{name1} %{name2}.
|
pet_type: We have no record of the %{name1} %{name2}.
|
||||||
It is spelled correctly?
|
It is spelled correctly?
|
||||||
|
pet_type_id: We have no record of pet type %{id}. Weird.
|
||||||
not_logged_in:
|
not_logged_in:
|
||||||
The "user" filters are only available if you're logged in.
|
The "user" filters are only available if you're logged in.
|
||||||
flag_keywords:
|
flag_keywords:
|
||||||
|
@ -379,7 +380,7 @@ en:
|
||||||
user_closet_hanger_ownership: user
|
user_closet_hanger_ownership: user
|
||||||
user_owns: owns
|
user_owns: owns
|
||||||
user_wants: wants
|
user_wants: wants
|
||||||
body_id: fits
|
fits_pet_type: fits
|
||||||
|
|
||||||
neopets_pages:
|
neopets_pages:
|
||||||
create:
|
create:
|
||||||
|
|
Loading…
Reference in a new issue