@universis/ngx-tables 0.8.3 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bundles/universis-ngx-tables.umd.js +144 -99
- package/bundles/universis-ngx-tables.umd.js.map +1 -1
- package/bundles/universis-ngx-tables.umd.min.js +1 -1
- package/bundles/universis-ngx-tables.umd.min.js.map +1 -1
- package/esm2015/lib/components/advanced-table/advanced-table.component.js +119 -89
- package/esm2015/lib/components/advanced-table/advanced-table.formatters.js +5 -3
- package/esm2015/lib/components/advanced-table/advanced-table.interfaces.js +1 -1
- package/esm2015/lib/components/column-selector/column-selector.component.js +27 -15
- package/esm2015/lib/components/column-selector/column-selector.service.js +1 -1
- package/esm2015/lib/directives/advance-table-state.directive.js +2 -1
- package/esm5/lib/components/advanced-table/advanced-table.component.js +119 -89
- package/esm5/lib/components/advanced-table/advanced-table.formatters.js +5 -3
- package/esm5/lib/components/advanced-table/advanced-table.interfaces.js +1 -1
- package/esm5/lib/components/column-selector/column-selector.component.js +25 -12
- package/esm5/lib/components/column-selector/column-selector.service.js +1 -1
- package/esm5/lib/directives/advance-table-state.directive.js +1 -1
- package/fesm2015/universis-ngx-tables.js +148 -102
- package/fesm2015/universis-ngx-tables.js.map +1 -1
- package/fesm5/universis-ngx-tables.js +145 -100
- package/fesm5/universis-ngx-tables.js.map +1 -1
- package/lib/components/advanced-table/advanced-table.interfaces.d.ts +1 -0
- package/lib/components/column-selector/column-selector.component.d.ts +4 -5
- package/package.json +1 -1
- package/universis-ngx-tables.metadata.json +1 -1
|
@@ -21,7 +21,7 @@ import { ProgressbarModule } from 'ngx-bootstrap/progressbar';
|
|
|
21
21
|
import { GroupByPipe, NgPipesModule } from 'ngx-pipes';
|
|
22
22
|
import { template, at, cloneDeep } from 'lodash';
|
|
23
23
|
import { __extends, __awaiter, __generator, __values, __assign, __spread } from 'tslib';
|
|
24
|
-
import { Injectable, Directive, Optional, Input, Pipe, Component, ElementRef, ViewChild, ViewEncapsulation, EventEmitter, Output, NgModule, CUSTOM_ELEMENTS_SCHEMA, defineInjectable, inject,
|
|
24
|
+
import { Injectable, Directive, Optional, Input, Pipe, Component, ElementRef, ViewChild, ViewEncapsulation, EventEmitter, Output, NgModule, CUSTOM_ELEMENTS_SCHEMA, HostListener, defineInjectable, inject, ChangeDetectorRef, InjectionToken, Inject, Injector, ChangeDetectionStrategy } from '@angular/core';
|
|
25
25
|
import { ActivatedRoute, Router, NavigationStart, NavigationEnd, RouterModule } from '@angular/router';
|
|
26
26
|
import { createFeatureSelector, createSelector, select, Store } from '@ngrx/store';
|
|
27
27
|
import { skip, first, filter } from 'rxjs/operators';
|
|
@@ -211,9 +211,11 @@ var ActionLinkFormatter = /** @class */ (function (_super) {
|
|
|
211
211
|
}
|
|
212
212
|
if (x.formatOptions && x.formatOptions.commands) {
|
|
213
213
|
var urlTree = _this.createUrlTree(row, x.formatOptions);
|
|
214
|
-
return "<a data-name='" + x.name + "' class=\"dropdown-item
|
|
214
|
+
return "<a data-name='" + x.name + "' class=\"dropdown-item" + (typeof x.className === 'string' && x.className.length
|
|
215
|
+
? " " + x.className.trim() : '') + "\" href=\"#" + urlTree.toString() + "\">\n " + _this.injector.get(TranslateService).instant(x.title) + "\n </a>";
|
|
215
216
|
}
|
|
216
|
-
return "<a data-name='" + x.name + "' class=\"dropdown-item
|
|
217
|
+
return "<a data-name='" + x.name + "' class=\"dropdown-item" + (typeof x.className === 'string' && x.className.length
|
|
218
|
+
? " " + x.className.trim() : '') + "\" href=\"" + AdvancedColumnFormatter.template(x.href)(row) + "\">\n " + _this.injector.get(TranslateService).instant(x.title) + "\n </a>";
|
|
217
219
|
})
|
|
218
220
|
.join('') + "\n </div>\n </div>";
|
|
219
221
|
}
|
|
@@ -529,19 +531,32 @@ var AdvancedFilterValueProvider = /** @class */ (function () {
|
|
|
529
531
|
|
|
530
532
|
var ColumnSelectorComponent = /** @class */ (function (_super) {
|
|
531
533
|
__extends(ColumnSelectorComponent, _super);
|
|
532
|
-
function ColumnSelectorComponent(router, activatedRoute, _modalRef,
|
|
534
|
+
function ColumnSelectorComponent(router, activatedRoute, _modalRef, _changeDetector) {
|
|
533
535
|
var _this = _super.call(this, router, activatedRoute) || this;
|
|
534
536
|
_this._modalRef = _modalRef;
|
|
535
|
-
_this.
|
|
536
|
-
_this._translateService = _translateService;
|
|
537
|
+
_this._changeDetector = _changeDetector;
|
|
537
538
|
_this.dismiss = new EventEmitter();
|
|
538
539
|
_this.availableColumnsControl = new FormControl();
|
|
539
540
|
_this.selectedColumnsControl = new FormControl();
|
|
541
|
+
_this.changing = false;
|
|
540
542
|
return _this;
|
|
541
543
|
}
|
|
542
544
|
ColumnSelectorComponent.prototype.ok = function () {
|
|
543
|
-
this
|
|
544
|
-
this.
|
|
545
|
+
var _this = this;
|
|
546
|
+
this._changeDetector.detectChanges();
|
|
547
|
+
setTimeout(function () {
|
|
548
|
+
_this.changing = true;
|
|
549
|
+
_this._modalRef.hide();
|
|
550
|
+
}, 0);
|
|
551
|
+
try {
|
|
552
|
+
this.applyChanges();
|
|
553
|
+
}
|
|
554
|
+
catch (err) {
|
|
555
|
+
throw err;
|
|
556
|
+
}
|
|
557
|
+
finally {
|
|
558
|
+
this.changing = false;
|
|
559
|
+
}
|
|
545
560
|
this.dismiss.emit('ok');
|
|
546
561
|
return Promise.resolve('ok');
|
|
547
562
|
};
|
|
@@ -752,9 +767,10 @@ var ColumnSelectorComponent = /** @class */ (function (_super) {
|
|
|
752
767
|
};
|
|
753
768
|
ColumnSelectorComponent.decorators = [
|
|
754
769
|
{ type: Component, args: [{
|
|
770
|
+
// tslint:disable-next-line:component-selector
|
|
755
771
|
selector: 'app-column-selector',
|
|
756
|
-
template: "<div>\n <div class=\"modal-header\">\n <h5 class=\"modal-title\">{{'Tables.SelectColumns' | translate}}</h5>\n <button (click)=\"cancel()\"\n type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Cancel\">\n <span aria-hidden=\"true\">×</span>\n </button>\n </div>\n <div class=\"modal-body pt-0\">\n <div class=\"row\">\n <div class=\"col-12\">\n <p [translate]=\"'Tables.SelectColumnHelp'\"></p>\n <p [translate]=\"'Tables.MoveColumnHelp'\"></p>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-4\">\n <select [formControl]=\"availableColumnsControl\" size=\"10\" class=\"form-select form-control\" multiple aria-label=\"multiple select example\">\n <ng-container *ngIf=\"columns\">\n <ng-container *ngFor=\"let column of columns | orderBy: ['title']\">\n <option [value]=\"column.key\">{{column.title}}</option>\n </ng-container>\n </ng-container>\n </select>\n </div>\n <div class=\"col-4 d-flex justify-content-center align-items-center\">\n <div class=\"col-9\">\n <div>\n <button [disabled]=\"!(availableColumnsControl.value && availableColumnsControl.value.length)\" (click)=\"addColumns()\" type=\"button\" class=\"btn btn-primary btn-block\">\n <i class=\"fas fa-plus mr-2\"></i><span [translate]=\"'Tables.AddColumn'\"></span>\n </button>\n </div>\n <div class=\"mt-3\">\n <button [disabled]=\"!(selectedColumnsControl.value && selectedColumnsControl.value.length)\" (click)=\"removeColumns()\" type=\"button\" class=\"btn btn-secondary btn-block\">\n <i class=\"fas fa-minus mr-2\"></i><span [translate]=\"'Tables.RemoveColumn'\"></span>\n </button>\n </div>\n </div>\n </div>\n <div class=\"col-4\">\n <select [formControl]=\"selectedColumnsControl\" size=\"10\" class=\"form-select form-control\" multiple aria-label=\"multiple select example\">\n <ng-container *ngIf=\"selectedColumns\">\n <ng-container *ngFor=\"let column of selectedColumns\">\n <option [value]=\"column.key\">{{column.title}}</option>\n </ng-container>\n </ng-container>\n </select>\n <div class=\"d-flex justify-content-center align-items-center\">\n <div class=\"btn-group mt-4\">\n <button #moveUpButton (click)=\"moveUp()\" type=\"button\" class=\"btn btn-primary\">\n <i class=\"fas fa-chevron-up mr-2\"></i><span [translate]=\"'Tables.MoveUp'\"></span>\n </button>\n <button #moveDownButton (click)=\"moveDown()\" type=\"button\" class=\"btn btn-primary ml-2\">\n <i class=\"fas fa-chevron-down mr-2\"></i><span [translate]=\"'Tables.MoveDown'\"></span>\n </button>\n </div>\n </div>\n </div>\n </div>\n \n </div>\n <div class=\"modal-footer justify-content-end\">\n <button [disabled]=\"okButtonDisabled\" (click)=\"ok()\"\n type=\"button\" class=\"btn btn-primary\">\n {{'OK' | translate}}\n </button>\n <button [disabled]=\"cancelButtonDisabled\"\n (click)=\"cancel()\" type=\"button\" [ngClass]=\"cancelButtonClass\" data-dismiss=\"modal\">\n {{'Cancel' | translate}}\n </button>\n </div>\n </div>\n ",
|
|
757
|
-
encapsulation: ViewEncapsulation.
|
|
772
|
+
template: "<div>\n <div class=\"modal-header\">\n <h5 class=\"modal-title\">{{'Tables.SelectColumns' | translate}}</h5>\n <button (click)=\"cancel()\"\n type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-label=\"Cancel\">\n <span aria-hidden=\"true\">×</span>\n </button>\n </div>\n <div class=\"modal-body pt-0\">\n <div class=\"row\">\n <div class=\"col-12\">\n <p [translate]=\"'Tables.SelectColumnHelp'\"></p>\n <p [translate]=\"'Tables.MoveColumnHelp'\"></p>\n </div>\n </div>\n <div class=\"row\">\n <div class=\"col-4\">\n <select [formControl]=\"availableColumnsControl\" size=\"10\" class=\"form-select form-control\" multiple aria-label=\"multiple select example\">\n <ng-container *ngIf=\"columns\">\n <ng-container *ngFor=\"let column of columns | orderBy: ['title']\">\n <option class=\"text-wrap\" [value]=\"column.key\">{{column.title}}</option>\n </ng-container>\n </ng-container>\n </select>\n </div>\n <div class=\"col-4 d-flex justify-content-center align-items-center\">\n <div class=\"col-9\">\n <div>\n <button [disabled]=\"!(availableColumnsControl.value && availableColumnsControl.value.length)\" (click)=\"addColumns()\" type=\"button\" class=\"btn btn-primary btn-block\">\n <i class=\"fas fa-plus mr-2\"></i><span [translate]=\"'Tables.AddColumn'\"></span>\n </button>\n </div>\n <div class=\"mt-3\">\n <button [disabled]=\"!(selectedColumnsControl.value && selectedColumnsControl.value.length)\" (click)=\"removeColumns()\" type=\"button\" class=\"btn btn-secondary btn-block\">\n <i class=\"fas fa-minus mr-2\"></i><span [translate]=\"'Tables.RemoveColumn'\"></span>\n </button>\n </div>\n </div>\n </div>\n <div class=\"col-4\">\n <select [formControl]=\"selectedColumnsControl\" size=\"10\" class=\"form-select form-control\" multiple aria-label=\"multiple select example\">\n <ng-container *ngIf=\"selectedColumns\">\n <ng-container *ngFor=\"let column of selectedColumns\">\n <option class=\"text-wrap\" [value]=\"column.key\">{{column.title}}</option>\n </ng-container>\n </ng-container>\n </select>\n <div class=\"d-flex justify-content-center align-items-center\">\n <div class=\"btn-group mt-4\">\n <button #moveUpButton (click)=\"moveUp()\" type=\"button\" class=\"btn btn-primary\">\n <i class=\"fas fa-chevron-up mr-2\"></i><span [translate]=\"'Tables.MoveUp'\"></span>\n </button>\n <button #moveDownButton (click)=\"moveDown()\" type=\"button\" class=\"btn btn-primary ml-2\">\n <i class=\"fas fa-chevron-down mr-2\"></i><span [translate]=\"'Tables.MoveDown'\"></span>\n </button>\n </div>\n </div>\n </div>\n </div>\n \n </div>\n <div class=\"modal-footer justify-content-end\">\n\n <button [disabled]=\"okButtonDisabled\" (click)=\"ok()\"\n type=\"button\" class=\"btn btn-primary\">\n <i *ngIf=\"changing\" class=\"fa fa-spinner fa-spin mr-1\"></i>\n {{'OK' | translate}}\n </button>\n <button [disabled]=\"cancelButtonDisabled\"\n (click)=\"cancel()\" type=\"button\" [ngClass]=\"cancelButtonClass\" data-dismiss=\"modal\">\n {{'Cancel' | translate}}\n </button>\n </div>\n </div>\n ",
|
|
773
|
+
encapsulation: ViewEncapsulation.Emulated,
|
|
758
774
|
styles: ["\n .form-select {\n -webkit-appearance: none;\n -moz-appearance: none;\n appearance: none;\n padding: 5px;\n }\n .form-select * {\n padding: 5px 5px;\n }\n .btn.disabled, .btn:disabled {\n border-color: transparent !important;\n }\n "]
|
|
759
775
|
}] }
|
|
760
776
|
];
|
|
@@ -763,8 +779,7 @@ var ColumnSelectorComponent = /** @class */ (function (_super) {
|
|
|
763
779
|
{ type: Router },
|
|
764
780
|
{ type: ActivatedRoute },
|
|
765
781
|
{ type: BsModalRef },
|
|
766
|
-
{ type: ChangeDetectorRef }
|
|
767
|
-
{ type: TranslateService }
|
|
782
|
+
{ type: ChangeDetectorRef }
|
|
768
783
|
]; };
|
|
769
784
|
ColumnSelectorComponent.propDecorators = {
|
|
770
785
|
columns: [{ type: Input }],
|
|
@@ -1937,113 +1952,141 @@ var AdvancedTableComponent = /** @class */ (function () {
|
|
|
1937
1952
|
if (order && order.length) {
|
|
1938
1953
|
// get order query expression
|
|
1939
1954
|
var orderByStr = order.map(function (expr) {
|
|
1940
|
-
|
|
1955
|
+
var columnIndex;
|
|
1956
|
+
if (self.columnOrdering === false) {
|
|
1957
|
+
columnIndex = expr.column;
|
|
1958
|
+
}
|
|
1959
|
+
else {
|
|
1960
|
+
// get the current column order (from colReorder)
|
|
1961
|
+
var columnOrder = self.dataTable.colReorder.order();
|
|
1962
|
+
// and match the dataTable index to the config columns index
|
|
1963
|
+
// expr.column should always be valid (e.g. in range), but perform a minor validation
|
|
1964
|
+
if (expr.column >= 0 && expr.column < columnOrder.length) {
|
|
1965
|
+
columnIndex = columnOrder[expr.column];
|
|
1966
|
+
}
|
|
1967
|
+
else {
|
|
1968
|
+
// use the first column as a fallback (won't happen, just for safety)
|
|
1969
|
+
columnIndex = 0;
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
return tableColumns_1[columnIndex].name + ' ' + expr.dir || 'asc';
|
|
1941
1973
|
}).join(',');
|
|
1942
1974
|
// set order
|
|
1943
1975
|
q.setParam('$orderby', orderByStr);
|
|
1944
1976
|
}
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1977
|
+
self.stateLoadCallback(null, function (state) {
|
|
1978
|
+
// configure $select parameter
|
|
1979
|
+
var select$$1 = self.config.columns.filter(function (column) {
|
|
1980
|
+
if (column.virtual === true) {
|
|
1981
|
+
return false;
|
|
1982
|
+
}
|
|
1983
|
+
if (column.optional === true) {
|
|
1984
|
+
if (state && state.columns) {
|
|
1985
|
+
var index = tableColumns_1.findIndex(function (tableColumn) { return tableColumn.name === column.name; });
|
|
1986
|
+
if (index >= 0) {
|
|
1987
|
+
return state.columns[index].visible;
|
|
1988
|
+
}
|
|
1989
|
+
}
|
|
1990
|
+
return false;
|
|
1991
|
+
}
|
|
1992
|
+
return true;
|
|
1993
|
+
}).map(function (column) {
|
|
1994
|
+
if (column.property) {
|
|
1995
|
+
return column.name + ' as ' + column.property;
|
|
1996
|
+
}
|
|
1997
|
+
else {
|
|
1998
|
+
return column.name;
|
|
1999
|
+
}
|
|
2000
|
+
});
|
|
2001
|
+
q.select.apply(q, select$$1);
|
|
2002
|
+
// configure $filter
|
|
2003
|
+
if (queryParams.$filter && queryParams.$filter.length) {
|
|
2004
|
+
// set route filter
|
|
2005
|
+
var qParams = q.getParams();
|
|
2006
|
+
q.setParam('$filter', null);
|
|
2007
|
+
var expressions = [queryParams.$filter];
|
|
2008
|
+
if (qParams.$filter) {
|
|
2009
|
+
expressions.push('(' + qParams.$filter + ')');
|
|
2010
|
+
}
|
|
2011
|
+
q.filter(expressions.join(' and '));
|
|
1949
2012
|
}
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
2013
|
+
// check if query parameters contain filter
|
|
2014
|
+
if (queryParams.$expand && queryParams.$expand.length) {
|
|
2015
|
+
// set route $expand
|
|
2016
|
+
q.setParam('$expand', queryParams.$expand);
|
|
1954
2017
|
}
|
|
1955
|
-
else {
|
|
1956
|
-
|
|
2018
|
+
else if (self.config && self.config.defaults && self.config.defaults.expand) {
|
|
2019
|
+
q.setParam('$expand', self.config.defaults.expand);
|
|
1957
2020
|
}
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
// configure $filter
|
|
1961
|
-
if (queryParams.$filter && queryParams.$filter.length) {
|
|
1962
|
-
// set route filter
|
|
1963
|
-
var qParams = q.getParams();
|
|
1964
|
-
q.setParam('$filter', null);
|
|
1965
|
-
var expressions = [queryParams.$filter];
|
|
1966
|
-
if (qParams.$filter) {
|
|
1967
|
-
expressions.push('(' + qParams.$filter + ')');
|
|
2021
|
+
if (!q.getParams()['$orderby'] && self.config && self.config.defaults && self.config.defaults.orderBy) {
|
|
2022
|
+
q.setParam('$orderby', self.config.defaults.orderBy);
|
|
1968
2023
|
}
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
q.setParam('$groupby', self.config.defaults.groupBy);
|
|
1984
|
-
}
|
|
1985
|
-
// append default filter
|
|
1986
|
-
if (self.config && self.config.defaults && self.config.defaults.filter) {
|
|
1987
|
-
return self._advancedFilterValueProvider.asyncBuildFilter(self.config.defaults.filter).then(function (defaultFilterString) {
|
|
1988
|
-
if (defaultFilterString) {
|
|
1989
|
-
var qParams = q.getParams();
|
|
1990
|
-
q.setParam('$filter', null);
|
|
1991
|
-
var expressions = [defaultFilterString];
|
|
1992
|
-
if (qParams.$filter) {
|
|
1993
|
-
expressions.push('(' + qParams.$filter + ')');
|
|
1994
|
-
}
|
|
1995
|
-
q.filter(expressions.join(' and '));
|
|
1996
|
-
}
|
|
1997
|
-
self.lastQueryParams = q.getParams();
|
|
1998
|
-
return q.getList().then(function (items) {
|
|
1999
|
-
var dataSet = {
|
|
2000
|
-
recordsTotal: items.total,
|
|
2001
|
-
recordsFiltered: items.total,
|
|
2002
|
-
data: items.value,
|
|
2003
|
-
};
|
|
2004
|
-
self._lastQueryTotalItems = items.total;
|
|
2005
|
-
if (items.total === 0) {
|
|
2006
|
-
self.resetEmptyTable();
|
|
2024
|
+
if (self.config && self.config.defaults && self.config.defaults.groupBy) {
|
|
2025
|
+
q.setParam('$groupby', self.config.defaults.groupBy);
|
|
2026
|
+
}
|
|
2027
|
+
// append default filter
|
|
2028
|
+
if (self.config && self.config.defaults && self.config.defaults.filter) {
|
|
2029
|
+
return self._advancedFilterValueProvider.asyncBuildFilter(self.config.defaults.filter).then(function (defaultFilterString) {
|
|
2030
|
+
if (defaultFilterString) {
|
|
2031
|
+
var qParams = q.getParams();
|
|
2032
|
+
q.setParam('$filter', null);
|
|
2033
|
+
var expressions = [defaultFilterString];
|
|
2034
|
+
if (qParams.$filter) {
|
|
2035
|
+
expressions.push('(' + qParams.$filter + ')');
|
|
2036
|
+
}
|
|
2037
|
+
q.filter(expressions.join(' and '));
|
|
2007
2038
|
}
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2039
|
+
self.lastQueryParams = q.getParams();
|
|
2040
|
+
return q.getList().then(function (items) {
|
|
2041
|
+
var dataSet = {
|
|
2042
|
+
recordsTotal: items.total,
|
|
2043
|
+
recordsFiltered: items.total,
|
|
2044
|
+
data: items.value,
|
|
2045
|
+
};
|
|
2046
|
+
self._lastQueryTotalItems = items.total;
|
|
2047
|
+
if (items.total === 0) {
|
|
2048
|
+
self.resetEmptyTable();
|
|
2049
|
+
}
|
|
2050
|
+
// emit load event
|
|
2051
|
+
self.load.emit(dataSet);
|
|
2052
|
+
// return data
|
|
2053
|
+
return fnCallback(dataSet);
|
|
2054
|
+
});
|
|
2055
|
+
}).catch(function (err) {
|
|
2056
|
+
// log error to console
|
|
2057
|
+
console.error('TABLES', err);
|
|
2058
|
+
// show error
|
|
2059
|
+
self.toggleError(err);
|
|
2060
|
+
self._lastQueryTotalItems = 0;
|
|
2061
|
+
// by returning empty dataset
|
|
2062
|
+
self.load.emit(EMPTY_DATASET);
|
|
2063
|
+
return fnCallback(EMPTY_DATASET);
|
|
2012
2064
|
});
|
|
2065
|
+
}
|
|
2066
|
+
self.lastQueryParams = q.getParams();
|
|
2067
|
+
q.getList().then(function (items) {
|
|
2068
|
+
var dataSet = {
|
|
2069
|
+
recordsTotal: items.total,
|
|
2070
|
+
recordsFiltered: items.total,
|
|
2071
|
+
data: items.value,
|
|
2072
|
+
};
|
|
2073
|
+
self._lastQueryTotalItems = items.total;
|
|
2074
|
+
if (items.total === 0) {
|
|
2075
|
+
self.resetEmptyTable();
|
|
2076
|
+
}
|
|
2077
|
+
// emit load event
|
|
2078
|
+
self.load.emit(dataSet);
|
|
2079
|
+
// return data
|
|
2080
|
+
return fnCallback(dataSet);
|
|
2013
2081
|
}).catch(function (err) {
|
|
2014
2082
|
// log error to console
|
|
2015
2083
|
console.error('TABLES', err);
|
|
2016
2084
|
// show error
|
|
2017
2085
|
self.toggleError(err);
|
|
2018
|
-
self._lastQueryTotalItems = 0;
|
|
2019
2086
|
// by returning empty dataset
|
|
2020
2087
|
self.load.emit(EMPTY_DATASET);
|
|
2021
2088
|
return fnCallback(EMPTY_DATASET);
|
|
2022
2089
|
});
|
|
2023
|
-
}
|
|
2024
|
-
self.lastQueryParams = q.getParams();
|
|
2025
|
-
q.getList().then(function (items) {
|
|
2026
|
-
var dataSet = {
|
|
2027
|
-
recordsTotal: items.total,
|
|
2028
|
-
recordsFiltered: items.total,
|
|
2029
|
-
data: items.value,
|
|
2030
|
-
};
|
|
2031
|
-
self._lastQueryTotalItems = items.total;
|
|
2032
|
-
if (items.total === 0) {
|
|
2033
|
-
self.resetEmptyTable();
|
|
2034
|
-
}
|
|
2035
|
-
// emit load event
|
|
2036
|
-
self.load.emit(dataSet);
|
|
2037
|
-
// return data
|
|
2038
|
-
return fnCallback(dataSet);
|
|
2039
|
-
}).catch(function (err) {
|
|
2040
|
-
// log error to console
|
|
2041
|
-
console.error('TABLES', err);
|
|
2042
|
-
// show error
|
|
2043
|
-
self.toggleError(err);
|
|
2044
|
-
// by returning empty dataset
|
|
2045
|
-
self.load.emit(EMPTY_DATASET);
|
|
2046
|
-
return fnCallback(EMPTY_DATASET);
|
|
2047
2090
|
});
|
|
2048
2091
|
},
|
|
2049
2092
|
language: Object.assign({}, self.translator.transform('Tables.DataTable'), { emptyTable: ' ' }),
|
|
@@ -2418,6 +2461,8 @@ var AdvancedTableComponent = /** @class */ (function () {
|
|
|
2418
2461
|
}
|
|
2419
2462
|
// finally apply column order
|
|
2420
2463
|
_this.dataTable.colReorder.order(indexes, true);
|
|
2464
|
+
// simply redraw the table
|
|
2465
|
+
_this.dataTable.draw();
|
|
2421
2466
|
}
|
|
2422
2467
|
});
|
|
2423
2468
|
};
|