From d7af6cfd4a0818d77324b21ce79b62cc176e6a3e Mon Sep 17 00:00:00 2001 From: Matchu Date: Wed, 2 Apr 2014 20:26:53 -0500 Subject: [PATCH] populate occupies/restricts selects --- app/assets/javascripts/outfits/edit.js | 19 +++++++++++++++---- app/assets/javascripts/wardrobe.js | 10 ++++------ app/controllers/item_zone_sets_controller.rb | 2 +- app/models/item/search/query.rb | 12 +++++++++++- app/models/zone.rb | 8 ++++++-- 5 files changed, 37 insertions(+), 14 deletions(-) diff --git a/app/assets/javascripts/outfits/edit.js b/app/assets/javascripts/outfits/edit.js index 83c9c847..1e98883c 100644 --- a/app/assets/javascripts/outfits/edit.js +++ b/app/assets/javascripts/outfits/edit.js @@ -201,10 +201,6 @@ View.Fullscreen = function (wardrobe) { $('#preview').data('fit', fit); win.resize(fit).load(fit); - // run fit after search updates select fields - function fitSoon() { setTimeout(fit, 0) } - wardrobe.item_zone_sets.bind('update', fitSoon); - wardrobe.pet_attributes.bind('update', fitSoon); fit(); } @@ -1250,6 +1246,21 @@ View.Search = function (wardrobe) { wrapper.toggleClass('advanced'); fit(); }); + + wardrobe.item_zone_sets.bind('update', function (item_zone_sets) { + var selects = $('#advanced-search-occupies, #advanced-search-restricts'); + console.log("yo", selects, item_zone_sets); + var sorted_item_zone_sets = item_zone_sets.slice(0); + item_zone_sets.sort(function(a, b) { + if (a.label < b.label) return -1; + else if (a.label > b.label) return 1; + else return 0; + }); + item_zone_sets.forEach(function(set) { + $('