Commit 77e933d93d342c7481e197fae9461cb8d0c8ecb1
Fix filterTags function
- The previous implementation of filterTags was not working. Fix that.
| | | | 256 | }, this); | 256 | }, this); |
---|
257 | | 257 | |
---|
258 | // pluck uniq tags of sweets | 258 | // pluck uniq tags of sweets |
---|
259 | var tags = _.chain(this.collection.pluck('how')).pluck('tags').uniq(). | | var tags = _.chain(this.collection.pluck('how')).pluck('tags').uniq(). |
---|
260 | value(); | | value(); |
---|
| | 259 | var tags = _.chain(this.collection.pluck('how')).pluck('tags').flatten(). | | | 260 | uniq().value(); |
---|
261 | // render them as filter controls | 261 | // render them as filter controls |
---|
262 | _.each(tags, function(tag) { | 262 | _.each(tags, function(tag) { |
---|
263 | if(tag) { | 263 | if(tag) { |
---|
… | | … | |
---|
308 | return; | 308 | return; |
---|
309 | } | 309 | } |
---|
310 | var filtered_swts = this.collection.filter(function(model) { | 310 | var filtered_swts = this.collection.filter(function(model) { |
---|
| | 311 | //TODO: find a better way of doing this.. |
---|
| | 312 | var flag = false; |
---|
311 | _.each(model.get('how').tags, function(tag) { | 313 | _.each(model.get('how').tags, function(tag) { |
---|
312 | if(_.indexOf(tags, tag) > -1) { | 314 | if(_.indexOf(tags, tag) > -1) { |
---|
313 | return model; | | return model; |
---|
| | 315 | flag = true; | 314 | } | 316 | } |
---|
315 | }); | 317 | }); |
---|
| | 318 | if(flag === true) { |
---|
| | 319 | return model; |
---|
| | 320 | } |
---|
316 | }); | 321 | }); |
---|
317 | if(filtered_swts.length) { | 322 | if(filtered_swts.length) { |
---|
318 | anno.removeAll(); | 323 | anno.removeAll(); |
---|