From ecacb441537934b8c520f315156dee726ecc9382 Mon Sep 17 00:00:00 2001 From: Matchu Date: Wed, 2 Apr 2014 21:14:49 -0500 Subject: [PATCH] update current species name --- app/assets/javascripts/outfits/edit.js | 20 ++++++++++++++++++++ app/views/outfits/edit.html.haml | 3 +-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/outfits/edit.js b/app/assets/javascripts/outfits/edit.js index 59243814..dd43e1f6 100644 --- a/app/assets/javascripts/outfits/edit.js +++ b/app/assets/javascripts/outfits/edit.js @@ -1286,6 +1286,26 @@ View.Search = function (wardrobe) { if ($('meta[name=user-signed-in]').attr('content') === 'true') { wrapper.find('li.must-log-in input').removeAttr('disabled'); } + + var speciesNamesById = null; + + function updateCurrentSpeciesName() { + if (speciesNamesById !== null) { + var speciesId = wardrobe.outfits.getPetType().species_id; + var speciesName = speciesNamesById[speciesId]; + $('label[for=advanced-search-species] span').text(speciesName); + } + } + + wardrobe.pet_attributes.bind('update', function(petAttributes) { + speciesNamesById = {}; + petAttributes.species.forEach(function(species) { + speciesNamesById[species.id] = species.name; + }); + updateCurrentSpeciesName(); + }); + + wardrobe.outfits.bind('updatePetType', updateCurrentSpeciesName); } View.PrankColorMessage = function(wardrobe) { diff --git a/app/views/outfits/edit.html.haml b/app/views/outfits/edit.html.haml index 693c9616..7aa19732 100644 --- a/app/views/outfits/edit.html.haml +++ b/app/views/outfits/edit.html.haml @@ -145,8 +145,7 @@ %input{type: 'checkbox', id: 'advanced-search-species'} %label{for: 'advanced-search-species'} Fits the - -# TODO: update to current species - %span Acara + %span (the current species) %li.checkbox.must-log-in %input{type: 'checkbox', id: 'advanced-search-owns', disabled: true}