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">
|
<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>
|
||||||
|
|
|
@ -1,19 +1,25 @@
|
||||||
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.order === 'ASC') {
|
if (!this.orderLocked) {
|
||||||
this.order = 'DESC';
|
if (this.order === 'ASC') {
|
||||||
} else {
|
this.order = 'DESC';
|
||||||
this.order = 'ASC';
|
} else {
|
||||||
|
this.order = 'ASC';
|
||||||
|
}
|
||||||
|
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'),
|
||||||
|
|
Loading…
Reference in New Issue