I'm using ember-drag-drop to implement a sortable list. This worked fine until I needed to implement a text filter on the list.
The filteredItems is a computed property which filters the original list based on a user's text input.
filteredRules: computed('items', 'term', function() {
let term = this.get('term');
let items = this.get('items');
if (term.length > 0) {
return items.filter(item => item.conditions.some(cond => cond.field.toLowerCase().indexOf(term) > -1 || (cond.term && cond.term.toLowerCase().indexOf(term) > -1)));
} else {
return items;
}
}),
The problem is that a computed can't (normally) be written back to.
How can I still allow sorting of the original items data set while still allowing filtering?
Aucun commentaire:
Enregistrer un commentaire