You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2853 lines
129 KiB
JavaScript
2853 lines
129 KiB
JavaScript
"use strict";
|
|
var __assign = (this && this.__assign) || function () {
|
|
__assign = Object.assign || function(t) {
|
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
s = arguments[i];
|
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
t[p] = s[p];
|
|
}
|
|
return t;
|
|
};
|
|
return __assign.apply(this, arguments);
|
|
};
|
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
var core_1 = require("@angular/core");
|
|
var common_1 = require("@angular/common");
|
|
var rxjs_1 = require("rxjs");
|
|
var domhandler_1 = require("../dom/domhandler");
|
|
var paginator_1 = require("../paginator/paginator");
|
|
var shared_1 = require("../common/shared");
|
|
var objectutils_1 = require("../utils/objectutils");
|
|
var TreeTableService = /** @class */ (function () {
|
|
function TreeTableService() {
|
|
this.sortSource = new rxjs_1.Subject();
|
|
this.selectionSource = new rxjs_1.Subject();
|
|
this.contextMenuSource = new rxjs_1.Subject();
|
|
this.uiUpdateSource = new rxjs_1.Subject();
|
|
this.totalRecordsSource = new rxjs_1.Subject();
|
|
this.sortSource$ = this.sortSource.asObservable();
|
|
this.selectionSource$ = this.selectionSource.asObservable();
|
|
this.contextMenuSource$ = this.contextMenuSource.asObservable();
|
|
this.uiUpdateSource$ = this.uiUpdateSource.asObservable();
|
|
this.totalRecordsSource$ = this.totalRecordsSource.asObservable();
|
|
}
|
|
TreeTableService.prototype.onSort = function (sortMeta) {
|
|
this.sortSource.next(sortMeta);
|
|
};
|
|
TreeTableService.prototype.onSelectionChange = function () {
|
|
this.selectionSource.next();
|
|
};
|
|
TreeTableService.prototype.onContextMenu = function (node) {
|
|
this.contextMenuSource.next(node);
|
|
};
|
|
TreeTableService.prototype.onUIUpdate = function (value) {
|
|
this.uiUpdateSource.next(value);
|
|
};
|
|
TreeTableService.prototype.onTotalRecordsChange = function (value) {
|
|
this.totalRecordsSource.next(value);
|
|
};
|
|
TreeTableService = __decorate([
|
|
core_1.Injectable()
|
|
], TreeTableService);
|
|
return TreeTableService;
|
|
}());
|
|
exports.TreeTableService = TreeTableService;
|
|
var TreeTable = /** @class */ (function () {
|
|
function TreeTable(el, zone, tableService) {
|
|
this.el = el;
|
|
this.zone = zone;
|
|
this.tableService = tableService;
|
|
this.lazy = false;
|
|
this.first = 0;
|
|
this.pageLinks = 5;
|
|
this.alwaysShowPaginator = true;
|
|
this.paginatorPosition = 'bottom';
|
|
this.defaultSortOrder = 1;
|
|
this.sortMode = 'single';
|
|
this.resetPageOnSort = true;
|
|
this.selectionChange = new core_1.EventEmitter();
|
|
this.contextMenuSelectionChange = new core_1.EventEmitter();
|
|
this.contextMenuSelectionMode = "separate";
|
|
this.compareSelectionBy = 'deepEquals';
|
|
this.loadingIcon = 'pi pi-spinner';
|
|
this.showLoader = true;
|
|
this.virtualScrollDelay = 150;
|
|
this.virtualRowHeight = 28;
|
|
this.columnResizeMode = 'fit';
|
|
this.rowTrackBy = function (index, item) { return item; };
|
|
this.filters = {};
|
|
this.filterDelay = 300;
|
|
this.filterMode = 'lenient';
|
|
this.onFilter = new core_1.EventEmitter();
|
|
this.onNodeExpand = new core_1.EventEmitter();
|
|
this.onNodeCollapse = new core_1.EventEmitter();
|
|
this.onPage = new core_1.EventEmitter();
|
|
this.onSort = new core_1.EventEmitter();
|
|
this.onLazyLoad = new core_1.EventEmitter();
|
|
this.sortFunction = new core_1.EventEmitter();
|
|
this.onColResize = new core_1.EventEmitter();
|
|
this.onColReorder = new core_1.EventEmitter();
|
|
this.onNodeSelect = new core_1.EventEmitter();
|
|
this.onNodeUnselect = new core_1.EventEmitter();
|
|
this.onContextMenuSelect = new core_1.EventEmitter();
|
|
this.onHeaderCheckboxToggle = new core_1.EventEmitter();
|
|
this.onEditInit = new core_1.EventEmitter();
|
|
this.onEditComplete = new core_1.EventEmitter();
|
|
this.onEditCancel = new core_1.EventEmitter();
|
|
this._value = [];
|
|
this._totalRecords = 0;
|
|
this._sortOrder = 1;
|
|
this.selectionKeys = {};
|
|
this.filterConstraints = {
|
|
startsWith: function (value, filter) {
|
|
if (filter === undefined || filter === null || filter.trim() === '') {
|
|
return true;
|
|
}
|
|
if (value === undefined || value === null) {
|
|
return false;
|
|
}
|
|
var filterValue = objectutils_1.ObjectUtils.removeAccents(filter.toString()).toLowerCase();
|
|
var stringValue = objectutils_1.ObjectUtils.removeAccents(value.toString()).toLowerCase();
|
|
return stringValue.slice(0, filterValue.length) === filterValue;
|
|
},
|
|
contains: function (value, filter) {
|
|
if (filter === undefined || filter === null || (typeof filter === 'string' && filter.trim() === '')) {
|
|
return true;
|
|
}
|
|
if (value === undefined || value === null) {
|
|
return false;
|
|
}
|
|
var filterValue = objectutils_1.ObjectUtils.removeAccents(filter.toString()).toLowerCase();
|
|
var stringValue = objectutils_1.ObjectUtils.removeAccents(value.toString()).toLowerCase();
|
|
return stringValue.indexOf(filterValue) !== -1;
|
|
},
|
|
endsWith: function (value, filter) {
|
|
if (filter === undefined || filter === null || filter.trim() === '') {
|
|
return true;
|
|
}
|
|
if (value === undefined || value === null) {
|
|
return false;
|
|
}
|
|
var filterValue = objectutils_1.ObjectUtils.removeAccents(filter.toString()).toLowerCase();
|
|
var stringValue = objectutils_1.ObjectUtils.removeAccents(value.toString()).toLowerCase();
|
|
return stringValue.indexOf(filterValue, stringValue.length - filterValue.length) !== -1;
|
|
},
|
|
equals: function (value, filter) {
|
|
if (filter === undefined || filter === null || (typeof filter === 'string' && filter.trim() === '')) {
|
|
return true;
|
|
}
|
|
if (value === undefined || value === null) {
|
|
return false;
|
|
}
|
|
if (value.getTime && filter.getTime)
|
|
return value.getTime() === filter.getTime();
|
|
else
|
|
return objectutils_1.ObjectUtils.removeAccents(value.toString()).toLowerCase() == objectutils_1.ObjectUtils.removeAccents(filter.toString()).toLowerCase();
|
|
},
|
|
notEquals: function (value, filter) {
|
|
if (filter === undefined || filter === null || (typeof filter === 'string' && filter.trim() === '')) {
|
|
return false;
|
|
}
|
|
if (value === undefined || value === null) {
|
|
return true;
|
|
}
|
|
if (value.getTime && filter.getTime)
|
|
return value.getTime() !== filter.getTime();
|
|
else
|
|
return objectutils_1.ObjectUtils.removeAccents(value.toString()).toLowerCase() != objectutils_1.ObjectUtils.removeAccents(filter.toString()).toLowerCase();
|
|
},
|
|
in: function (value, filter) {
|
|
if (filter === undefined || filter === null || filter.length === 0) {
|
|
return true;
|
|
}
|
|
for (var i = 0; i < filter.length; i++) {
|
|
if (filter[i] === value || (value != null && (value.getTime && filter[i].getTime && value.getTime() === filter[i].getTime()))) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
},
|
|
lt: function (value, filter) {
|
|
if (filter === undefined || filter === null) {
|
|
return true;
|
|
}
|
|
if (value === undefined || value === null) {
|
|
return false;
|
|
}
|
|
if (value.getTime && filter.getTime)
|
|
return value.getTime() < filter.getTime();
|
|
else
|
|
return value < filter;
|
|
},
|
|
lte: function (value, filter) {
|
|
if (filter === undefined || filter === null) {
|
|
return true;
|
|
}
|
|
if (value === undefined || value === null) {
|
|
return false;
|
|
}
|
|
if (value.getTime && filter.getTime)
|
|
return value.getTime() <= filter.getTime();
|
|
else
|
|
return value <= filter;
|
|
},
|
|
gt: function (value, filter) {
|
|
if (filter === undefined || filter === null) {
|
|
return true;
|
|
}
|
|
if (value === undefined || value === null) {
|
|
return false;
|
|
}
|
|
if (value.getTime && filter.getTime)
|
|
return value.getTime() > filter.getTime();
|
|
else
|
|
return value > filter;
|
|
},
|
|
gte: function (value, filter) {
|
|
if (filter === undefined || filter === null) {
|
|
return true;
|
|
}
|
|
if (value === undefined || value === null) {
|
|
return false;
|
|
}
|
|
if (value.getTime && filter.getTime)
|
|
return value.getTime() >= filter.getTime();
|
|
else
|
|
return value >= filter;
|
|
}
|
|
};
|
|
}
|
|
TreeTable.prototype.ngOnInit = function () {
|
|
if (this.lazy) {
|
|
this.onLazyLoad.emit(this.createLazyLoadMetadata());
|
|
}
|
|
this.initialized = true;
|
|
};
|
|
TreeTable.prototype.ngAfterContentInit = function () {
|
|
var _this = this;
|
|
this.templates.forEach(function (item) {
|
|
switch (item.getType()) {
|
|
case 'caption':
|
|
_this.captionTemplate = item.template;
|
|
break;
|
|
case 'header':
|
|
_this.headerTemplate = item.template;
|
|
break;
|
|
case 'body':
|
|
_this.bodyTemplate = item.template;
|
|
break;
|
|
case 'loadingbody':
|
|
_this.loadingBodyTemplate = item.template;
|
|
break;
|
|
case 'footer':
|
|
_this.footerTemplate = item.template;
|
|
break;
|
|
case 'summary':
|
|
_this.summaryTemplate = item.template;
|
|
break;
|
|
case 'colgroup':
|
|
_this.colGroupTemplate = item.template;
|
|
break;
|
|
case 'emptymessage':
|
|
_this.emptyMessageTemplate = item.template;
|
|
break;
|
|
case 'paginatorleft':
|
|
_this.paginatorLeftTemplate = item.template;
|
|
break;
|
|
case 'paginatorright':
|
|
_this.paginatorRightTemplate = item.template;
|
|
break;
|
|
case 'frozenheader':
|
|
_this.frozenHeaderTemplate = item.template;
|
|
break;
|
|
case 'frozenbody':
|
|
_this.frozenBodyTemplate = item.template;
|
|
break;
|
|
case 'frozenfooter':
|
|
_this.frozenFooterTemplate = item.template;
|
|
break;
|
|
case 'frozencolgroup':
|
|
_this.frozenColGroupTemplate = item.template;
|
|
break;
|
|
}
|
|
});
|
|
};
|
|
Object.defineProperty(TreeTable.prototype, "value", {
|
|
get: function () {
|
|
return this._value;
|
|
},
|
|
set: function (val) {
|
|
this._value = val;
|
|
if (!this.lazy) {
|
|
this.totalRecords = (this._value ? this._value.length : 0);
|
|
if (this.sortMode == 'single' && this.sortField)
|
|
this.sortSingle();
|
|
else if (this.sortMode == 'multiple' && this.multiSortMeta)
|
|
this.sortMultiple();
|
|
else if (this.hasFilter()) //sort already filters
|
|
this._filter();
|
|
}
|
|
if (this.virtualScroll && this.virtualScrollCallback) {
|
|
this.virtualScrollCallback();
|
|
}
|
|
this.updateSerializedValue();
|
|
this.tableService.onUIUpdate(this.value);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
TreeTable.prototype.updateSerializedValue = function () {
|
|
this.serializedValue = [];
|
|
if (this.paginator)
|
|
this.serializePageNodes();
|
|
else
|
|
this.serializeNodes(null, this.filteredNodes || this.value, 0, true);
|
|
};
|
|
TreeTable.prototype.serializeNodes = function (parent, nodes, level, visible) {
|
|
if (nodes && nodes.length) {
|
|
for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
|
|
var node = nodes_1[_i];
|
|
node.parent = parent;
|
|
var rowNode = {
|
|
node: node,
|
|
parent: parent,
|
|
level: level,
|
|
visible: visible && (parent ? parent.expanded : true)
|
|
};
|
|
this.serializedValue.push(rowNode);
|
|
if (rowNode.visible && node.expanded) {
|
|
this.serializeNodes(node, node.children, level + 1, rowNode.visible);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
TreeTable.prototype.serializePageNodes = function () {
|
|
var data = this.filteredNodes || this.value;
|
|
this.serializedValue = [];
|
|
if (data && data.length) {
|
|
var first = this.lazy ? 0 : this.first;
|
|
for (var i = first; i < (first + this.rows); i++) {
|
|
var node = data[i];
|
|
if (node) {
|
|
this.serializedValue.push({
|
|
node: node,
|
|
parent: null,
|
|
level: 0,
|
|
visible: true
|
|
});
|
|
this.serializeNodes(node, node.children, 1, true);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
Object.defineProperty(TreeTable.prototype, "totalRecords", {
|
|
get: function () {
|
|
return this._totalRecords;
|
|
},
|
|
set: function (val) {
|
|
this._totalRecords = val;
|
|
this.tableService.onTotalRecordsChange(this._totalRecords);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(TreeTable.prototype, "sortField", {
|
|
get: function () {
|
|
return this._sortField;
|
|
},
|
|
set: function (val) {
|
|
this._sortField = val;
|
|
//avoid triggering lazy load prior to lazy initialization at onInit
|
|
if (!this.lazy || this.initialized) {
|
|
if (this.sortMode === 'single') {
|
|
this.sortSingle();
|
|
}
|
|
}
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(TreeTable.prototype, "sortOrder", {
|
|
get: function () {
|
|
return this._sortOrder;
|
|
},
|
|
set: function (val) {
|
|
this._sortOrder = val;
|
|
//avoid triggering lazy load prior to lazy initialization at onInit
|
|
if (!this.lazy || this.initialized) {
|
|
if (this.sortMode === 'single') {
|
|
this.sortSingle();
|
|
}
|
|
}
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(TreeTable.prototype, "multiSortMeta", {
|
|
get: function () {
|
|
return this._multiSortMeta;
|
|
},
|
|
set: function (val) {
|
|
this._multiSortMeta = val;
|
|
if (this.sortMode === 'multiple') {
|
|
this.sortMultiple();
|
|
}
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(TreeTable.prototype, "selection", {
|
|
get: function () {
|
|
return this._selection;
|
|
},
|
|
set: function (val) {
|
|
this._selection = val;
|
|
if (!this.preventSelectionSetterPropagation) {
|
|
this.updateSelectionKeys();
|
|
this.tableService.onSelectionChange();
|
|
}
|
|
this.preventSelectionSetterPropagation = false;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
TreeTable.prototype.updateSelectionKeys = function () {
|
|
if (this.dataKey && this._selection) {
|
|
this.selectionKeys = {};
|
|
if (Array.isArray(this._selection)) {
|
|
for (var _i = 0, _a = this._selection; _i < _a.length; _i++) {
|
|
var node = _a[_i];
|
|
this.selectionKeys[String(objectutils_1.ObjectUtils.resolveFieldData(node.data, this.dataKey))] = 1;
|
|
}
|
|
}
|
|
else {
|
|
this.selectionKeys[String(objectutils_1.ObjectUtils.resolveFieldData(this._selection.data, this.dataKey))] = 1;
|
|
}
|
|
}
|
|
};
|
|
TreeTable.prototype.onPageChange = function (event) {
|
|
this.first = event.first;
|
|
this.rows = event.rows;
|
|
if (this.lazy)
|
|
this.onLazyLoad.emit(this.createLazyLoadMetadata());
|
|
else
|
|
this.serializePageNodes();
|
|
this.onPage.emit({
|
|
first: this.first,
|
|
rows: this.rows
|
|
});
|
|
this.tableService.onUIUpdate(this.value);
|
|
};
|
|
TreeTable.prototype.sort = function (event) {
|
|
var originalEvent = event.originalEvent;
|
|
if (this.sortMode === 'single') {
|
|
this._sortOrder = (this.sortField === event.field) ? this.sortOrder * -1 : this.defaultSortOrder;
|
|
this._sortField = event.field;
|
|
this.sortSingle();
|
|
}
|
|
if (this.sortMode === 'multiple') {
|
|
var metaKey = originalEvent.metaKey || originalEvent.ctrlKey;
|
|
var sortMeta = this.getSortMeta(event.field);
|
|
if (sortMeta) {
|
|
if (!metaKey) {
|
|
this._multiSortMeta = [{ field: event.field, order: sortMeta.order * -1 }];
|
|
}
|
|
else {
|
|
sortMeta.order = sortMeta.order * -1;
|
|
}
|
|
}
|
|
else {
|
|
if (!metaKey || !this.multiSortMeta) {
|
|
this._multiSortMeta = [];
|
|
}
|
|
this.multiSortMeta.push({ field: event.field, order: this.defaultSortOrder });
|
|
}
|
|
this.sortMultiple();
|
|
}
|
|
};
|
|
TreeTable.prototype.sortSingle = function () {
|
|
if (this.sortField && this.sortOrder) {
|
|
if (this.resetPageOnSort) {
|
|
this.first = 0;
|
|
}
|
|
if (this.lazy) {
|
|
this.onLazyLoad.emit(this.createLazyLoadMetadata());
|
|
}
|
|
else if (this.value) {
|
|
this.sortNodes(this.value);
|
|
if (this.hasFilter()) {
|
|
this._filter();
|
|
}
|
|
}
|
|
var sortMeta = {
|
|
field: this.sortField,
|
|
order: this.sortOrder
|
|
};
|
|
this.onSort.emit(sortMeta);
|
|
this.tableService.onSort(sortMeta);
|
|
this.updateSerializedValue();
|
|
}
|
|
};
|
|
TreeTable.prototype.sortNodes = function (nodes) {
|
|
var _this = this;
|
|
if (!nodes || nodes.length === 0) {
|
|
return;
|
|
}
|
|
if (this.customSort) {
|
|
this.sortFunction.emit({
|
|
data: nodes,
|
|
mode: this.sortMode,
|
|
field: this.sortField,
|
|
order: this.sortOrder
|
|
});
|
|
}
|
|
else {
|
|
nodes.sort(function (node1, node2) {
|
|
var value1 = objectutils_1.ObjectUtils.resolveFieldData(node1.data, _this.sortField);
|
|
var value2 = objectutils_1.ObjectUtils.resolveFieldData(node2.data, _this.sortField);
|
|
var result = null;
|
|
if (value1 == null && value2 != null)
|
|
result = -1;
|
|
else if (value1 != null && value2 == null)
|
|
result = 1;
|
|
else if (value1 == null && value2 == null)
|
|
result = 0;
|
|
else if (typeof value1 === 'string' && typeof value2 === 'string')
|
|
result = value1.localeCompare(value2, undefined, { numeric: true });
|
|
else
|
|
result = (value1 < value2) ? -1 : (value1 > value2) ? 1 : 0;
|
|
return (_this.sortOrder * result);
|
|
});
|
|
}
|
|
for (var _i = 0, nodes_2 = nodes; _i < nodes_2.length; _i++) {
|
|
var node = nodes_2[_i];
|
|
this.sortNodes(node.children);
|
|
}
|
|
};
|
|
TreeTable.prototype.sortMultiple = function () {
|
|
if (this.multiSortMeta) {
|
|
if (this.lazy) {
|
|
this.onLazyLoad.emit(this.createLazyLoadMetadata());
|
|
}
|
|
else if (this.value) {
|
|
this.sortMultipleNodes(this.value);
|
|
if (this.hasFilter()) {
|
|
this._filter();
|
|
}
|
|
}
|
|
this.onSort.emit({
|
|
multisortmeta: this.multiSortMeta
|
|
});
|
|
this.tableService.onSort(this.multiSortMeta);
|
|
this.updateSerializedValue();
|
|
}
|
|
};
|
|
TreeTable.prototype.sortMultipleNodes = function (nodes) {
|
|
var _this = this;
|
|
if (!nodes || nodes.length === 0) {
|
|
return;
|
|
}
|
|
if (this.customSort) {
|
|
this.sortFunction.emit({
|
|
data: this.value,
|
|
mode: this.sortMode,
|
|
multiSortMeta: this.multiSortMeta
|
|
});
|
|
}
|
|
else {
|
|
this.value.sort(function (node1, node2) {
|
|
return _this.multisortField(node1, node2, _this.multiSortMeta, 0);
|
|
});
|
|
}
|
|
for (var _i = 0, nodes_3 = nodes; _i < nodes_3.length; _i++) {
|
|
var node = nodes_3[_i];
|
|
this.sortMultipleNodes(node.children);
|
|
}
|
|
};
|
|
TreeTable.prototype.multisortField = function (node1, node2, multiSortMeta, index) {
|
|
var value1 = objectutils_1.ObjectUtils.resolveFieldData(node1.data, multiSortMeta[index].field);
|
|
var value2 = objectutils_1.ObjectUtils.resolveFieldData(node2.data, multiSortMeta[index].field);
|
|
var result = null;
|
|
if (value1 == null && value2 != null)
|
|
result = -1;
|
|
else if (value1 != null && value2 == null)
|
|
result = 1;
|
|
else if (value1 == null && value2 == null)
|
|
result = 0;
|
|
if (typeof value1 == 'string' || value1 instanceof String) {
|
|
if (value1.localeCompare && (value1 != value2)) {
|
|
return (multiSortMeta[index].order * value1.localeCompare(value2, undefined, { numeric: true }));
|
|
}
|
|
}
|
|
else {
|
|
result = (value1 < value2) ? -1 : 1;
|
|
}
|
|
if (value1 == value2) {
|
|
return (multiSortMeta.length - 1) > (index) ? (this.multisortField(node1, node2, multiSortMeta, index + 1)) : 0;
|
|
}
|
|
return (multiSortMeta[index].order * result);
|
|
};
|
|
TreeTable.prototype.getSortMeta = function (field) {
|
|
if (this.multiSortMeta && this.multiSortMeta.length) {
|
|
for (var i = 0; i < this.multiSortMeta.length; i++) {
|
|
if (this.multiSortMeta[i].field === field) {
|
|
return this.multiSortMeta[i];
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
TreeTable.prototype.isSorted = function (field) {
|
|
if (this.sortMode === 'single') {
|
|
return (this.sortField && this.sortField === field);
|
|
}
|
|
else if (this.sortMode === 'multiple') {
|
|
var sorted = false;
|
|
if (this.multiSortMeta) {
|
|
for (var i = 0; i < this.multiSortMeta.length; i++) {
|
|
if (this.multiSortMeta[i].field == field) {
|
|
sorted = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return sorted;
|
|
}
|
|
};
|
|
TreeTable.prototype.createLazyLoadMetadata = function () {
|
|
return {
|
|
first: this.first,
|
|
rows: this.virtualScroll ? this.rows * 2 : this.rows,
|
|
sortField: this.sortField,
|
|
sortOrder: this.sortOrder,
|
|
filters: this.filters,
|
|
globalFilter: this.filters && this.filters['global'] ? this.filters['global'].value : null,
|
|
multiSortMeta: this.multiSortMeta
|
|
};
|
|
};
|
|
TreeTable.prototype.handleVirtualScroll = function (event) {
|
|
var _this = this;
|
|
this.first = (event.page - 1) * this.rows;
|
|
this.virtualScrollCallback = event.callback;
|
|
this.zone.run(function () {
|
|
if (_this.virtualScrollTimer) {
|
|
clearTimeout(_this.virtualScrollTimer);
|
|
}
|
|
_this.virtualScrollTimer = setTimeout(function () {
|
|
_this.onLazyLoad.emit(_this.createLazyLoadMetadata());
|
|
}, _this.virtualScrollDelay);
|
|
});
|
|
};
|
|
TreeTable.prototype.isEmpty = function () {
|
|
var data = this.filteredNodes || this.value;
|
|
return data == null || data.length == 0;
|
|
};
|
|
TreeTable.prototype.getBlockableElement = function () {
|
|
return this.el.nativeElement.children[0];
|
|
};
|
|
TreeTable.prototype.onColumnResizeBegin = function (event) {
|
|
var containerLeft = domhandler_1.DomHandler.getOffset(this.containerViewChild.nativeElement).left;
|
|
this.lastResizerHelperX = (event.pageX - containerLeft + this.containerViewChild.nativeElement.scrollLeft);
|
|
event.preventDefault();
|
|
};
|
|
TreeTable.prototype.onColumnResize = function (event) {
|
|
var containerLeft = domhandler_1.DomHandler.getOffset(this.containerViewChild.nativeElement).left;
|
|
domhandler_1.DomHandler.addClass(this.containerViewChild.nativeElement, 'ui-unselectable-text');
|
|
this.resizeHelperViewChild.nativeElement.style.height = this.containerViewChild.nativeElement.offsetHeight + 'px';
|
|
this.resizeHelperViewChild.nativeElement.style.top = 0 + 'px';
|
|
this.resizeHelperViewChild.nativeElement.style.left = (event.pageX - containerLeft + this.containerViewChild.nativeElement.scrollLeft) + 'px';
|
|
this.resizeHelperViewChild.nativeElement.style.display = 'block';
|
|
};
|
|
TreeTable.prototype.onColumnResizeEnd = function (event, column) {
|
|
var delta = this.resizeHelperViewChild.nativeElement.offsetLeft - this.lastResizerHelperX;
|
|
var columnWidth = column.offsetWidth;
|
|
var newColumnWidth = columnWidth + delta;
|
|
var minWidth = column.style.minWidth || 15;
|
|
if (columnWidth + delta > parseInt(minWidth)) {
|
|
if (this.columnResizeMode === 'fit') {
|
|
var nextColumn = column.nextElementSibling;
|
|
while (!nextColumn.offsetParent) {
|
|
nextColumn = nextColumn.nextElementSibling;
|
|
}
|
|
if (nextColumn) {
|
|
var nextColumnWidth = nextColumn.offsetWidth - delta;
|
|
var nextColumnMinWidth = nextColumn.style.minWidth || 15;
|
|
if (newColumnWidth > 15 && nextColumnWidth > parseInt(nextColumnMinWidth)) {
|
|
if (this.scrollable) {
|
|
var scrollableView = this.findParentScrollableView(column);
|
|
var scrollableBodyTable = domhandler_1.DomHandler.findSingle(scrollableView, 'table.ui-treetable-scrollable-body-table');
|
|
var scrollableHeaderTable = domhandler_1.DomHandler.findSingle(scrollableView, 'table.ui-treetable-scrollable-header-table');
|
|
var scrollableFooterTable = domhandler_1.DomHandler.findSingle(scrollableView, 'table.ui-treetable-scrollable-footer-table');
|
|
var resizeColumnIndex = domhandler_1.DomHandler.index(column);
|
|
this.resizeColGroup(scrollableHeaderTable, resizeColumnIndex, newColumnWidth, nextColumnWidth);
|
|
this.resizeColGroup(scrollableBodyTable, resizeColumnIndex, newColumnWidth, nextColumnWidth);
|
|
this.resizeColGroup(scrollableFooterTable, resizeColumnIndex, newColumnWidth, nextColumnWidth);
|
|
}
|
|
else {
|
|
column.style.width = newColumnWidth + 'px';
|
|
if (nextColumn) {
|
|
nextColumn.style.width = nextColumnWidth + 'px';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (this.columnResizeMode === 'expand') {
|
|
if (this.scrollable) {
|
|
var scrollableView = this.findParentScrollableView(column);
|
|
var scrollableBodyTable = domhandler_1.DomHandler.findSingle(scrollableView, 'table.ui-treetable-scrollable-body-table');
|
|
var scrollableHeaderTable = domhandler_1.DomHandler.findSingle(scrollableView, 'table.ui-treetable-scrollable-header-table');
|
|
var scrollableFooterTable = domhandler_1.DomHandler.findSingle(scrollableView, 'table.ui-treetable-scrollable-footer-table');
|
|
scrollableBodyTable.style.width = scrollableBodyTable.offsetWidth + delta + 'px';
|
|
scrollableHeaderTable.style.width = scrollableHeaderTable.offsetWidth + delta + 'px';
|
|
if (scrollableFooterTable) {
|
|
scrollableFooterTable.style.width = scrollableHeaderTable.offsetWidth + delta + 'px';
|
|
}
|
|
var resizeColumnIndex = domhandler_1.DomHandler.index(column);
|
|
this.resizeColGroup(scrollableHeaderTable, resizeColumnIndex, newColumnWidth, null);
|
|
this.resizeColGroup(scrollableBodyTable, resizeColumnIndex, newColumnWidth, null);
|
|
this.resizeColGroup(scrollableFooterTable, resizeColumnIndex, newColumnWidth, null);
|
|
}
|
|
else {
|
|
this.tableViewChild.nativeElement.style.width = this.tableViewChild.nativeElement.offsetWidth + delta + 'px';
|
|
column.style.width = newColumnWidth + 'px';
|
|
var containerWidth = this.tableViewChild.nativeElement.style.width;
|
|
this.containerViewChild.nativeElement.style.width = containerWidth + 'px';
|
|
}
|
|
}
|
|
this.onColResize.emit({
|
|
element: column,
|
|
delta: delta
|
|
});
|
|
}
|
|
this.resizeHelperViewChild.nativeElement.style.display = 'none';
|
|
domhandler_1.DomHandler.removeClass(this.containerViewChild.nativeElement, 'ui-unselectable-text');
|
|
};
|
|
TreeTable.prototype.findParentScrollableView = function (column) {
|
|
if (column) {
|
|
var parent_1 = column.parentElement;
|
|
while (parent_1 && !domhandler_1.DomHandler.hasClass(parent_1, 'ui-treetable-scrollable-view')) {
|
|
parent_1 = parent_1.parentElement;
|
|
}
|
|
return parent_1;
|
|
}
|
|
else {
|
|
return null;
|
|
}
|
|
};
|
|
TreeTable.prototype.resizeColGroup = function (table, resizeColumnIndex, newColumnWidth, nextColumnWidth) {
|
|
if (table) {
|
|
var colGroup = table.children[0].nodeName === 'COLGROUP' ? table.children[0] : null;
|
|
if (colGroup) {
|
|
var col = colGroup.children[resizeColumnIndex];
|
|
var nextCol = col.nextElementSibling;
|
|
col.style.width = newColumnWidth + 'px';
|
|
if (nextCol && nextColumnWidth) {
|
|
nextCol.style.width = nextColumnWidth + 'px';
|
|
}
|
|
}
|
|
else {
|
|
throw "Scrollable tables require a colgroup to support resizable columns";
|
|
}
|
|
}
|
|
};
|
|
TreeTable.prototype.onColumnDragStart = function (event, columnElement) {
|
|
this.reorderIconWidth = domhandler_1.DomHandler.getHiddenElementOuterWidth(this.reorderIndicatorUpViewChild.nativeElement);
|
|
this.reorderIconHeight = domhandler_1.DomHandler.getHiddenElementOuterHeight(this.reorderIndicatorDownViewChild.nativeElement);
|
|
this.draggedColumn = columnElement;
|
|
event.dataTransfer.setData('text', 'b'); // For firefox
|
|
};
|
|
TreeTable.prototype.onColumnDragEnter = function (event, dropHeader) {
|
|
if (this.reorderableColumns && this.draggedColumn && dropHeader) {
|
|
event.preventDefault();
|
|
var containerOffset = domhandler_1.DomHandler.getOffset(this.containerViewChild.nativeElement);
|
|
var dropHeaderOffset = domhandler_1.DomHandler.getOffset(dropHeader);
|
|
if (this.draggedColumn != dropHeader) {
|
|
var targetLeft = dropHeaderOffset.left - containerOffset.left;
|
|
var targetTop = containerOffset.top - dropHeaderOffset.top;
|
|
var columnCenter = dropHeaderOffset.left + dropHeader.offsetWidth / 2;
|
|
this.reorderIndicatorUpViewChild.nativeElement.style.top = dropHeaderOffset.top - containerOffset.top - (this.reorderIconHeight - 1) + 'px';
|
|
this.reorderIndicatorDownViewChild.nativeElement.style.top = dropHeaderOffset.top - containerOffset.top + dropHeader.offsetHeight + 'px';
|
|
if (event.pageX > columnCenter) {
|
|
this.reorderIndicatorUpViewChild.nativeElement.style.left = (targetLeft + dropHeader.offsetWidth - Math.ceil(this.reorderIconWidth / 2)) + 'px';
|
|
this.reorderIndicatorDownViewChild.nativeElement.style.left = (targetLeft + dropHeader.offsetWidth - Math.ceil(this.reorderIconWidth / 2)) + 'px';
|
|
this.dropPosition = 1;
|
|
}
|
|
else {
|
|
this.reorderIndicatorUpViewChild.nativeElement.style.left = (targetLeft - Math.ceil(this.reorderIconWidth / 2)) + 'px';
|
|
this.reorderIndicatorDownViewChild.nativeElement.style.left = (targetLeft - Math.ceil(this.reorderIconWidth / 2)) + 'px';
|
|
this.dropPosition = -1;
|
|
}
|
|
this.reorderIndicatorUpViewChild.nativeElement.style.display = 'block';
|
|
this.reorderIndicatorDownViewChild.nativeElement.style.display = 'block';
|
|
}
|
|
else {
|
|
event.dataTransfer.dropEffect = 'none';
|
|
}
|
|
}
|
|
};
|
|
TreeTable.prototype.onColumnDragLeave = function (event) {
|
|
if (this.reorderableColumns && this.draggedColumn) {
|
|
event.preventDefault();
|
|
this.reorderIndicatorUpViewChild.nativeElement.style.display = 'none';
|
|
this.reorderIndicatorDownViewChild.nativeElement.style.display = 'none';
|
|
}
|
|
};
|
|
TreeTable.prototype.onColumnDrop = function (event, dropColumn) {
|
|
event.preventDefault();
|
|
if (this.draggedColumn) {
|
|
var dragIndex = domhandler_1.DomHandler.indexWithinGroup(this.draggedColumn, 'ttreorderablecolumn');
|
|
var dropIndex = domhandler_1.DomHandler.indexWithinGroup(dropColumn, 'ttreorderablecolumn');
|
|
var allowDrop = (dragIndex != dropIndex);
|
|
if (allowDrop && ((dropIndex - dragIndex == 1 && this.dropPosition === -1) || (dragIndex - dropIndex == 1 && this.dropPosition === 1))) {
|
|
allowDrop = false;
|
|
}
|
|
if (allowDrop) {
|
|
objectutils_1.ObjectUtils.reorderArray(this.columns, dragIndex, dropIndex);
|
|
this.onColReorder.emit({
|
|
dragIndex: dragIndex,
|
|
dropIndex: dropIndex,
|
|
columns: this.columns
|
|
});
|
|
}
|
|
this.reorderIndicatorUpViewChild.nativeElement.style.display = 'none';
|
|
this.reorderIndicatorDownViewChild.nativeElement.style.display = 'none';
|
|
this.draggedColumn.draggable = false;
|
|
this.draggedColumn = null;
|
|
this.dropPosition = null;
|
|
}
|
|
};
|
|
TreeTable.prototype.handleRowClick = function (event) {
|
|
var targetNode = event.originalEvent.target.nodeName;
|
|
if (targetNode == 'INPUT' || targetNode == 'BUTTON' || targetNode == 'A' || (domhandler_1.DomHandler.hasClass(event.originalEvent.target, 'ui-clickable'))) {
|
|
return;
|
|
}
|
|
if (this.selectionMode) {
|
|
this.preventSelectionSetterPropagation = true;
|
|
var rowNode = event.rowNode;
|
|
var selected = this.isSelected(rowNode.node);
|
|
var metaSelection = this.rowTouched ? false : this.metaKeySelection;
|
|
var dataKeyValue = this.dataKey ? String(objectutils_1.ObjectUtils.resolveFieldData(rowNode.node.data, this.dataKey)) : null;
|
|
if (metaSelection) {
|
|
var metaKey = event.originalEvent.metaKey || event.originalEvent.ctrlKey;
|
|
if (selected && metaKey) {
|
|
if (this.isSingleSelectionMode()) {
|
|
this._selection = null;
|
|
this.selectionKeys = {};
|
|
this.selectionChange.emit(null);
|
|
}
|
|
else {
|
|
var selectionIndex_1 = this.findIndexInSelection(rowNode.node);
|
|
this._selection = this.selection.filter(function (val, i) { return i != selectionIndex_1; });
|
|
this.selectionChange.emit(this.selection);
|
|
if (dataKeyValue) {
|
|
delete this.selectionKeys[dataKeyValue];
|
|
}
|
|
}
|
|
this.onNodeUnselect.emit({ originalEvent: event.originalEvent, node: rowNode.node, type: 'row' });
|
|
}
|
|
else {
|
|
if (this.isSingleSelectionMode()) {
|
|
this._selection = rowNode.node;
|
|
this.selectionChange.emit(rowNode.node);
|
|
if (dataKeyValue) {
|
|
this.selectionKeys = {};
|
|
this.selectionKeys[dataKeyValue] = 1;
|
|
}
|
|
}
|
|
else if (this.isMultipleSelectionMode()) {
|
|
if (metaKey) {
|
|
this._selection = this.selection || [];
|
|
}
|
|
else {
|
|
this._selection = [];
|
|
this.selectionKeys = {};
|
|
}
|
|
this._selection = this.selection.concat([rowNode.node]);
|
|
this.selectionChange.emit(this.selection);
|
|
if (dataKeyValue) {
|
|
this.selectionKeys[dataKeyValue] = 1;
|
|
}
|
|
}
|
|
this.onNodeSelect.emit({ originalEvent: event.originalEvent, node: rowNode.node, type: 'row', index: event.rowIndex });
|
|
}
|
|
}
|
|
else {
|
|
if (this.selectionMode === 'single') {
|
|
if (selected) {
|
|
this._selection = null;
|
|
this.selectionKeys = {};
|
|
this.selectionChange.emit(this.selection);
|
|
this.onNodeUnselect.emit({ originalEvent: event.originalEvent, node: rowNode.node, type: 'row' });
|
|
}
|
|
else {
|
|
this._selection = rowNode.node;
|
|
this.selectionChange.emit(this.selection);
|
|
this.onNodeSelect.emit({ originalEvent: event.originalEvent, node: rowNode.node, type: 'row', index: event.rowIndex });
|
|
if (dataKeyValue) {
|
|
this.selectionKeys = {};
|
|
this.selectionKeys[dataKeyValue] = 1;
|
|
}
|
|
}
|
|
}
|
|
else if (this.selectionMode === 'multiple') {
|
|
if (selected) {
|
|
var selectionIndex_2 = this.findIndexInSelection(rowNode.node);
|
|
this._selection = this.selection.filter(function (val, i) { return i != selectionIndex_2; });
|
|
this.selectionChange.emit(this.selection);
|
|
this.onNodeUnselect.emit({ originalEvent: event.originalEvent, node: rowNode.node, type: 'row' });
|
|
if (dataKeyValue) {
|
|
delete this.selectionKeys[dataKeyValue];
|
|
}
|
|
}
|
|
else {
|
|
this._selection = this.selection ? this.selection.concat([rowNode.node]) : [rowNode.node];
|
|
this.selectionChange.emit(this.selection);
|
|
this.onNodeSelect.emit({ originalEvent: event.originalEvent, node: rowNode.node, type: 'row', index: event.rowIndex });
|
|
if (dataKeyValue) {
|
|
this.selectionKeys[dataKeyValue] = 1;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.tableService.onSelectionChange();
|
|
}
|
|
this.rowTouched = false;
|
|
};
|
|
TreeTable.prototype.handleRowTouchEnd = function (event) {
|
|
this.rowTouched = true;
|
|
};
|
|
TreeTable.prototype.handleRowRightClick = function (event) {
|
|
if (this.contextMenu) {
|
|
var node = event.rowNode.node;
|
|
if (this.contextMenuSelectionMode === 'separate') {
|
|
this.contextMenuSelection = node;
|
|
this.contextMenuSelectionChange.emit(node);
|
|
this.onContextMenuSelect.emit({ originalEvent: event.originalEvent, node: node });
|
|
this.contextMenu.show(event.originalEvent);
|
|
this.tableService.onContextMenu(node);
|
|
}
|
|
else if (this.contextMenuSelectionMode === 'joint') {
|
|
this.preventSelectionSetterPropagation = true;
|
|
var selected = this.isSelected(node);
|
|
var dataKeyValue = this.dataKey ? String(objectutils_1.ObjectUtils.resolveFieldData(node.data, this.dataKey)) : null;
|
|
if (!selected) {
|
|
if (this.isSingleSelectionMode()) {
|
|
this.selection = node;
|
|
this.selectionChange.emit(node);
|
|
}
|
|
else if (this.isMultipleSelectionMode()) {
|
|
this.selection = [node];
|
|
this.selectionChange.emit(this.selection);
|
|
}
|
|
if (dataKeyValue) {
|
|
this.selectionKeys[dataKeyValue] = 1;
|
|
}
|
|
}
|
|
this.contextMenu.show(event.originalEvent);
|
|
this.onContextMenuSelect.emit({ originalEvent: event.originalEvent, node: node });
|
|
}
|
|
}
|
|
};
|
|
TreeTable.prototype.toggleNodeWithCheckbox = function (event) {
|
|
this.selection = this.selection || [];
|
|
this.preventSelectionSetterPropagation = true;
|
|
var node = event.rowNode.node;
|
|
var selected = this.isSelected(node);
|
|
if (selected) {
|
|
this.propagateSelectionDown(node, false);
|
|
if (event.rowNode.parent) {
|
|
this.propagateSelectionUp(node.parent, false);
|
|
}
|
|
this.selectionChange.emit(this.selection);
|
|
this.onNodeUnselect.emit({ originalEvent: event, node: node });
|
|
}
|
|
else {
|
|
this.propagateSelectionDown(node, true);
|
|
if (event.rowNode.parent) {
|
|
this.propagateSelectionUp(node.parent, true);
|
|
}
|
|
this.selectionChange.emit(this.selection);
|
|
this.onNodeSelect.emit({ originalEvent: event, node: node });
|
|
}
|
|
this.tableService.onSelectionChange();
|
|
};
|
|
TreeTable.prototype.toggleNodesWithCheckbox = function (event, check) {
|
|
var data = this.filteredNodes || this.value;
|
|
this._selection = check && data ? data.slice() : [];
|
|
if (check) {
|
|
if (data && data.length) {
|
|
for (var _i = 0, data_1 = data; _i < data_1.length; _i++) {
|
|
var node = data_1[_i];
|
|
this.propagateSelectionDown(node, true);
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
this._selection = [];
|
|
this.selectionKeys = {};
|
|
}
|
|
this.preventSelectionSetterPropagation = true;
|
|
this.selectionChange.emit(this._selection);
|
|
this.tableService.onSelectionChange();
|
|
this.onHeaderCheckboxToggle.emit({ originalEvent: event, checked: check });
|
|
};
|
|
TreeTable.prototype.propagateSelectionUp = function (node, select) {
|
|
if (node.children && node.children.length) {
|
|
var selectedChildCount = 0;
|
|
var childPartialSelected = false;
|
|
var dataKeyValue = this.dataKey ? String(objectutils_1.ObjectUtils.resolveFieldData(node.data, this.dataKey)) : null;
|
|
for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
|
|
var child = _a[_i];
|
|
if (this.isSelected(child))
|
|
selectedChildCount++;
|
|
else if (child.partialSelected)
|
|
childPartialSelected = true;
|
|
}
|
|
if (select && selectedChildCount == node.children.length) {
|
|
this._selection = (this.selection || []).concat([node]);
|
|
node.partialSelected = false;
|
|
if (dataKeyValue) {
|
|
this.selectionKeys[dataKeyValue] = 1;
|
|
}
|
|
}
|
|
else {
|
|
if (!select) {
|
|
var index_1 = this.findIndexInSelection(node);
|
|
if (index_1 >= 0) {
|
|
this._selection = this.selection.filter(function (val, i) { return i != index_1; });
|
|
if (dataKeyValue) {
|
|
delete this.selectionKeys[dataKeyValue];
|
|
}
|
|
}
|
|
}
|
|
if (childPartialSelected || selectedChildCount > 0 && selectedChildCount != node.children.length)
|
|
node.partialSelected = true;
|
|
else
|
|
node.partialSelected = false;
|
|
}
|
|
}
|
|
var parent = node.parent;
|
|
if (parent) {
|
|
this.propagateSelectionUp(parent, select);
|
|
}
|
|
};
|
|
TreeTable.prototype.propagateSelectionDown = function (node, select) {
|
|
var index = this.findIndexInSelection(node);
|
|
var dataKeyValue = this.dataKey ? String(objectutils_1.ObjectUtils.resolveFieldData(node.data, this.dataKey)) : null;
|
|
if (select && index == -1) {
|
|
this._selection = (this.selection || []).concat([node]);
|
|
if (dataKeyValue) {
|
|
this.selectionKeys[dataKeyValue] = 1;
|
|
}
|
|
}
|
|
else if (!select && index > -1) {
|
|
this._selection = this.selection.filter(function (val, i) { return i != index; });
|
|
if (dataKeyValue) {
|
|
delete this.selectionKeys[dataKeyValue];
|
|
}
|
|
}
|
|
node.partialSelected = false;
|
|
if (node.children && node.children.length) {
|
|
for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
|
|
var child = _a[_i];
|
|
this.propagateSelectionDown(child, select);
|
|
}
|
|
}
|
|
};
|
|
TreeTable.prototype.isSelected = function (node) {
|
|
if (node && this.selection) {
|
|
if (this.dataKey) {
|
|
return this.selectionKeys[objectutils_1.ObjectUtils.resolveFieldData(node.data, this.dataKey)] !== undefined;
|
|
}
|
|
else {
|
|
if (this.selection instanceof Array)
|
|
return this.findIndexInSelection(node) > -1;
|
|
else
|
|
return this.equals(node, this.selection);
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
TreeTable.prototype.findIndexInSelection = function (node) {
|
|
var index = -1;
|
|
if (this.selection && this.selection.length) {
|
|
for (var i = 0; i < this.selection.length; i++) {
|
|
if (this.equals(node, this.selection[i])) {
|
|
index = i;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return index;
|
|
};
|
|
TreeTable.prototype.isSingleSelectionMode = function () {
|
|
return this.selectionMode === 'single';
|
|
};
|
|
TreeTable.prototype.isMultipleSelectionMode = function () {
|
|
return this.selectionMode === 'multiple';
|
|
};
|
|
TreeTable.prototype.equals = function (node1, node2) {
|
|
return this.compareSelectionBy === 'equals' ? (node1 === node2) : objectutils_1.ObjectUtils.equals(node1.data, node2.data, this.dataKey);
|
|
};
|
|
TreeTable.prototype.filter = function (value, field, matchMode) {
|
|
var _this = this;
|
|
if (this.filterTimeout) {
|
|
clearTimeout(this.filterTimeout);
|
|
}
|
|
if (!this.isFilterBlank(value)) {
|
|
this.filters[field] = { value: value, matchMode: matchMode };
|
|
}
|
|
else if (this.filters[field]) {
|
|
delete this.filters[field];
|
|
}
|
|
this.filterTimeout = setTimeout(function () {
|
|
_this._filter();
|
|
_this.filterTimeout = null;
|
|
}, this.filterDelay);
|
|
};
|
|
TreeTable.prototype.filterGlobal = function (value, matchMode) {
|
|
this.filter(value, 'global', matchMode);
|
|
};
|
|
TreeTable.prototype.isFilterBlank = function (filter) {
|
|
if (filter !== null && filter !== undefined) {
|
|
if ((typeof filter === 'string' && filter.trim().length == 0) || (filter instanceof Array && filter.length == 0))
|
|
return true;
|
|
else
|
|
return false;
|
|
}
|
|
return true;
|
|
};
|
|
TreeTable.prototype._filter = function () {
|
|
if (this.lazy) {
|
|
this.onLazyLoad.emit(this.createLazyLoadMetadata());
|
|
}
|
|
else {
|
|
if (!this.value) {
|
|
return;
|
|
}
|
|
if (!this.hasFilter()) {
|
|
this.filteredNodes = null;
|
|
if (this.paginator) {
|
|
this.totalRecords = this.value ? this.value.length : 0;
|
|
}
|
|
}
|
|
else {
|
|
var globalFilterFieldsArray = void 0;
|
|
if (this.filters['global']) {
|
|
if (!this.columns && !this.globalFilterFields)
|
|
throw new Error('Global filtering requires dynamic columns or globalFilterFields to be defined.');
|
|
else
|
|
globalFilterFieldsArray = this.globalFilterFields || this.columns;
|
|
}
|
|
this.filteredNodes = [];
|
|
var isStrictMode = this.filterMode === 'strict';
|
|
var isValueChanged = false;
|
|
for (var _i = 0, _a = this.value; _i < _a.length; _i++) {
|
|
var node = _a[_i];
|
|
var copyNode = __assign({}, node);
|
|
var localMatch = true;
|
|
var globalMatch = false;
|
|
var paramsWithoutNode = void 0;
|
|
for (var prop in this.filters) {
|
|
if (this.filters.hasOwnProperty(prop) && prop !== 'global') {
|
|
var filterMeta = this.filters[prop];
|
|
var filterField = prop;
|
|
var filterValue = filterMeta.value;
|
|
var filterMatchMode = filterMeta.matchMode || 'startsWith';
|
|
var filterConstraint = this.filterConstraints[filterMatchMode];
|
|
paramsWithoutNode = { filterField: filterField, filterValue: filterValue, filterConstraint: filterConstraint, isStrictMode: isStrictMode };
|
|
if ((isStrictMode && !(this.findFilteredNodes(copyNode, paramsWithoutNode) || this.isFilterMatched(copyNode, paramsWithoutNode))) ||
|
|
(!isStrictMode && !(this.isFilterMatched(copyNode, paramsWithoutNode) || this.findFilteredNodes(copyNode, paramsWithoutNode)))) {
|
|
localMatch = false;
|
|
}
|
|
if (!localMatch) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (this.filters['global'] && !globalMatch && globalFilterFieldsArray) {
|
|
for (var j = 0; j < globalFilterFieldsArray.length; j++) {
|
|
var copyNodeForGlobal = __assign({}, copyNode);
|
|
var filterField = globalFilterFieldsArray[j].field || globalFilterFieldsArray[j];
|
|
var filterValue = this.filters['global'].value;
|
|
var filterConstraint = this.filterConstraints[this.filters['global'].matchMode];
|
|
paramsWithoutNode = { filterField: filterField, filterValue: filterValue, filterConstraint: filterConstraint, isStrictMode: isStrictMode };
|
|
if ((isStrictMode && (this.findFilteredNodes(copyNodeForGlobal, paramsWithoutNode) || this.isFilterMatched(copyNodeForGlobal, paramsWithoutNode))) ||
|
|
(!isStrictMode && (this.isFilterMatched(copyNodeForGlobal, paramsWithoutNode) || this.findFilteredNodes(copyNodeForGlobal, paramsWithoutNode)))) {
|
|
globalMatch = true;
|
|
copyNode = copyNodeForGlobal;
|
|
}
|
|
}
|
|
}
|
|
var matches = localMatch;
|
|
if (this.filters['global']) {
|
|
matches = localMatch && globalMatch;
|
|
}
|
|
if (matches) {
|
|
this.filteredNodes.push(copyNode);
|
|
}
|
|
isValueChanged = isValueChanged || !localMatch || globalMatch;
|
|
}
|
|
if (!isValueChanged) {
|
|
this.filteredNodes = null;
|
|
}
|
|
if (this.paginator) {
|
|
this.totalRecords = this.filteredNodes ? this.filteredNodes.length : this.value ? this.value.length : 0;
|
|
}
|
|
}
|
|
}
|
|
this.first = 0;
|
|
var filteredValue = this.filteredNodes || this.value;
|
|
this.onFilter.emit({
|
|
filters: this.filters,
|
|
filteredValue: filteredValue
|
|
});
|
|
this.tableService.onUIUpdate(filteredValue);
|
|
this.updateSerializedValue();
|
|
};
|
|
TreeTable.prototype.findFilteredNodes = function (node, paramsWithoutNode) {
|
|
if (node) {
|
|
var matched = false;
|
|
if (node.children) {
|
|
var childNodes = node.children.slice();
|
|
node.children = [];
|
|
for (var _i = 0, childNodes_1 = childNodes; _i < childNodes_1.length; _i++) {
|
|
var childNode = childNodes_1[_i];
|
|
var copyChildNode = __assign({}, childNode);
|
|
if (this.isFilterMatched(copyChildNode, paramsWithoutNode)) {
|
|
matched = true;
|
|
node.children.push(copyChildNode);
|
|
}
|
|
}
|
|
}
|
|
if (matched) {
|
|
return true;
|
|
}
|
|
}
|
|
};
|
|
TreeTable.prototype.isFilterMatched = function (node, _a) {
|
|
var filterField = _a.filterField, filterValue = _a.filterValue, filterConstraint = _a.filterConstraint, isStrictMode = _a.isStrictMode;
|
|
var matched = false;
|
|
var dataFieldValue = objectutils_1.ObjectUtils.resolveFieldData(node.data, filterField);
|
|
if (filterConstraint(dataFieldValue, filterValue)) {
|
|
matched = true;
|
|
}
|
|
if (!matched || (isStrictMode && !this.isNodeLeaf(node))) {
|
|
matched = this.findFilteredNodes(node, { filterField: filterField, filterValue: filterValue, filterConstraint: filterConstraint, isStrictMode: isStrictMode }) || matched;
|
|
}
|
|
return matched;
|
|
};
|
|
TreeTable.prototype.isNodeLeaf = function (node) {
|
|
return node.leaf === false ? false : !(node.children && node.children.length);
|
|
};
|
|
TreeTable.prototype.hasFilter = function () {
|
|
var empty = true;
|
|
for (var prop in this.filters) {
|
|
if (this.filters.hasOwnProperty(prop)) {
|
|
empty = false;
|
|
break;
|
|
}
|
|
}
|
|
return !empty;
|
|
};
|
|
TreeTable.prototype.reset = function () {
|
|
this._sortField = null;
|
|
this._sortOrder = 1;
|
|
this._multiSortMeta = null;
|
|
this.tableService.onSort(null);
|
|
this.filteredNodes = null;
|
|
this.filters = {};
|
|
this.first = 0;
|
|
if (this.lazy) {
|
|
this.onLazyLoad.emit(this.createLazyLoadMetadata());
|
|
}
|
|
else {
|
|
this.totalRecords = (this._value ? this._value.length : 0);
|
|
}
|
|
};
|
|
TreeTable.prototype.updateEditingCell = function (cell) {
|
|
this.editingCell = cell;
|
|
this.bindDocumentEditListener();
|
|
};
|
|
TreeTable.prototype.isEditingCellValid = function () {
|
|
return (this.editingCell && domhandler_1.DomHandler.find(this.editingCell, '.ng-invalid.ng-dirty').length === 0);
|
|
};
|
|
TreeTable.prototype.bindDocumentEditListener = function () {
|
|
var _this = this;
|
|
if (!this.documentEditListener) {
|
|
this.documentEditListener = function (event) {
|
|
if (_this.editingCell && !_this.editingCellClick && _this.isEditingCellValid()) {
|
|
domhandler_1.DomHandler.removeClass(_this.editingCell, 'ui-editing-cell');
|
|
_this.editingCell = null;
|
|
_this.unbindDocumentEditListener();
|
|
}
|
|
_this.editingCellClick = false;
|
|
};
|
|
document.addEventListener('click', this.documentEditListener);
|
|
}
|
|
};
|
|
TreeTable.prototype.unbindDocumentEditListener = function () {
|
|
if (this.documentEditListener) {
|
|
document.removeEventListener('click', this.documentEditListener);
|
|
this.documentEditListener = null;
|
|
}
|
|
};
|
|
TreeTable.prototype.ngOnDestroy = function () {
|
|
this.unbindDocumentEditListener();
|
|
this.editingCell = null;
|
|
this.initialized = null;
|
|
};
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Array)
|
|
], TreeTable.prototype, "columns", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Object)
|
|
], TreeTable.prototype, "style", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", String)
|
|
], TreeTable.prototype, "styleClass", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Boolean)
|
|
], TreeTable.prototype, "autoLayout", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Boolean)
|
|
], TreeTable.prototype, "lazy", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Boolean)
|
|
], TreeTable.prototype, "paginator", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Number)
|
|
], TreeTable.prototype, "rows", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Number)
|
|
], TreeTable.prototype, "first", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Number)
|
|
], TreeTable.prototype, "pageLinks", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Array)
|
|
], TreeTable.prototype, "rowsPerPageOptions", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Boolean)
|
|
], TreeTable.prototype, "alwaysShowPaginator", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", String)
|
|
], TreeTable.prototype, "paginatorPosition", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Object)
|
|
], TreeTable.prototype, "paginatorDropdownAppendTo", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Number)
|
|
], TreeTable.prototype, "defaultSortOrder", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", String)
|
|
], TreeTable.prototype, "sortMode", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Boolean)
|
|
], TreeTable.prototype, "resetPageOnSort", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Boolean)
|
|
], TreeTable.prototype, "customSort", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", String)
|
|
], TreeTable.prototype, "selectionMode", void 0);
|
|
__decorate([
|
|
core_1.Output(),
|
|
__metadata("design:type", core_1.EventEmitter)
|
|
], TreeTable.prototype, "selectionChange", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Object)
|
|
], TreeTable.prototype, "contextMenuSelection", void 0);
|
|
__decorate([
|
|
core_1.Output(),
|
|
__metadata("design:type", core_1.EventEmitter)
|
|
], TreeTable.prototype, "contextMenuSelectionChange", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", String)
|
|
], TreeTable.prototype, "contextMenuSelectionMode", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", String)
|
|
], TreeTable.prototype, "dataKey", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Boolean)
|
|
], TreeTable.prototype, "metaKeySelection", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", String)
|
|
], TreeTable.prototype, "compareSelectionBy", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Boolean)
|
|
], TreeTable.prototype, "rowHover", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Boolean)
|
|
], TreeTable.prototype, "loading", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", String)
|
|
], TreeTable.prototype, "loadingIcon", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Boolean)
|
|
], TreeTable.prototype, "showLoader", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Boolean)
|
|
], TreeTable.prototype, "scrollable", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", String)
|
|
], TreeTable.prototype, "scrollHeight", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Boolean)
|
|
], TreeTable.prototype, "virtualScroll", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Number)
|
|
], TreeTable.prototype, "virtualScrollDelay", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Number)
|
|
], TreeTable.prototype, "virtualRowHeight", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", String)
|
|
], TreeTable.prototype, "frozenWidth", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Array)
|
|
], TreeTable.prototype, "frozenColumns", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Boolean)
|
|
], TreeTable.prototype, "resizableColumns", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", String)
|
|
], TreeTable.prototype, "columnResizeMode", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Boolean)
|
|
], TreeTable.prototype, "reorderableColumns", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Object)
|
|
], TreeTable.prototype, "contextMenu", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Function)
|
|
], TreeTable.prototype, "rowTrackBy", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Object)
|
|
], TreeTable.prototype, "filters", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Array)
|
|
], TreeTable.prototype, "globalFilterFields", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Number)
|
|
], TreeTable.prototype, "filterDelay", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", String)
|
|
], TreeTable.prototype, "filterMode", void 0);
|
|
__decorate([
|
|
core_1.Output(),
|
|
__metadata("design:type", core_1.EventEmitter)
|
|
], TreeTable.prototype, "onFilter", void 0);
|
|
__decorate([
|
|
core_1.Output(),
|
|
__metadata("design:type", core_1.EventEmitter)
|
|
], TreeTable.prototype, "onNodeExpand", void 0);
|
|
__decorate([
|
|
core_1.Output(),
|
|
__metadata("design:type", core_1.EventEmitter)
|
|
], TreeTable.prototype, "onNodeCollapse", void 0);
|
|
__decorate([
|
|
core_1.Output(),
|
|
__metadata("design:type", core_1.EventEmitter)
|
|
], TreeTable.prototype, "onPage", void 0);
|
|
__decorate([
|
|
core_1.Output(),
|
|
__metadata("design:type", core_1.EventEmitter)
|
|
], TreeTable.prototype, "onSort", void 0);
|
|
__decorate([
|
|
core_1.Output(),
|
|
__metadata("design:type", core_1.EventEmitter)
|
|
], TreeTable.prototype, "onLazyLoad", void 0);
|
|
__decorate([
|
|
core_1.Output(),
|
|
__metadata("design:type", core_1.EventEmitter)
|
|
], TreeTable.prototype, "sortFunction", void 0);
|
|
__decorate([
|
|
core_1.Output(),
|
|
__metadata("design:type", core_1.EventEmitter)
|
|
], TreeTable.prototype, "onColResize", void 0);
|
|
__decorate([
|
|
core_1.Output(),
|
|
__metadata("design:type", core_1.EventEmitter)
|
|
], TreeTable.prototype, "onColReorder", void 0);
|
|
__decorate([
|
|
core_1.Output(),
|
|
__metadata("design:type", core_1.EventEmitter)
|
|
], TreeTable.prototype, "onNodeSelect", void 0);
|
|
__decorate([
|
|
core_1.Output(),
|
|
__metadata("design:type", core_1.EventEmitter)
|
|
], TreeTable.prototype, "onNodeUnselect", void 0);
|
|
__decorate([
|
|
core_1.Output(),
|
|
__metadata("design:type", core_1.EventEmitter)
|
|
], TreeTable.prototype, "onContextMenuSelect", void 0);
|
|
__decorate([
|
|
core_1.Output(),
|
|
__metadata("design:type", core_1.EventEmitter)
|
|
], TreeTable.prototype, "onHeaderCheckboxToggle", void 0);
|
|
__decorate([
|
|
core_1.Output(),
|
|
__metadata("design:type", core_1.EventEmitter)
|
|
], TreeTable.prototype, "onEditInit", void 0);
|
|
__decorate([
|
|
core_1.Output(),
|
|
__metadata("design:type", core_1.EventEmitter)
|
|
], TreeTable.prototype, "onEditComplete", void 0);
|
|
__decorate([
|
|
core_1.Output(),
|
|
__metadata("design:type", core_1.EventEmitter)
|
|
], TreeTable.prototype, "onEditCancel", void 0);
|
|
__decorate([
|
|
core_1.ViewChild('container'),
|
|
__metadata("design:type", core_1.ElementRef)
|
|
], TreeTable.prototype, "containerViewChild", void 0);
|
|
__decorate([
|
|
core_1.ViewChild('resizeHelper'),
|
|
__metadata("design:type", core_1.ElementRef)
|
|
], TreeTable.prototype, "resizeHelperViewChild", void 0);
|
|
__decorate([
|
|
core_1.ViewChild('reorderIndicatorUp'),
|
|
__metadata("design:type", core_1.ElementRef)
|
|
], TreeTable.prototype, "reorderIndicatorUpViewChild", void 0);
|
|
__decorate([
|
|
core_1.ViewChild('reorderIndicatorDown'),
|
|
__metadata("design:type", core_1.ElementRef)
|
|
], TreeTable.prototype, "reorderIndicatorDownViewChild", void 0);
|
|
__decorate([
|
|
core_1.ViewChild('table'),
|
|
__metadata("design:type", core_1.ElementRef)
|
|
], TreeTable.prototype, "tableViewChild", void 0);
|
|
__decorate([
|
|
core_1.ContentChildren(shared_1.PrimeTemplate),
|
|
__metadata("design:type", core_1.QueryList)
|
|
], TreeTable.prototype, "templates", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Array),
|
|
__metadata("design:paramtypes", [Array])
|
|
], TreeTable.prototype, "value", null);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Number),
|
|
__metadata("design:paramtypes", [Number])
|
|
], TreeTable.prototype, "totalRecords", null);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", String),
|
|
__metadata("design:paramtypes", [String])
|
|
], TreeTable.prototype, "sortField", null);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Number),
|
|
__metadata("design:paramtypes", [Number])
|
|
], TreeTable.prototype, "sortOrder", null);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Array),
|
|
__metadata("design:paramtypes", [Array])
|
|
], TreeTable.prototype, "multiSortMeta", null);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Object),
|
|
__metadata("design:paramtypes", [Object])
|
|
], TreeTable.prototype, "selection", null);
|
|
TreeTable = __decorate([
|
|
core_1.Component({
|
|
selector: 'p-treeTable',
|
|
template: "\n <div #container [ngStyle]=\"style\" [class]=\"styleClass\"\n [ngClass]=\"{'ui-treetable ui-widget': true, 'ui-treetable-auto-layout': autoLayout, 'ui-treetable-hoverable-rows': (rowHover||(selectionMode === 'single' || selectionMode === 'multiple')),\n 'ui-treetable-resizable': resizableColumns, 'ui-treetable-resizable-fit': (resizableColumns && columnResizeMode === 'fit')}\">\n <div class=\"ui-treetable-loading ui-widget-overlay\" *ngIf=\"loading && showLoader\"></div>\n <div class=\"ui-treetable-loading-content\" *ngIf=\"loading && showLoader\">\n <i [class]=\"'ui-treetable-loading-icon pi-spin ' + loadingIcon\"></i>\n </div>\n <div *ngIf=\"captionTemplate\" class=\"ui-treetable-caption ui-widget-header\">\n <ng-container *ngTemplateOutlet=\"captionTemplate\"></ng-container>\n </div>\n <p-paginator [rows]=\"rows\" [first]=\"first\" [totalRecords]=\"totalRecords\" [pageLinkSize]=\"pageLinks\" styleClass=\"ui-paginator-top\" [alwaysShow]=\"alwaysShowPaginator\"\n (onPageChange)=\"onPageChange($event)\" [rowsPerPageOptions]=\"rowsPerPageOptions\" *ngIf=\"paginator && (paginatorPosition === 'top' || paginatorPosition =='both')\"\n [templateLeft]=\"paginatorLeftTemplate\" [templateRight]=\"paginatorRightTemplate\" [dropdownAppendTo]=\"paginatorDropdownAppendTo\"></p-paginator>\n \n <div class=\"ui-treetable-wrapper\" *ngIf=\"!scrollable\">\n <table #table class=\"ui-treetable-table\">\n <ng-container *ngTemplateOutlet=\"colGroupTemplate; context {$implicit: columns}\"></ng-container>\n <thead class=\"ui-treetable-thead\">\n <ng-container *ngTemplateOutlet=\"headerTemplate; context: {$implicit: columns}\"></ng-container>\n </thead>\n <tfoot class=\"ui-treetable-tfoot\">\n <ng-container *ngTemplateOutlet=\"footerTemplate; context {$implicit: columns}\"></ng-container>\n </tfoot>\n <tbody class=\"ui-treetable-tbody\" [pTreeTableBody]=\"columns\" [pTreeTableBodyTemplate]=\"bodyTemplate\"></tbody>\n </table>\n </div>\n\n <div class=\"ui-treetable-scrollable-wrapper\" *ngIf=\"scrollable\">\n <div class=\"ui-treetable-scrollable-view ui-treetable-frozen-view\" *ngIf=\"frozenColumns||frozenBodyTemplate\" [ttScrollableView]=\"frozenColumns\" [frozen]=\"true\" [ngStyle]=\"{width: frozenWidth}\" [scrollHeight]=\"scrollHeight\"></div>\n <div class=\"ui-treetable-scrollable-view\" [ttScrollableView]=\"columns\" [frozen]=\"false\" [scrollHeight]=\"scrollHeight\"></div>\n </div>\n\n <p-paginator [rows]=\"rows\" [first]=\"first\" [totalRecords]=\"totalRecords\" [pageLinkSize]=\"pageLinks\" styleClass=\"ui-paginator-bottom\" [alwaysShow]=\"alwaysShowPaginator\"\n (onPageChange)=\"onPageChange($event)\" [rowsPerPageOptions]=\"rowsPerPageOptions\" *ngIf=\"paginator && (paginatorPosition === 'bottom' || paginatorPosition =='both')\"\n [templateLeft]=\"paginatorLeftTemplate\" [templateRight]=\"paginatorRightTemplate\" [dropdownAppendTo]=\"paginatorDropdownAppendTo\"></p-paginator>\n <div *ngIf=\"summaryTemplate\" class=\"ui-treetable-summary ui-widget-header\">\n <ng-container *ngTemplateOutlet=\"summaryTemplate\"></ng-container>\n </div>\n\n <div #resizeHelper class=\"ui-column-resizer-helper ui-state-highlight\" style=\"display:none\" *ngIf=\"resizableColumns\"></div>\n\n <span #reorderIndicatorUp class=\"pi pi-arrow-down ui-table-reorder-indicator-up\" *ngIf=\"reorderableColumns\"></span>\n <span #reorderIndicatorDown class=\"pi pi-arrow-up ui-table-reorder-indicator-down\" *ngIf=\"reorderableColumns\"></span>\n </div>\n ",
|
|
providers: [TreeTableService]
|
|
}),
|
|
__metadata("design:paramtypes", [core_1.ElementRef, core_1.NgZone, TreeTableService])
|
|
], TreeTable);
|
|
return TreeTable;
|
|
}());
|
|
exports.TreeTable = TreeTable;
|
|
var TTBody = /** @class */ (function () {
|
|
function TTBody(tt) {
|
|
this.tt = tt;
|
|
}
|
|
__decorate([
|
|
core_1.Input("pTreeTableBody"),
|
|
__metadata("design:type", Array)
|
|
], TTBody.prototype, "columns", void 0);
|
|
__decorate([
|
|
core_1.Input("pTreeTableBodyTemplate"),
|
|
__metadata("design:type", core_1.TemplateRef)
|
|
], TTBody.prototype, "template", void 0);
|
|
TTBody = __decorate([
|
|
core_1.Component({
|
|
selector: '[pTreeTableBody]',
|
|
template: "\n <ng-template ngFor let-serializedNode let-rowIndex=\"index\" [ngForOf]=\"tt.serializedValue\" [ngForTrackBy]=\"tt.rowTrackBy\">\n <ng-container *ngIf=\"serializedNode.visible\">\n <ng-container *ngTemplateOutlet=\"template; context: {$implicit: serializedNode, node: serializedNode.node, rowData: serializedNode.node.data, columns: columns}\"></ng-container>\n </ng-container>\n </ng-template>\n <ng-container *ngIf=\"tt.isEmpty()\">\n <ng-container *ngTemplateOutlet=\"tt.emptyMessageTemplate; context: {$implicit: columns}\"></ng-container>\n </ng-container>\n "
|
|
}),
|
|
__metadata("design:paramtypes", [TreeTable])
|
|
], TTBody);
|
|
return TTBody;
|
|
}());
|
|
exports.TTBody = TTBody;
|
|
var TTScrollableView = /** @class */ (function () {
|
|
function TTScrollableView(tt, el, zone) {
|
|
var _this = this;
|
|
this.tt = tt;
|
|
this.el = el;
|
|
this.zone = zone;
|
|
this.loadingArray = [];
|
|
this.subscription = this.tt.tableService.uiUpdateSource$.subscribe(function () {
|
|
_this.zone.runOutsideAngular(function () {
|
|
setTimeout(function () {
|
|
_this.alignScrollBar();
|
|
_this.initialized = true;
|
|
if (_this.scrollLoadingTableViewChild && _this.scrollLoadingTableViewChild.nativeElement) {
|
|
_this.scrollLoadingTableViewChild.nativeElement.style.display = 'none';
|
|
}
|
|
}, 50);
|
|
});
|
|
});
|
|
if (this.tt.virtualScroll) {
|
|
this.totalRecordsSubscription = this.tt.tableService.totalRecordsSource$.subscribe(function () {
|
|
_this.zone.runOutsideAngular(function () {
|
|
setTimeout(function () {
|
|
_this.setVirtualScrollerHeight();
|
|
}, 50);
|
|
});
|
|
});
|
|
}
|
|
this.loadingArray = Array(this.tt.rows).fill(1);
|
|
this.initialized = false;
|
|
}
|
|
Object.defineProperty(TTScrollableView.prototype, "scrollHeight", {
|
|
get: function () {
|
|
return this._scrollHeight;
|
|
},
|
|
set: function (val) {
|
|
this._scrollHeight = val;
|
|
this.setScrollHeight();
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
TTScrollableView.prototype.ngAfterViewChecked = function () {
|
|
if (!this.initialized && this.el.nativeElement.offsetParent) {
|
|
this.alignScrollBar();
|
|
this.initialized = true;
|
|
}
|
|
};
|
|
TTScrollableView.prototype.ngAfterViewInit = function () {
|
|
this.bindEvents();
|
|
this.setScrollHeight();
|
|
this.alignScrollBar();
|
|
if (!this.frozen) {
|
|
if (this.tt.frozenColumns || this.tt.frozenBodyTemplate) {
|
|
domhandler_1.DomHandler.addClass(this.el.nativeElement, 'ui-treetable-unfrozen-view');
|
|
}
|
|
if (this.tt.frozenWidth) {
|
|
this.el.nativeElement.style.left = this.tt.frozenWidth;
|
|
this.el.nativeElement.style.width = 'calc(100% - ' + this.tt.frozenWidth + ')';
|
|
}
|
|
var frozenView = this.el.nativeElement.previousElementSibling;
|
|
if (frozenView) {
|
|
this.frozenSiblingBody = domhandler_1.DomHandler.findSingle(frozenView, '.ui-treetable-scrollable-body');
|
|
}
|
|
}
|
|
else {
|
|
this.scrollBodyViewChild.nativeElement.style.paddingBottom = domhandler_1.DomHandler.calculateScrollbarWidth() + 'px';
|
|
}
|
|
if (this.tt.virtualScroll) {
|
|
this.setVirtualScrollerHeight();
|
|
if (this.scrollLoadingTableViewChild && this.scrollLoadingTableViewChild.nativeElement) {
|
|
this.scrollLoadingTableViewChild.nativeElement.style.display = 'table';
|
|
}
|
|
}
|
|
};
|
|
TTScrollableView.prototype.bindEvents = function () {
|
|
var _this = this;
|
|
this.zone.runOutsideAngular(function () {
|
|
var scrollBarWidth = domhandler_1.DomHandler.calculateScrollbarWidth();
|
|
if (_this.scrollHeaderViewChild && _this.scrollHeaderViewChild.nativeElement) {
|
|
_this.headerScrollListener = _this.onHeaderScroll.bind(_this);
|
|
_this.scrollHeaderBoxViewChild.nativeElement.addEventListener('scroll', _this.headerScrollListener);
|
|
}
|
|
if (_this.scrollFooterViewChild && _this.scrollFooterViewChild.nativeElement) {
|
|
_this.footerScrollListener = _this.onFooterScroll.bind(_this);
|
|
_this.scrollFooterViewChild.nativeElement.addEventListener('scroll', _this.footerScrollListener);
|
|
}
|
|
if (!_this.frozen) {
|
|
_this.bodyScrollListener = _this.onBodyScroll.bind(_this);
|
|
_this.scrollBodyViewChild.nativeElement.addEventListener('scroll', _this.bodyScrollListener);
|
|
}
|
|
});
|
|
};
|
|
TTScrollableView.prototype.unbindEvents = function () {
|
|
if (this.scrollHeaderViewChild && this.scrollHeaderViewChild.nativeElement) {
|
|
this.scrollHeaderBoxViewChild.nativeElement.removeEventListener('scroll', this.headerScrollListener);
|
|
}
|
|
if (this.scrollFooterViewChild && this.scrollFooterViewChild.nativeElement) {
|
|
this.scrollFooterViewChild.nativeElement.removeEventListener('scroll', this.footerScrollListener);
|
|
}
|
|
this.scrollBodyViewChild.nativeElement.addEventListener('scroll', this.bodyScrollListener);
|
|
};
|
|
TTScrollableView.prototype.onHeaderScroll = function (event) {
|
|
this.scrollHeaderViewChild.nativeElement.scrollLeft = 0;
|
|
};
|
|
TTScrollableView.prototype.onFooterScroll = function (event) {
|
|
this.scrollFooterViewChild.nativeElement.scrollLeft = 0;
|
|
};
|
|
TTScrollableView.prototype.onBodyScroll = function (event) {
|
|
var _this = this;
|
|
if (this.scrollHeaderViewChild && this.scrollHeaderViewChild.nativeElement) {
|
|
this.scrollHeaderBoxViewChild.nativeElement.style.marginLeft = -1 * this.scrollBodyViewChild.nativeElement.scrollLeft + 'px';
|
|
}
|
|
if (this.scrollFooterViewChild && this.scrollFooterViewChild.nativeElement) {
|
|
this.scrollFooterBoxViewChild.nativeElement.style.marginLeft = -1 * this.scrollBodyViewChild.nativeElement.scrollLeft + 'px';
|
|
}
|
|
if (this.frozenSiblingBody) {
|
|
this.frozenSiblingBody.scrollTop = this.scrollBodyViewChild.nativeElement.scrollTop;
|
|
}
|
|
if (this.tt.virtualScroll) {
|
|
var viewport = domhandler_1.DomHandler.getOuterHeight(this.scrollBodyViewChild.nativeElement);
|
|
var tableHeight = domhandler_1.DomHandler.getOuterHeight(this.scrollTableViewChild.nativeElement);
|
|
var pageHeight_1 = this.tt.virtualRowHeight * this.tt.rows;
|
|
var virtualTableHeight = domhandler_1.DomHandler.getOuterHeight(this.virtualScrollerViewChild.nativeElement);
|
|
var pageCount = (virtualTableHeight / pageHeight_1) || 1;
|
|
var scrollBodyTop = this.scrollTableViewChild.nativeElement.style.top || '0';
|
|
if ((this.scrollBodyViewChild.nativeElement.scrollTop + viewport > parseFloat(scrollBodyTop) + tableHeight) || (this.scrollBodyViewChild.nativeElement.scrollTop < parseFloat(scrollBodyTop))) {
|
|
if (this.scrollLoadingTableViewChild && this.scrollLoadingTableViewChild.nativeElement) {
|
|
this.scrollLoadingTableViewChild.nativeElement.style.display = 'table';
|
|
this.scrollLoadingTableViewChild.nativeElement.style.top = this.scrollBodyViewChild.nativeElement.scrollTop + 'px';
|
|
}
|
|
var page_1 = Math.floor((this.scrollBodyViewChild.nativeElement.scrollTop * pageCount) / (this.scrollBodyViewChild.nativeElement.scrollHeight)) + 1;
|
|
this.tt.handleVirtualScroll({
|
|
page: page_1,
|
|
callback: function () {
|
|
if (_this.scrollLoadingTableViewChild && _this.scrollLoadingTableViewChild.nativeElement) {
|
|
_this.scrollLoadingTableViewChild.nativeElement.style.display = 'none';
|
|
}
|
|
_this.scrollTableViewChild.nativeElement.style.top = ((page_1 - 1) * pageHeight_1) + 'px';
|
|
if (_this.frozenSiblingBody) {
|
|
_this.frozenSiblingBody.children[0].style.top = _this.scrollTableViewChild.nativeElement.style.top;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
};
|
|
TTScrollableView.prototype.setScrollHeight = function () {
|
|
if (this.scrollHeight && this.scrollBodyViewChild && this.scrollBodyViewChild.nativeElement) {
|
|
if (this.scrollHeight.indexOf('%') !== -1) {
|
|
var relativeHeight = void 0;
|
|
this.scrollBodyViewChild.nativeElement.style.visibility = 'hidden';
|
|
this.scrollBodyViewChild.nativeElement.style.height = '100px'; //temporary height to calculate static height
|
|
var containerHeight = domhandler_1.DomHandler.getOuterHeight(this.tt.el.nativeElement.children[0]);
|
|
if (this.scrollHeight.includes("calc")) {
|
|
var percentHeight = parseInt(this.scrollHeight.slice(this.scrollHeight.indexOf("(") + 1, this.scrollHeight.indexOf("%")));
|
|
var diffValue = parseInt(this.scrollHeight.slice(this.scrollHeight.indexOf("-") + 1, this.scrollHeight.indexOf(")")));
|
|
relativeHeight = (domhandler_1.DomHandler.getOuterHeight(this.tt.el.nativeElement.parentElement) * percentHeight / 100) - diffValue;
|
|
}
|
|
else {
|
|
relativeHeight = domhandler_1.DomHandler.getOuterHeight(this.tt.el.nativeElement.parentElement) * parseInt(this.scrollHeight) / 100;
|
|
}
|
|
var staticHeight = containerHeight - 100; //total height of headers, footers, paginators
|
|
var scrollBodyHeight = (relativeHeight - staticHeight);
|
|
if (this.frozen) {
|
|
scrollBodyHeight -= domhandler_1.DomHandler.calculateScrollbarWidth();
|
|
}
|
|
this.scrollBodyViewChild.nativeElement.style.height = 'auto';
|
|
this.scrollBodyViewChild.nativeElement.style.maxHeight = scrollBodyHeight + 'px';
|
|
this.scrollBodyViewChild.nativeElement.style.visibility = 'visible';
|
|
}
|
|
else {
|
|
if (this.frozen)
|
|
this.scrollBodyViewChild.nativeElement.style.maxHeight = (parseInt(this.scrollHeight) - domhandler_1.DomHandler.calculateScrollbarWidth()) + 'px';
|
|
else
|
|
this.scrollBodyViewChild.nativeElement.style.maxHeight = this.scrollHeight;
|
|
}
|
|
}
|
|
};
|
|
TTScrollableView.prototype.setVirtualScrollerHeight = function () {
|
|
if (this.virtualScrollerViewChild.nativeElement) {
|
|
this.virtualScrollerViewChild.nativeElement.style.height = this.tt.totalRecords * this.tt.virtualRowHeight + 'px';
|
|
}
|
|
};
|
|
TTScrollableView.prototype.hasVerticalOverflow = function () {
|
|
return domhandler_1.DomHandler.getOuterHeight(this.scrollTableViewChild.nativeElement) > domhandler_1.DomHandler.getOuterHeight(this.scrollBodyViewChild.nativeElement);
|
|
};
|
|
TTScrollableView.prototype.alignScrollBar = function () {
|
|
if (!this.frozen) {
|
|
var scrollBarWidth = this.hasVerticalOverflow() ? domhandler_1.DomHandler.calculateScrollbarWidth() : 0;
|
|
this.scrollHeaderBoxViewChild.nativeElement.style.marginRight = scrollBarWidth + 'px';
|
|
if (this.scrollFooterBoxViewChild && this.scrollFooterBoxViewChild.nativeElement) {
|
|
this.scrollFooterBoxViewChild.nativeElement.style.marginRight = scrollBarWidth + 'px';
|
|
}
|
|
}
|
|
this.initialized = false;
|
|
};
|
|
TTScrollableView.prototype.ngOnDestroy = function () {
|
|
this.unbindEvents();
|
|
this.frozenSiblingBody = null;
|
|
if (this.subscription) {
|
|
this.subscription.unsubscribe();
|
|
}
|
|
if (this.totalRecordsSubscription) {
|
|
this.totalRecordsSubscription.unsubscribe();
|
|
}
|
|
this.initialized = false;
|
|
};
|
|
__decorate([
|
|
core_1.Input("ttScrollableView"),
|
|
__metadata("design:type", Array)
|
|
], TTScrollableView.prototype, "columns", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Boolean)
|
|
], TTScrollableView.prototype, "frozen", void 0);
|
|
__decorate([
|
|
core_1.ViewChild('scrollHeader'),
|
|
__metadata("design:type", core_1.ElementRef)
|
|
], TTScrollableView.prototype, "scrollHeaderViewChild", void 0);
|
|
__decorate([
|
|
core_1.ViewChild('scrollHeaderBox'),
|
|
__metadata("design:type", core_1.ElementRef)
|
|
], TTScrollableView.prototype, "scrollHeaderBoxViewChild", void 0);
|
|
__decorate([
|
|
core_1.ViewChild('scrollBody'),
|
|
__metadata("design:type", core_1.ElementRef)
|
|
], TTScrollableView.prototype, "scrollBodyViewChild", void 0);
|
|
__decorate([
|
|
core_1.ViewChild('scrollTable'),
|
|
__metadata("design:type", core_1.ElementRef)
|
|
], TTScrollableView.prototype, "scrollTableViewChild", void 0);
|
|
__decorate([
|
|
core_1.ViewChild('loadingTable'),
|
|
__metadata("design:type", core_1.ElementRef)
|
|
], TTScrollableView.prototype, "scrollLoadingTableViewChild", void 0);
|
|
__decorate([
|
|
core_1.ViewChild('scrollFooter'),
|
|
__metadata("design:type", core_1.ElementRef)
|
|
], TTScrollableView.prototype, "scrollFooterViewChild", void 0);
|
|
__decorate([
|
|
core_1.ViewChild('scrollFooterBox'),
|
|
__metadata("design:type", core_1.ElementRef)
|
|
], TTScrollableView.prototype, "scrollFooterBoxViewChild", void 0);
|
|
__decorate([
|
|
core_1.ViewChild('virtualScroller'),
|
|
__metadata("design:type", core_1.ElementRef)
|
|
], TTScrollableView.prototype, "virtualScrollerViewChild", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", String),
|
|
__metadata("design:paramtypes", [String])
|
|
], TTScrollableView.prototype, "scrollHeight", null);
|
|
TTScrollableView = __decorate([
|
|
core_1.Component({
|
|
selector: '[ttScrollableView]',
|
|
template: "\n <div #scrollHeader class=\"ui-treetable-scrollable-header ui-widget-header\">\n <div #scrollHeaderBox class=\"ui-treetable-scrollable-header-box\">\n <table class=\"ui-treetable-scrollable-header-table\">\n <ng-container *ngTemplateOutlet=\"frozen ? tt.frozenColGroupTemplate||tt.colGroupTemplate : tt.colGroupTemplate; context {$implicit: columns}\"></ng-container>\n <thead class=\"ui-treetable-thead\">\n <ng-container *ngTemplateOutlet=\"frozen ? tt.frozenHeaderTemplate||tt.headerTemplate : tt.headerTemplate; context {$implicit: columns}\"></ng-container>\n </thead>\n </table>\n </div>\n </div>\n <div #scrollBody class=\"ui-treetable-scrollable-body\">\n <table #scrollTable [ngClass]=\"{'ui-treetable-scrollable-body-table': true, 'ui-treetable-virtual-table': tt.virtualScroll}\">\n <ng-container *ngTemplateOutlet=\"frozen ? tt.frozenColGroupTemplate||tt.colGroupTemplate : tt.colGroupTemplate; context {$implicit: columns}\"></ng-container>\n <tbody class=\"ui-treetable-tbody\" [pTreeTableBody]=\"columns\" [pTreeTableBodyTemplate]=\"frozen ? tt.frozenBodyTemplate||tt.bodyTemplate : tt.bodyTemplate\"></tbody>\n </table>\n <table #loadingTable *ngIf=\"tt.virtualScroll && tt.loadingBodyTemplate != null\" [ngClass]=\"{'ui-treetable-scrollable-body-table ui-treetable-loading-virtual-table': true, 'ui-treetable-virtual-table': tt.virtualScroll}\">\n <tbody class=\"ui-treetable-tbody\">\n <ng-template ngFor [ngForOf]=\"loadingArray\">\n <ng-container *ngTemplateOutlet=\"tt.loadingBodyTemplate; context: {columns: columns}\"></ng-container>\n </ng-template>\n </tbody>\n </table>\n <div #virtualScroller class=\"ui-treetable-virtual-scroller\" *ngIf=\"tt.virtualScroll\"></div>\n </div>\n <div #scrollFooter *ngIf=\"tt.footerTemplate\" class=\"ui-treetable-scrollable-footer ui-widget-header\">\n <div #scrollFooterBox class=\"ui-treetable-scrollable-footer-box\">\n <table class=\"ui-treetable-scrollable-footer-table\">\n <ng-container *ngTemplateOutlet=\"frozen ? tt.frozenColGroupTemplate||tt.colGroupTemplate : tt.colGroupTemplate; context {$implicit: columns}\"></ng-container>\n <tfoot class=\"ui-treetable-tfoot\">\n <ng-container *ngTemplateOutlet=\"frozen ? tt.frozenFooterTemplate||tt.footerTemplate : tt.footerTemplate; context {$implicit: columns}\"></ng-container>\n </tfoot>\n </table>\n </div>\n </div>\n "
|
|
}),
|
|
__metadata("design:paramtypes", [TreeTable, core_1.ElementRef, core_1.NgZone])
|
|
], TTScrollableView);
|
|
return TTScrollableView;
|
|
}());
|
|
exports.TTScrollableView = TTScrollableView;
|
|
var TTSortableColumn = /** @class */ (function () {
|
|
function TTSortableColumn(tt) {
|
|
var _this = this;
|
|
this.tt = tt;
|
|
if (this.isEnabled()) {
|
|
this.subscription = this.tt.tableService.sortSource$.subscribe(function (sortMeta) {
|
|
_this.updateSortState();
|
|
});
|
|
}
|
|
}
|
|
TTSortableColumn.prototype.ngOnInit = function () {
|
|
if (this.isEnabled()) {
|
|
this.updateSortState();
|
|
}
|
|
};
|
|
TTSortableColumn.prototype.updateSortState = function () {
|
|
this.sorted = this.tt.isSorted(this.field);
|
|
};
|
|
TTSortableColumn.prototype.onClick = function (event) {
|
|
if (this.isEnabled()) {
|
|
this.updateSortState();
|
|
this.tt.sort({
|
|
originalEvent: event,
|
|
field: this.field
|
|
});
|
|
domhandler_1.DomHandler.clearSelection();
|
|
}
|
|
};
|
|
TTSortableColumn.prototype.onEnterKey = function (event) {
|
|
this.onClick(event);
|
|
};
|
|
TTSortableColumn.prototype.isEnabled = function () {
|
|
return this.ttSortableColumnDisabled !== true;
|
|
};
|
|
TTSortableColumn.prototype.ngOnDestroy = function () {
|
|
if (this.subscription) {
|
|
this.subscription.unsubscribe();
|
|
}
|
|
};
|
|
__decorate([
|
|
core_1.Input("ttSortableColumn"),
|
|
__metadata("design:type", String)
|
|
], TTSortableColumn.prototype, "field", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Boolean)
|
|
], TTSortableColumn.prototype, "ttSortableColumnDisabled", void 0);
|
|
__decorate([
|
|
core_1.HostListener('click', ['$event']),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [MouseEvent]),
|
|
__metadata("design:returntype", void 0)
|
|
], TTSortableColumn.prototype, "onClick", null);
|
|
__decorate([
|
|
core_1.HostListener('keydown.enter', ['$event']),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [MouseEvent]),
|
|
__metadata("design:returntype", void 0)
|
|
], TTSortableColumn.prototype, "onEnterKey", null);
|
|
TTSortableColumn = __decorate([
|
|
core_1.Directive({
|
|
selector: '[ttSortableColumn]',
|
|
host: {
|
|
'[class.ui-sortable-column]': 'isEnabled()',
|
|
'[class.ui-state-highlight]': 'sorted',
|
|
'[attr.tabindex]': 'isEnabled() ? "0" : null'
|
|
}
|
|
}),
|
|
__metadata("design:paramtypes", [TreeTable])
|
|
], TTSortableColumn);
|
|
return TTSortableColumn;
|
|
}());
|
|
exports.TTSortableColumn = TTSortableColumn;
|
|
var TTSortIcon = /** @class */ (function () {
|
|
function TTSortIcon(tt) {
|
|
var _this = this;
|
|
this.tt = tt;
|
|
this.subscription = this.tt.tableService.sortSource$.subscribe(function (sortMeta) {
|
|
_this.updateSortState();
|
|
});
|
|
}
|
|
TTSortIcon.prototype.ngOnInit = function () {
|
|
this.updateSortState();
|
|
};
|
|
TTSortIcon.prototype.onClick = function (event) {
|
|
event.preventDefault();
|
|
};
|
|
TTSortIcon.prototype.updateSortState = function () {
|
|
if (this.tt.sortMode === 'single') {
|
|
this.sortOrder = this.tt.isSorted(this.field) ? this.tt.sortOrder : 0;
|
|
}
|
|
else if (this.tt.sortMode === 'multiple') {
|
|
var sortMeta = this.tt.getSortMeta(this.field);
|
|
this.sortOrder = sortMeta ? sortMeta.order : 0;
|
|
}
|
|
};
|
|
TTSortIcon.prototype.ngOnDestroy = function () {
|
|
if (this.subscription) {
|
|
this.subscription.unsubscribe();
|
|
}
|
|
};
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", String)
|
|
], TTSortIcon.prototype, "field", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", String)
|
|
], TTSortIcon.prototype, "ariaLabelDesc", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", String)
|
|
], TTSortIcon.prototype, "ariaLabelAsc", void 0);
|
|
TTSortIcon = __decorate([
|
|
core_1.Component({
|
|
selector: 'p-treeTableSortIcon',
|
|
template: "\n <i class=\"ui-sortable-column-icon pi pi-fw\" [ngClass]=\"{'pi-sort-up': sortOrder === 1, 'pi-sort-down': sortOrder === -1, 'pi-sort': sortOrder === 0}\"></i>\n "
|
|
}),
|
|
__metadata("design:paramtypes", [TreeTable])
|
|
], TTSortIcon);
|
|
return TTSortIcon;
|
|
}());
|
|
exports.TTSortIcon = TTSortIcon;
|
|
var TTResizableColumn = /** @class */ (function () {
|
|
function TTResizableColumn(tt, el, zone) {
|
|
this.tt = tt;
|
|
this.el = el;
|
|
this.zone = zone;
|
|
}
|
|
TTResizableColumn.prototype.ngAfterViewInit = function () {
|
|
var _this = this;
|
|
if (this.isEnabled()) {
|
|
domhandler_1.DomHandler.addClass(this.el.nativeElement, 'ui-resizable-column');
|
|
this.resizer = document.createElement('span');
|
|
this.resizer.className = 'ui-column-resizer ui-clickable';
|
|
this.el.nativeElement.appendChild(this.resizer);
|
|
this.zone.runOutsideAngular(function () {
|
|
_this.resizerMouseDownListener = _this.onMouseDown.bind(_this);
|
|
_this.resizer.addEventListener('mousedown', _this.resizerMouseDownListener);
|
|
});
|
|
}
|
|
};
|
|
TTResizableColumn.prototype.bindDocumentEvents = function () {
|
|
var _this = this;
|
|
this.zone.runOutsideAngular(function () {
|
|
_this.documentMouseMoveListener = _this.onDocumentMouseMove.bind(_this);
|
|
document.addEventListener('mousemove', _this.documentMouseMoveListener);
|
|
_this.documentMouseUpListener = _this.onDocumentMouseUp.bind(_this);
|
|
document.addEventListener('mouseup', _this.documentMouseUpListener);
|
|
});
|
|
};
|
|
TTResizableColumn.prototype.unbindDocumentEvents = function () {
|
|
if (this.documentMouseMoveListener) {
|
|
document.removeEventListener('mousemove', this.documentMouseMoveListener);
|
|
this.documentMouseMoveListener = null;
|
|
}
|
|
if (this.documentMouseUpListener) {
|
|
document.removeEventListener('mouseup', this.documentMouseUpListener);
|
|
this.documentMouseUpListener = null;
|
|
}
|
|
};
|
|
TTResizableColumn.prototype.onMouseDown = function (event) {
|
|
this.tt.onColumnResizeBegin(event);
|
|
this.bindDocumentEvents();
|
|
};
|
|
TTResizableColumn.prototype.onDocumentMouseMove = function (event) {
|
|
this.tt.onColumnResize(event);
|
|
};
|
|
TTResizableColumn.prototype.onDocumentMouseUp = function (event) {
|
|
this.tt.onColumnResizeEnd(event, this.el.nativeElement);
|
|
this.unbindDocumentEvents();
|
|
};
|
|
TTResizableColumn.prototype.isEnabled = function () {
|
|
return this.ttResizableColumnDisabled !== true;
|
|
};
|
|
TTResizableColumn.prototype.ngOnDestroy = function () {
|
|
if (this.resizerMouseDownListener) {
|
|
this.resizer.removeEventListener('mousedown', this.resizerMouseDownListener);
|
|
}
|
|
this.unbindDocumentEvents();
|
|
};
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Boolean)
|
|
], TTResizableColumn.prototype, "ttResizableColumnDisabled", void 0);
|
|
TTResizableColumn = __decorate([
|
|
core_1.Directive({
|
|
selector: '[ttResizableColumn]'
|
|
}),
|
|
__metadata("design:paramtypes", [TreeTable, core_1.ElementRef, core_1.NgZone])
|
|
], TTResizableColumn);
|
|
return TTResizableColumn;
|
|
}());
|
|
exports.TTResizableColumn = TTResizableColumn;
|
|
var TTReorderableColumn = /** @class */ (function () {
|
|
function TTReorderableColumn(tt, el, zone) {
|
|
this.tt = tt;
|
|
this.el = el;
|
|
this.zone = zone;
|
|
}
|
|
TTReorderableColumn.prototype.ngAfterViewInit = function () {
|
|
if (this.isEnabled()) {
|
|
this.bindEvents();
|
|
}
|
|
};
|
|
TTReorderableColumn.prototype.bindEvents = function () {
|
|
var _this = this;
|
|
this.zone.runOutsideAngular(function () {
|
|
_this.mouseDownListener = _this.onMouseDown.bind(_this);
|
|
_this.el.nativeElement.addEventListener('mousedown', _this.mouseDownListener);
|
|
_this.dragStartListener = _this.onDragStart.bind(_this);
|
|
_this.el.nativeElement.addEventListener('dragstart', _this.dragStartListener);
|
|
_this.dragOverListener = _this.onDragEnter.bind(_this);
|
|
_this.el.nativeElement.addEventListener('dragover', _this.dragOverListener);
|
|
_this.dragEnterListener = _this.onDragEnter.bind(_this);
|
|
_this.el.nativeElement.addEventListener('dragenter', _this.dragEnterListener);
|
|
_this.dragLeaveListener = _this.onDragLeave.bind(_this);
|
|
_this.el.nativeElement.addEventListener('dragleave', _this.dragLeaveListener);
|
|
});
|
|
};
|
|
TTReorderableColumn.prototype.unbindEvents = function () {
|
|
if (this.mouseDownListener) {
|
|
document.removeEventListener('mousedown', this.mouseDownListener);
|
|
this.mouseDownListener = null;
|
|
}
|
|
if (this.dragOverListener) {
|
|
document.removeEventListener('dragover', this.dragOverListener);
|
|
this.dragOverListener = null;
|
|
}
|
|
if (this.dragEnterListener) {
|
|
document.removeEventListener('dragenter', this.dragEnterListener);
|
|
this.dragEnterListener = null;
|
|
}
|
|
if (this.dragEnterListener) {
|
|
document.removeEventListener('dragenter', this.dragEnterListener);
|
|
this.dragEnterListener = null;
|
|
}
|
|
if (this.dragLeaveListener) {
|
|
document.removeEventListener('dragleave', this.dragLeaveListener);
|
|
this.dragLeaveListener = null;
|
|
}
|
|
};
|
|
TTReorderableColumn.prototype.onMouseDown = function (event) {
|
|
if (event.target.nodeName === 'INPUT' || domhandler_1.DomHandler.hasClass(event.target, 'ui-column-resizer'))
|
|
this.el.nativeElement.draggable = false;
|
|
else
|
|
this.el.nativeElement.draggable = true;
|
|
};
|
|
TTReorderableColumn.prototype.onDragStart = function (event) {
|
|
this.tt.onColumnDragStart(event, this.el.nativeElement);
|
|
};
|
|
TTReorderableColumn.prototype.onDragOver = function (event) {
|
|
event.preventDefault();
|
|
};
|
|
TTReorderableColumn.prototype.onDragEnter = function (event) {
|
|
this.tt.onColumnDragEnter(event, this.el.nativeElement);
|
|
};
|
|
TTReorderableColumn.prototype.onDragLeave = function (event) {
|
|
this.tt.onColumnDragLeave(event);
|
|
};
|
|
TTReorderableColumn.prototype.onDrop = function (event) {
|
|
if (this.isEnabled()) {
|
|
this.tt.onColumnDrop(event, this.el.nativeElement);
|
|
}
|
|
};
|
|
TTReorderableColumn.prototype.isEnabled = function () {
|
|
return this.ttReorderableColumnDisabled !== true;
|
|
};
|
|
TTReorderableColumn.prototype.ngOnDestroy = function () {
|
|
this.unbindEvents();
|
|
};
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Boolean)
|
|
], TTReorderableColumn.prototype, "ttReorderableColumnDisabled", void 0);
|
|
__decorate([
|
|
core_1.HostListener('drop', ['$event']),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Object]),
|
|
__metadata("design:returntype", void 0)
|
|
], TTReorderableColumn.prototype, "onDrop", null);
|
|
TTReorderableColumn = __decorate([
|
|
core_1.Directive({
|
|
selector: '[ttReorderableColumn]'
|
|
}),
|
|
__metadata("design:paramtypes", [TreeTable, core_1.ElementRef, core_1.NgZone])
|
|
], TTReorderableColumn);
|
|
return TTReorderableColumn;
|
|
}());
|
|
exports.TTReorderableColumn = TTReorderableColumn;
|
|
var TTSelectableRow = /** @class */ (function () {
|
|
function TTSelectableRow(tt, tableService) {
|
|
var _this = this;
|
|
this.tt = tt;
|
|
this.tableService = tableService;
|
|
if (this.isEnabled()) {
|
|
this.subscription = this.tt.tableService.selectionSource$.subscribe(function () {
|
|
_this.selected = _this.tt.isSelected(_this.rowNode.node);
|
|
});
|
|
}
|
|
}
|
|
TTSelectableRow.prototype.ngOnInit = function () {
|
|
if (this.isEnabled()) {
|
|
this.selected = this.tt.isSelected(this.rowNode.node);
|
|
}
|
|
};
|
|
TTSelectableRow.prototype.onClick = function (event) {
|
|
if (this.isEnabled()) {
|
|
this.tt.handleRowClick({
|
|
originalEvent: event,
|
|
rowNode: this.rowNode
|
|
});
|
|
}
|
|
};
|
|
TTSelectableRow.prototype.onEnterKey = function (event) {
|
|
this.onClick(event);
|
|
};
|
|
TTSelectableRow.prototype.onTouchEnd = function (event) {
|
|
if (this.isEnabled()) {
|
|
this.tt.handleRowTouchEnd(event);
|
|
}
|
|
};
|
|
TTSelectableRow.prototype.isEnabled = function () {
|
|
return this.ttSelectableRowDisabled !== true;
|
|
};
|
|
TTSelectableRow.prototype.ngOnDestroy = function () {
|
|
if (this.subscription) {
|
|
this.subscription.unsubscribe();
|
|
}
|
|
};
|
|
__decorate([
|
|
core_1.Input("ttSelectableRow"),
|
|
__metadata("design:type", Object)
|
|
], TTSelectableRow.prototype, "rowNode", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Boolean)
|
|
], TTSelectableRow.prototype, "ttSelectableRowDisabled", void 0);
|
|
__decorate([
|
|
core_1.HostListener('click', ['$event']),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Event]),
|
|
__metadata("design:returntype", void 0)
|
|
], TTSelectableRow.prototype, "onClick", null);
|
|
__decorate([
|
|
core_1.HostListener('keydown.enter', ['$event']),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Event]),
|
|
__metadata("design:returntype", void 0)
|
|
], TTSelectableRow.prototype, "onEnterKey", null);
|
|
__decorate([
|
|
core_1.HostListener('touchend', ['$event']),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Event]),
|
|
__metadata("design:returntype", void 0)
|
|
], TTSelectableRow.prototype, "onTouchEnd", null);
|
|
TTSelectableRow = __decorate([
|
|
core_1.Directive({
|
|
selector: '[ttSelectableRow]',
|
|
host: {
|
|
'[class.ui-state-highlight]': 'selected'
|
|
}
|
|
}),
|
|
__metadata("design:paramtypes", [TreeTable, TreeTableService])
|
|
], TTSelectableRow);
|
|
return TTSelectableRow;
|
|
}());
|
|
exports.TTSelectableRow = TTSelectableRow;
|
|
var TTSelectableRowDblClick = /** @class */ (function () {
|
|
function TTSelectableRowDblClick(tt, tableService) {
|
|
var _this = this;
|
|
this.tt = tt;
|
|
this.tableService = tableService;
|
|
if (this.isEnabled()) {
|
|
this.subscription = this.tt.tableService.selectionSource$.subscribe(function () {
|
|
_this.selected = _this.tt.isSelected(_this.rowNode.node);
|
|
});
|
|
}
|
|
}
|
|
TTSelectableRowDblClick.prototype.ngOnInit = function () {
|
|
if (this.isEnabled()) {
|
|
this.selected = this.tt.isSelected(this.rowNode.node);
|
|
}
|
|
};
|
|
TTSelectableRowDblClick.prototype.onClick = function (event) {
|
|
if (this.isEnabled()) {
|
|
this.tt.handleRowClick({
|
|
originalEvent: event,
|
|
rowNode: this.rowNode
|
|
});
|
|
}
|
|
};
|
|
TTSelectableRowDblClick.prototype.isEnabled = function () {
|
|
return this.ttSelectableRowDisabled !== true;
|
|
};
|
|
TTSelectableRowDblClick.prototype.ngOnDestroy = function () {
|
|
if (this.subscription) {
|
|
this.subscription.unsubscribe();
|
|
}
|
|
};
|
|
__decorate([
|
|
core_1.Input("ttSelectableRowDblClick"),
|
|
__metadata("design:type", Object)
|
|
], TTSelectableRowDblClick.prototype, "rowNode", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Boolean)
|
|
], TTSelectableRowDblClick.prototype, "ttSelectableRowDisabled", void 0);
|
|
__decorate([
|
|
core_1.HostListener('dblclick', ['$event']),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Event]),
|
|
__metadata("design:returntype", void 0)
|
|
], TTSelectableRowDblClick.prototype, "onClick", null);
|
|
TTSelectableRowDblClick = __decorate([
|
|
core_1.Directive({
|
|
selector: '[ttSelectableRowDblClick]',
|
|
host: {
|
|
'[class.ui-state-highlight]': 'selected'
|
|
}
|
|
}),
|
|
__metadata("design:paramtypes", [TreeTable, TreeTableService])
|
|
], TTSelectableRowDblClick);
|
|
return TTSelectableRowDblClick;
|
|
}());
|
|
exports.TTSelectableRowDblClick = TTSelectableRowDblClick;
|
|
var TTContextMenuRow = /** @class */ (function () {
|
|
function TTContextMenuRow(tt, tableService) {
|
|
var _this = this;
|
|
this.tt = tt;
|
|
this.tableService = tableService;
|
|
if (this.isEnabled()) {
|
|
this.subscription = this.tt.tableService.contextMenuSource$.subscribe(function (node) {
|
|
_this.selected = _this.tt.equals(_this.rowNode.node, node);
|
|
});
|
|
}
|
|
}
|
|
TTContextMenuRow.prototype.onContextMenu = function (event) {
|
|
if (this.isEnabled()) {
|
|
this.tt.handleRowRightClick({
|
|
originalEvent: event,
|
|
rowNode: this.rowNode
|
|
});
|
|
event.preventDefault();
|
|
}
|
|
};
|
|
TTContextMenuRow.prototype.isEnabled = function () {
|
|
return this.ttContextMenuRowDisabled !== true;
|
|
};
|
|
TTContextMenuRow.prototype.ngOnDestroy = function () {
|
|
if (this.subscription) {
|
|
this.subscription.unsubscribe();
|
|
}
|
|
};
|
|
__decorate([
|
|
core_1.Input("ttContextMenuRow"),
|
|
__metadata("design:type", Object)
|
|
], TTContextMenuRow.prototype, "rowNode", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Boolean)
|
|
], TTContextMenuRow.prototype, "ttContextMenuRowDisabled", void 0);
|
|
__decorate([
|
|
core_1.HostListener('contextmenu', ['$event']),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [Event]),
|
|
__metadata("design:returntype", void 0)
|
|
], TTContextMenuRow.prototype, "onContextMenu", null);
|
|
TTContextMenuRow = __decorate([
|
|
core_1.Directive({
|
|
selector: '[ttContextMenuRow]',
|
|
host: {
|
|
'[class.ui-contextmenu-selected]': 'selected'
|
|
}
|
|
}),
|
|
__metadata("design:paramtypes", [TreeTable, TreeTableService])
|
|
], TTContextMenuRow);
|
|
return TTContextMenuRow;
|
|
}());
|
|
exports.TTContextMenuRow = TTContextMenuRow;
|
|
var TTCheckbox = /** @class */ (function () {
|
|
function TTCheckbox(tt, tableService) {
|
|
var _this = this;
|
|
this.tt = tt;
|
|
this.tableService = tableService;
|
|
this.subscription = this.tt.tableService.selectionSource$.subscribe(function () {
|
|
_this.checked = _this.tt.isSelected(_this.rowNode.node);
|
|
});
|
|
}
|
|
TTCheckbox.prototype.ngOnInit = function () {
|
|
this.checked = this.tt.isSelected(this.rowNode.node);
|
|
};
|
|
TTCheckbox.prototype.onClick = function (event) {
|
|
if (!this.disabled) {
|
|
this.tt.toggleNodeWithCheckbox({
|
|
originalEvent: event,
|
|
rowNode: this.rowNode
|
|
});
|
|
}
|
|
domhandler_1.DomHandler.clearSelection();
|
|
};
|
|
TTCheckbox.prototype.onFocus = function () {
|
|
domhandler_1.DomHandler.addClass(this.boxViewChild.nativeElement, 'ui-state-focus');
|
|
};
|
|
TTCheckbox.prototype.onBlur = function () {
|
|
domhandler_1.DomHandler.removeClass(this.boxViewChild.nativeElement, 'ui-state-focus');
|
|
};
|
|
TTCheckbox.prototype.ngOnDestroy = function () {
|
|
if (this.subscription) {
|
|
this.subscription.unsubscribe();
|
|
}
|
|
};
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Boolean)
|
|
], TTCheckbox.prototype, "disabled", void 0);
|
|
__decorate([
|
|
core_1.Input("value"),
|
|
__metadata("design:type", Object)
|
|
], TTCheckbox.prototype, "rowNode", void 0);
|
|
__decorate([
|
|
core_1.ViewChild('box'),
|
|
__metadata("design:type", core_1.ElementRef)
|
|
], TTCheckbox.prototype, "boxViewChild", void 0);
|
|
TTCheckbox = __decorate([
|
|
core_1.Component({
|
|
selector: 'p-treeTableCheckbox',
|
|
template: "\n <div class=\"ui-chkbox ui-treetable-chkbox ui-widget\" (click)=\"onClick($event)\">\n <div class=\"ui-helper-hidden-accessible\">\n <input type=\"checkbox\" [checked]=\"checked\" (focus)=\"onFocus()\" (blur)=\"onBlur()\">\n </div>\n <div #box [ngClass]=\"{'ui-chkbox-box ui-widget ui-state-default':true,\n 'ui-state-active':checked, 'ui-state-disabled':disabled}\">\n <span class=\"ui-chkbox-icon ui-clickable pi\" [ngClass]=\"{'pi-check':checked, 'pi-minus': rowNode.node.partialSelected}\"></span>\n </div>\n </div>\n "
|
|
}),
|
|
__metadata("design:paramtypes", [TreeTable, TreeTableService])
|
|
], TTCheckbox);
|
|
return TTCheckbox;
|
|
}());
|
|
exports.TTCheckbox = TTCheckbox;
|
|
var TTHeaderCheckbox = /** @class */ (function () {
|
|
function TTHeaderCheckbox(tt, tableService) {
|
|
var _this = this;
|
|
this.tt = tt;
|
|
this.tableService = tableService;
|
|
this.valueChangeSubscription = this.tt.tableService.uiUpdateSource$.subscribe(function () {
|
|
_this.checked = _this.updateCheckedState();
|
|
});
|
|
this.selectionChangeSubscription = this.tt.tableService.selectionSource$.subscribe(function () {
|
|
_this.checked = _this.updateCheckedState();
|
|
});
|
|
}
|
|
TTHeaderCheckbox.prototype.ngOnInit = function () {
|
|
this.checked = this.updateCheckedState();
|
|
};
|
|
TTHeaderCheckbox.prototype.onClick = function (event, checked) {
|
|
if (this.tt.value && this.tt.value.length > 0) {
|
|
this.tt.toggleNodesWithCheckbox(event, !checked);
|
|
}
|
|
domhandler_1.DomHandler.clearSelection();
|
|
};
|
|
TTHeaderCheckbox.prototype.onFocus = function () {
|
|
domhandler_1.DomHandler.addClass(this.boxViewChild.nativeElement, 'ui-state-focus');
|
|
};
|
|
TTHeaderCheckbox.prototype.onBlur = function () {
|
|
domhandler_1.DomHandler.removeClass(this.boxViewChild.nativeElement, 'ui-state-focus');
|
|
};
|
|
TTHeaderCheckbox.prototype.ngOnDestroy = function () {
|
|
if (this.selectionChangeSubscription) {
|
|
this.selectionChangeSubscription.unsubscribe();
|
|
}
|
|
if (this.valueChangeSubscription) {
|
|
this.valueChangeSubscription.unsubscribe();
|
|
}
|
|
};
|
|
TTHeaderCheckbox.prototype.updateCheckedState = function () {
|
|
var checked;
|
|
var data = this.tt.filteredNodes || this.tt.value;
|
|
if (data) {
|
|
for (var _i = 0, data_2 = data; _i < data_2.length; _i++) {
|
|
var node = data_2[_i];
|
|
if (this.tt.isSelected(node)) {
|
|
checked = true;
|
|
}
|
|
else {
|
|
checked = false;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
checked = false;
|
|
}
|
|
return checked;
|
|
};
|
|
__decorate([
|
|
core_1.ViewChild('box'),
|
|
__metadata("design:type", core_1.ElementRef)
|
|
], TTHeaderCheckbox.prototype, "boxViewChild", void 0);
|
|
TTHeaderCheckbox = __decorate([
|
|
core_1.Component({
|
|
selector: 'p-treeTableHeaderCheckbox',
|
|
template: "\n <div class=\"ui-chkbox ui-treetable-header-chkbox ui-widget\" (click)=\"onClick($event, cb.checked)\">\n <div class=\"ui-helper-hidden-accessible\">\n <input #cb type=\"checkbox\" [checked]=\"checked\" (focus)=\"onFocus()\" (blur)=\"onBlur()\" [disabled]=\"!tt.value||tt.value.length === 0\">\n </div>\n <div #box [ngClass]=\"{'ui-chkbox-box ui-widget ui-state-default':true,\n 'ui-state-active':checked, 'ui-state-disabled': (!tt.value || tt.value.length === 0)}\">\n <span class=\"ui-chkbox-icon ui-clickable\" [ngClass]=\"{'pi pi-check':checked}\"></span>\n </div>\n </div>\n "
|
|
}),
|
|
__metadata("design:paramtypes", [TreeTable, TreeTableService])
|
|
], TTHeaderCheckbox);
|
|
return TTHeaderCheckbox;
|
|
}());
|
|
exports.TTHeaderCheckbox = TTHeaderCheckbox;
|
|
var TTEditableColumn = /** @class */ (function () {
|
|
function TTEditableColumn(tt, el, zone) {
|
|
this.tt = tt;
|
|
this.el = el;
|
|
this.zone = zone;
|
|
}
|
|
TTEditableColumn.prototype.ngAfterViewInit = function () {
|
|
if (this.isEnabled()) {
|
|
domhandler_1.DomHandler.addClass(this.el.nativeElement, 'ui-editable-column');
|
|
}
|
|
};
|
|
TTEditableColumn.prototype.onClick = function (event) {
|
|
if (this.isEnabled()) {
|
|
this.tt.editingCellClick = true;
|
|
if (this.tt.editingCell) {
|
|
if (this.tt.editingCell !== this.el.nativeElement) {
|
|
if (!this.tt.isEditingCellValid()) {
|
|
return;
|
|
}
|
|
domhandler_1.DomHandler.removeClass(this.tt.editingCell, 'ui-editing-cell');
|
|
this.openCell();
|
|
}
|
|
}
|
|
else {
|
|
this.openCell();
|
|
}
|
|
}
|
|
};
|
|
TTEditableColumn.prototype.openCell = function () {
|
|
var _this = this;
|
|
this.tt.updateEditingCell(this.el.nativeElement);
|
|
domhandler_1.DomHandler.addClass(this.el.nativeElement, 'ui-editing-cell');
|
|
this.tt.onEditInit.emit({ field: this.field, data: this.data });
|
|
this.zone.runOutsideAngular(function () {
|
|
setTimeout(function () {
|
|
var focusable = domhandler_1.DomHandler.findSingle(_this.el.nativeElement, 'input, textarea');
|
|
if (focusable) {
|
|
focusable.focus();
|
|
}
|
|
}, 50);
|
|
});
|
|
};
|
|
TTEditableColumn.prototype.closeEditingCell = function () {
|
|
domhandler_1.DomHandler.removeClass(this.tt.editingCell, 'ui-editing-cell');
|
|
this.tt.editingCell = null;
|
|
this.tt.unbindDocumentEditListener();
|
|
};
|
|
TTEditableColumn.prototype.onKeyDown = function (event) {
|
|
if (this.isEnabled()) {
|
|
//enter
|
|
if (event.keyCode == 13) {
|
|
if (this.tt.isEditingCellValid()) {
|
|
domhandler_1.DomHandler.removeClass(this.tt.editingCell, 'ui-editing-cell');
|
|
this.closeEditingCell();
|
|
this.tt.onEditComplete.emit({ field: this.field, data: this.data });
|
|
}
|
|
event.preventDefault();
|
|
}
|
|
//escape
|
|
else if (event.keyCode == 27) {
|
|
if (this.tt.isEditingCellValid()) {
|
|
domhandler_1.DomHandler.removeClass(this.tt.editingCell, 'ui-editing-cell');
|
|
this.closeEditingCell();
|
|
this.tt.onEditCancel.emit({ field: this.field, data: this.data });
|
|
}
|
|
event.preventDefault();
|
|
}
|
|
//tab
|
|
else if (event.keyCode == 9) {
|
|
this.tt.onEditComplete.emit({ field: this.field, data: this.data });
|
|
if (event.shiftKey)
|
|
this.moveToPreviousCell(event);
|
|
else
|
|
this.moveToNextCell(event);
|
|
}
|
|
}
|
|
};
|
|
TTEditableColumn.prototype.findCell = function (element) {
|
|
if (element) {
|
|
var cell = element;
|
|
while (cell && !domhandler_1.DomHandler.hasClass(cell, 'ui-editing-cell')) {
|
|
cell = cell.parentElement;
|
|
}
|
|
return cell;
|
|
}
|
|
else {
|
|
return null;
|
|
}
|
|
};
|
|
TTEditableColumn.prototype.moveToPreviousCell = function (event) {
|
|
var currentCell = this.findCell(event.target);
|
|
var row = currentCell.parentElement;
|
|
var targetCell = this.findPreviousEditableColumn(currentCell);
|
|
if (targetCell) {
|
|
domhandler_1.DomHandler.invokeElementMethod(targetCell, 'click');
|
|
event.preventDefault();
|
|
}
|
|
};
|
|
TTEditableColumn.prototype.moveToNextCell = function (event) {
|
|
var currentCell = this.findCell(event.target);
|
|
var row = currentCell.parentElement;
|
|
var targetCell = this.findNextEditableColumn(currentCell);
|
|
if (targetCell) {
|
|
domhandler_1.DomHandler.invokeElementMethod(targetCell, 'click');
|
|
event.preventDefault();
|
|
}
|
|
};
|
|
TTEditableColumn.prototype.findPreviousEditableColumn = function (cell) {
|
|
var prevCell = cell.previousElementSibling;
|
|
if (!prevCell) {
|
|
var previousRow = cell.parentElement.previousElementSibling;
|
|
if (previousRow) {
|
|
prevCell = previousRow.lastElementChild;
|
|
}
|
|
}
|
|
if (prevCell) {
|
|
if (domhandler_1.DomHandler.hasClass(prevCell, 'ui-editable-column'))
|
|
return prevCell;
|
|
else
|
|
return this.findPreviousEditableColumn(prevCell);
|
|
}
|
|
else {
|
|
return null;
|
|
}
|
|
};
|
|
TTEditableColumn.prototype.findNextEditableColumn = function (cell) {
|
|
var nextCell = cell.nextElementSibling;
|
|
if (!nextCell) {
|
|
var nextRow = cell.parentElement.nextElementSibling;
|
|
if (nextRow) {
|
|
nextCell = nextRow.firstElementChild;
|
|
}
|
|
}
|
|
if (nextCell) {
|
|
if (domhandler_1.DomHandler.hasClass(nextCell, 'ui-editable-column'))
|
|
return nextCell;
|
|
else
|
|
return this.findNextEditableColumn(nextCell);
|
|
}
|
|
else {
|
|
return null;
|
|
}
|
|
};
|
|
TTEditableColumn.prototype.isEnabled = function () {
|
|
return this.ttEditableColumnDisabled !== true;
|
|
};
|
|
__decorate([
|
|
core_1.Input("ttEditableColumn"),
|
|
__metadata("design:type", Object)
|
|
], TTEditableColumn.prototype, "data", void 0);
|
|
__decorate([
|
|
core_1.Input("ttEditableColumnField"),
|
|
__metadata("design:type", Object)
|
|
], TTEditableColumn.prototype, "field", void 0);
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Boolean)
|
|
], TTEditableColumn.prototype, "ttEditableColumnDisabled", void 0);
|
|
__decorate([
|
|
core_1.HostListener('click', ['$event']),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [MouseEvent]),
|
|
__metadata("design:returntype", void 0)
|
|
], TTEditableColumn.prototype, "onClick", null);
|
|
__decorate([
|
|
core_1.HostListener('keydown', ['$event']),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [KeyboardEvent]),
|
|
__metadata("design:returntype", void 0)
|
|
], TTEditableColumn.prototype, "onKeyDown", null);
|
|
TTEditableColumn = __decorate([
|
|
core_1.Directive({
|
|
selector: '[ttEditableColumn]'
|
|
}),
|
|
__metadata("design:paramtypes", [TreeTable, core_1.ElementRef, core_1.NgZone])
|
|
], TTEditableColumn);
|
|
return TTEditableColumn;
|
|
}());
|
|
exports.TTEditableColumn = TTEditableColumn;
|
|
var TreeTableCellEditor = /** @class */ (function () {
|
|
function TreeTableCellEditor(tt, editableColumn) {
|
|
this.tt = tt;
|
|
this.editableColumn = editableColumn;
|
|
}
|
|
TreeTableCellEditor.prototype.ngAfterContentInit = function () {
|
|
var _this = this;
|
|
this.templates.forEach(function (item) {
|
|
switch (item.getType()) {
|
|
case 'input':
|
|
_this.inputTemplate = item.template;
|
|
break;
|
|
case 'output':
|
|
_this.outputTemplate = item.template;
|
|
break;
|
|
}
|
|
});
|
|
};
|
|
__decorate([
|
|
core_1.ContentChildren(shared_1.PrimeTemplate),
|
|
__metadata("design:type", core_1.QueryList)
|
|
], TreeTableCellEditor.prototype, "templates", void 0);
|
|
TreeTableCellEditor = __decorate([
|
|
core_1.Component({
|
|
selector: 'p-treeTableCellEditor',
|
|
template: "\n <ng-container *ngIf=\"tt.editingCell === editableColumn.el.nativeElement\">\n <ng-container *ngTemplateOutlet=\"inputTemplate\"></ng-container>\n </ng-container>\n <ng-container *ngIf=\"!tt.editingCell || tt.editingCell !== editableColumn.el.nativeElement\">\n <ng-container *ngTemplateOutlet=\"outputTemplate\"></ng-container>\n </ng-container>\n "
|
|
}),
|
|
__metadata("design:paramtypes", [TreeTable, TTEditableColumn])
|
|
], TreeTableCellEditor);
|
|
return TreeTableCellEditor;
|
|
}());
|
|
exports.TreeTableCellEditor = TreeTableCellEditor;
|
|
var TTRow = /** @class */ (function () {
|
|
function TTRow(tt, el, zone) {
|
|
this.tt = tt;
|
|
this.el = el;
|
|
this.zone = zone;
|
|
}
|
|
TTRow.prototype.onKeyDown = function (event) {
|
|
switch (event.which) {
|
|
//down arrow
|
|
case 40:
|
|
var nextRow = this.el.nativeElement.nextElementSibling;
|
|
if (nextRow) {
|
|
nextRow.focus();
|
|
}
|
|
event.preventDefault();
|
|
break;
|
|
//down arrow
|
|
case 38:
|
|
var prevRow = this.el.nativeElement.previousElementSibling;
|
|
if (prevRow) {
|
|
prevRow.focus();
|
|
}
|
|
event.preventDefault();
|
|
break;
|
|
//left arrow
|
|
case 37:
|
|
if (this.rowNode.node.expanded) {
|
|
this.tt.toggleRowIndex = domhandler_1.DomHandler.index(this.el.nativeElement);
|
|
this.rowNode.node.expanded = false;
|
|
this.tt.onNodeCollapse.emit({
|
|
originalEvent: event,
|
|
node: this.rowNode.node
|
|
});
|
|
this.tt.updateSerializedValue();
|
|
this.tt.tableService.onUIUpdate(this.tt.value);
|
|
this.restoreFocus();
|
|
}
|
|
break;
|
|
//right arrow
|
|
case 39:
|
|
if (!this.rowNode.node.expanded) {
|
|
this.tt.toggleRowIndex = domhandler_1.DomHandler.index(this.el.nativeElement);
|
|
this.rowNode.node.expanded = true;
|
|
this.tt.onNodeExpand.emit({
|
|
originalEvent: event,
|
|
node: this.rowNode.node
|
|
});
|
|
this.tt.updateSerializedValue();
|
|
this.tt.tableService.onUIUpdate(this.tt.value);
|
|
this.restoreFocus();
|
|
}
|
|
break;
|
|
}
|
|
};
|
|
TTRow.prototype.restoreFocus = function () {
|
|
var _this = this;
|
|
this.zone.runOutsideAngular(function () {
|
|
setTimeout(function () {
|
|
var row = domhandler_1.DomHandler.findSingle(_this.tt.containerViewChild.nativeElement, '.ui-treetable-tbody').children[_this.tt.toggleRowIndex];
|
|
if (row) {
|
|
row.focus();
|
|
}
|
|
}, 25);
|
|
});
|
|
};
|
|
__decorate([
|
|
core_1.Input('ttRow'),
|
|
__metadata("design:type", Object)
|
|
], TTRow.prototype, "rowNode", void 0);
|
|
__decorate([
|
|
core_1.HostListener('keydown', ['$event']),
|
|
__metadata("design:type", Function),
|
|
__metadata("design:paramtypes", [KeyboardEvent]),
|
|
__metadata("design:returntype", void 0)
|
|
], TTRow.prototype, "onKeyDown", null);
|
|
TTRow = __decorate([
|
|
core_1.Directive({
|
|
selector: '[ttRow]',
|
|
host: {
|
|
'[attr.tabindex]': '"0"'
|
|
}
|
|
}),
|
|
__metadata("design:paramtypes", [TreeTable, core_1.ElementRef, core_1.NgZone])
|
|
], TTRow);
|
|
return TTRow;
|
|
}());
|
|
exports.TTRow = TTRow;
|
|
var TreeTableToggler = /** @class */ (function () {
|
|
function TreeTableToggler(tt) {
|
|
this.tt = tt;
|
|
}
|
|
TreeTableToggler.prototype.onClick = function (event) {
|
|
this.rowNode.node.expanded = !this.rowNode.node.expanded;
|
|
if (this.rowNode.node.expanded) {
|
|
this.tt.onNodeExpand.emit({
|
|
originalEvent: event,
|
|
node: this.rowNode.node
|
|
});
|
|
}
|
|
else {
|
|
this.tt.onNodeCollapse.emit({
|
|
originalEvent: event,
|
|
node: this.rowNode.node
|
|
});
|
|
}
|
|
this.tt.updateSerializedValue();
|
|
this.tt.tableService.onUIUpdate(this.tt.value);
|
|
event.preventDefault();
|
|
};
|
|
__decorate([
|
|
core_1.Input(),
|
|
__metadata("design:type", Object)
|
|
], TreeTableToggler.prototype, "rowNode", void 0);
|
|
TreeTableToggler = __decorate([
|
|
core_1.Component({
|
|
selector: 'p-treeTableToggler',
|
|
template: "\n <a class=\"ui-treetable-toggler ui-unselectable-text\" *ngIf=\"rowNode.node.leaf === false || rowNode.level !== 0 || rowNode.node.children && rowNode.node.children.length\" (click)=\"onClick($event)\"\n [style.visibility]=\"rowNode.node.leaf === false || (rowNode.node.children && rowNode.node.children.length) ? 'visible' : 'hidden'\" [style.marginLeft]=\"rowNode.level * 16 + 'px'\">\n <i [ngClass]=\"rowNode.node.expanded ? 'pi pi-fw pi-chevron-down' : 'pi pi-fw pi-chevron-right'\"></i>\n </a>\n "
|
|
}),
|
|
__metadata("design:paramtypes", [TreeTable])
|
|
], TreeTableToggler);
|
|
return TreeTableToggler;
|
|
}());
|
|
exports.TreeTableToggler = TreeTableToggler;
|
|
var TreeTableModule = /** @class */ (function () {
|
|
function TreeTableModule() {
|
|
}
|
|
TreeTableModule = __decorate([
|
|
core_1.NgModule({
|
|
imports: [common_1.CommonModule, paginator_1.PaginatorModule],
|
|
exports: [TreeTable, shared_1.SharedModule, TreeTableToggler, TTSortableColumn, TTSortIcon, TTResizableColumn, TTRow, TTReorderableColumn, TTSelectableRow, TTSelectableRowDblClick, TTContextMenuRow, TTCheckbox, TTHeaderCheckbox, TTEditableColumn, TreeTableCellEditor],
|
|
declarations: [TreeTable, TreeTableToggler, TTScrollableView, TTBody, TTSortableColumn, TTSortIcon, TTResizableColumn, TTRow, TTReorderableColumn, TTSelectableRow, TTSelectableRowDblClick, TTContextMenuRow, TTCheckbox, TTHeaderCheckbox, TTEditableColumn, TreeTableCellEditor]
|
|
})
|
|
], TreeTableModule);
|
|
return TreeTableModule;
|
|
}());
|
|
exports.TreeTableModule = TreeTableModule;
|
|
//# sourceMappingURL=treetable.js.map
|