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"> <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> <vn-none class="title" translate>
{{::$ctrl.text}} {{::$ctrl.text}}
</vn-none> </vn-none>

View File

@ -1,11 +1,13 @@
import {module} from '../module'; import {module} from '../module';
export default class ColumnHeader { export default class ColumnHeader {
constructor() { constructor($attrs) {
this.order = undefined; this.order = undefined;
this.mouseIsOver = false; this.mouseIsOver = false;
this.orderLocked = ($attrs.orderLocked !== undefined);
} }
onClick() { onClick() {
if (!this.orderLocked) {
if (this.order === 'ASC') { if (this.order === 'ASC') {
this.order = 'DESC'; this.order = 'DESC';
} else { } else {
@ -13,7 +15,11 @@ export default class ColumnHeader {
} }
this.gridHeader.selectColum(this); this.gridHeader.selectColum(this);
} }
}
showArrow(type) { showArrow(type) {
if (this.orderLocked)
return false;
let showArrow = (this.gridHeader && this.gridHeader.currentColumn && this.gridHeader.currentColumn.field === this.field && this.order === type); 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); let showOther = (this.gridHeader && this.gridHeader.currentColumn && this.gridHeader.currentColumn.field === this.field && this.order !== type);
if (type === 'DESC' && this.mouseIsOver && !showOther) { if (type === 'DESC' && this.mouseIsOver && !showOther) {
@ -22,13 +28,13 @@ export default class ColumnHeader {
return showArrow; return showArrow;
} }
$onInit() { $onInit() {
if (this.defaultOrder) { if (this.defaultOrder && !this.orderLocked) {
this.order = this.defaultOrder; this.order = this.defaultOrder;
this.onClick(); this.onClick();
} }
} }
} }
ColumnHeader.$inject = []; ColumnHeader.$inject = ['$attrs'];
module.component('vnColumnHeader', { module.component('vnColumnHeader', {
template: require('./column-header.html'), template: require('./column-header.html'),