This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/sortable-heading.js.es6
2014-06-03 12:11:17 -04:00

28 lines
765 B
JavaScript

/**
Renders a heading for a table with optional sorting controls.
@class SortableHeadingComponent
@extends Ember.Component
@namespace Discourse
@module Discourse
**/
export default Ember.Component.extend({
tagName: 'th',
classNameBindings: ['number:num', 'sortBy', 'iconSortClass:sorting', 'sortable:sortable'],
attributeBindings: ['colspan'],
sortable: function() {
return this.get('sortBy');
}.property('sortBy'),
iconSortClass: function() {
if (this.get('sortable') && this.get('sortBy') === this.get('order')) {
return this.get('ascending') ? 'fa fa-chevron-up' : 'fa fa-chevron-down';
}
}.property('sortable', 'order', 'ascending'),
click: function() {
this.sendAction('action', this.get('sortBy'));
}
});