Good night.
I have a custom table component with sorting.
Each header uses itemController
to perform sorting on click action. E.g.:
click
→ asc
→ click
- desc
- click
- reset
It also uses templates to display sorting direction.
Code:
module.exports = App.SortableColumnsMixin = Em.Mixin.create({
//skip
sortingProperties: [],
sortedContent: Em.computed.sort('content', 'sortingProperties'),
actions: {
sortContent: function(sortBy) {
this.set('sortingProperties', sortBy ? [sortBy] : []);
}
}
});
module.exports = App.SortedTableHeaderItemController = Em.ObjectController.extend({
sortDirection: null,
isAsc: Em.computed.equal('sortDirection', 'asc'),
isDesc: Em.computed.equal('sortDirection', 'desc'),
// skip
actions: {
sortContent: function() {
this.set('sortDirection', this.nextSortDirection(this.get('sortDirection')));
return true;
}
}
});
What is the best way to reset sortDirection
on all itemControllers
except controller that fired an action?
Thank you.