column-header posibilidad de columna no ordenable
This commit is contained in:
parent
9638f5b529
commit
d816853b6c
|
@ -1,5 +1,5 @@
|
|||
<div class="{{$ctrl.className}}" ng-mouseover="$ctrl.mouseIsOver = true" ng-mouseleave="$ctrl.mouseIsOver = false">
|
||||
<vn-horizontal ng-if="$ctrl.text" class="orderly" ng-click="$ctrl.onClick()">
|
||||
<vn-horizontal ng-if="$ctrl.text" class="orderly" ng-class="{'pointer' : !$ctrl.orderLocked}" ng-click="$ctrl.onClick()">
|
||||
<vn-none class="title" translate>
|
||||
{{::$ctrl.text}}
|
||||
</vn-none>
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
import {module} from '../module';
|
||||
|
||||
export default class ColumnHeader {
|
||||
constructor() {
|
||||
constructor($attrs) {
|
||||
this.order = undefined;
|
||||
this.mouseIsOver = false;
|
||||
this.orderLocked = ($attrs.orderLocked !== undefined);
|
||||
}
|
||||
onClick() {
|
||||
if (!this.orderLocked) {
|
||||
if (this.order === 'ASC') {
|
||||
this.order = 'DESC';
|
||||
} else {
|
||||
|
@ -13,7 +15,11 @@ export default class ColumnHeader {
|
|||
}
|
||||
this.gridHeader.selectColum(this);
|
||||
}
|
||||
}
|
||||
showArrow(type) {
|
||||
if (this.orderLocked)
|
||||
return false;
|
||||
|
||||
let showArrow = (this.gridHeader && this.gridHeader.currentColumn && this.gridHeader.currentColumn.field === this.field && this.order === type);
|
||||
let showOther = (this.gridHeader && this.gridHeader.currentColumn && this.gridHeader.currentColumn.field === this.field && this.order !== type);
|
||||
if (type === 'DESC' && this.mouseIsOver && !showOther) {
|
||||
|
@ -22,13 +28,13 @@ export default class ColumnHeader {
|
|||
return showArrow;
|
||||
}
|
||||
$onInit() {
|
||||
if (this.defaultOrder) {
|
||||
if (this.defaultOrder && !this.orderLocked) {
|
||||
this.order = this.defaultOrder;
|
||||
this.onClick();
|
||||
}
|
||||
}
|
||||
}
|
||||
ColumnHeader.$inject = [];
|
||||
ColumnHeader.$inject = ['$attrs'];
|
||||
|
||||
module.component('vnColumnHeader', {
|
||||
template: require('./column-header.html'),
|
||||
|
|
Loading…
Reference in New Issue