column-header posibilidad de columna no ordenable

This commit is contained in:
Daniel Herrero 2017-11-29 09:37:08 +01:00
parent 9638f5b529
commit d816853b6c
2 changed files with 15 additions and 9 deletions

View File

@ -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>

View File

@ -1,19 +1,25 @@
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.order === 'ASC') {
this.order = 'DESC';
} else {
this.order = 'ASC';
if (!this.orderLocked) {
if (this.order === 'ASC') {
this.order = 'DESC';
} else {
this.order = 'ASC';
}
this.gridHeader.selectColum(this);
}
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'),