mardi 13 septembre 2016

How do I only return isActive records with search

In an ember app and I'm trying to return records that match the search term and isActive equals true. The search part works, I just can't get the isActive true to work with the rest of it.

filterDecks(search) {
  if (search.length < 2) {
    return;
  }
  // keep it local™
  search = search.toLowerCase();

  let decks = this.store.peekAll('deck').filter(function(item) {
    let title = (item.get('title') || '').toLowerCase();
    let description = (item.get('description') || '').toLowerCase();
    let tags = (item.get('tags') || []).toString().toLowerCase();
    let isActive  = (item.get('isActive'));

    return title.includes(search) ||
        description.includes(search) ||
        tags.includes(search);
  }, this);

  this.set('filteredDecks', decks);
},




Aucun commentaire:

Enregistrer un commentaire