mirror of
https://github.com/getredash/redash.git
synced 2026-03-22 19:00:09 -04:00
27 lines
675 B
JavaScript
27 lines
675 B
JavaScript
export default function init(ngModule) {
|
|
ngModule.component('sortIcon', {
|
|
template: '<span ng-if="$ctrl.showIcon"><i class="fa fa-sort-{{$ctrl.icon}}"></i></span>',
|
|
bindings: {
|
|
column: '<',
|
|
sortColumn: '<',
|
|
reverse: '<',
|
|
},
|
|
controller() {
|
|
this.$onChanges = (changes) => {
|
|
['column', 'sortColumn', 'reverse'].forEach((v) => {
|
|
if (v in changes) {
|
|
this[v] = changes[v].currentValue;
|
|
}
|
|
});
|
|
|
|
this.showIcon = false;
|
|
|
|
if (this.column === this.sortColumn) {
|
|
this.showIcon = true;
|
|
this.icon = this.reverse ? 'desc' : 'asc';
|
|
}
|
|
};
|
|
},
|
|
});
|
|
}
|