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