From d816853b6c1903c145fec6d1524114742ed0549c Mon Sep 17 00:00:00 2001 From: Daniel Herrero Date: Wed, 29 Nov 2017 09:37:08 +0100 Subject: [PATCH] column-header posibilidad de columna no ordenable --- .../core/src/column-header/column-header.html | 2 +- .../core/src/column-header/column-header.js | 22 ++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/client/core/src/column-header/column-header.html b/client/core/src/column-header/column-header.html index 435057a19..d5747fcfe 100644 --- a/client/core/src/column-header/column-header.html +++ b/client/core/src/column-header/column-header.html @@ -1,5 +1,5 @@
- + {{::$ctrl.text}} diff --git a/client/core/src/column-header/column-header.js b/client/core/src/column-header/column-header.js index 2f5f4d3c3..4c52e7e3d 100644 --- a/client/core/src/column-header/column-header.js +++ b/client/core/src/column-header/column-header.js @@ -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'),