@universis/ngx-tables 0.7.30 → 0.8.1

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.
@@ -3,15 +3,16 @@ import * as jQuery_ from 'jquery';
3
3
  import 'datatables.net';
4
4
  import 'datatables.net-scroller';
5
5
  import 'datatables.net-colreorder';
6
+ import 'datatables.net-buttons';
6
7
  import 'rxjs/add/observable/combineLatest';
7
8
  import { HttpClient } from '@angular/common/http';
8
- import { ClientDataQueryable, ResponseError, TextUtils } from '@themost/client';
9
+ import { ResponseError, ClientDataQueryable, TextUtils } from '@themost/client';
9
10
  import { BehaviorSubject } from 'rxjs';
10
11
  import { AngularDataContext } from '@themost/angular';
11
12
  import { DatePipe, CommonModule } from '@angular/common';
12
13
  import { TranslateService, TranslatePipe, TranslateModule } from '@ngx-translate/core';
13
14
  import { FormControl, FormArray, FormBuilder, FormsModule, ReactiveFormsModule } from '@angular/forms';
14
- import { TemplatePipe, ModalService, LoadingService, ErrorService, DIALOG_BUTTONS, UserActivityService, ToastService, AppEventService, UserStorageService, ConfigurationService, SharedModule } from '@universis/common';
15
+ import { TemplatePipe, ModalService, ConfigurationService, ErrorService, LoadingService, DIALOG_BUTTONS, ExportSpreadsheetService, UserActivityService, ToastService, AppEventService, UserStorageService, SharedModule } from '@universis/common';
15
16
  import { RouterModalOkCancel, RouterModalModule } from '@universis/common/routing';
16
17
  import { ServiceUrlPreProcessor, TranslatePreProcessor, AdvancedFormsModule } from '@universis/forms';
17
18
  import { FormioModule } from 'angular-formio';
@@ -819,6 +820,291 @@ var ColumnSelectorService = /** @class */ (function () {
819
820
  return ColumnSelectorService;
820
821
  }());
821
822
 
823
+ var ActivatedTableService = /** @class */ (function () {
824
+ function ActivatedTableService(_router, _activatedRoute) {
825
+ var _this = this;
826
+ this._router = _router;
827
+ this._activatedRoute = _activatedRoute;
828
+ _router.events.forEach(function (event) {
829
+ if (event instanceof NavigationStart) {
830
+ if (_this._activeTable) {
831
+ _this._activeTable = null;
832
+ }
833
+ }
834
+ });
835
+ }
836
+ Object.defineProperty(ActivatedTableService.prototype, "activeTable", {
837
+ get: function () {
838
+ return this._activeTable;
839
+ },
840
+ set: function (tableComponent) {
841
+ this._activeTable = tableComponent;
842
+ },
843
+ enumerable: true,
844
+ configurable: true
845
+ });
846
+ ActivatedTableService.decorators = [
847
+ { type: Injectable, args: [{
848
+ providedIn: 'root'
849
+ },] }
850
+ ];
851
+ /** @nocollapse */
852
+ ActivatedTableService.ctorParameters = function () { return [
853
+ { type: Router },
854
+ { type: ActivatedRoute }
855
+ ]; };
856
+ ActivatedTableService.ngInjectableDef = defineInjectable({ factory: function ActivatedTableService_Factory() { return new ActivatedTableService(inject(Router), inject(ActivatedRoute)); }, token: ActivatedTableService, providedIn: "root" });
857
+ return ActivatedTableService;
858
+ }());
859
+
860
+ var MAX_EXPORT_ITEMS = 500;
861
+ var BtnExpDirective = /** @class */ (function () {
862
+ function BtnExpDirective(_activatedTable, _context, _config, _translate, _loadingService, _errorService) {
863
+ this._activatedTable = _activatedTable;
864
+ this._context = _context;
865
+ this._config = _config;
866
+ this._translate = _translate;
867
+ this._loadingService = _loadingService;
868
+ this._errorService = _errorService;
869
+ }
870
+ BtnExpDirective.prototype.clickEvent = function (event) {
871
+ return __awaiter(this, void 0, void 0, function () {
872
+ return __generator(this, function (_a) {
873
+ event.preventDefault();
874
+ event.stopPropagation();
875
+ if (this._activatedTable.activeTable) {
876
+ return [2 /*return*/, this._activatedTable.activeTable.exportView()];
877
+ /*
878
+ const lastQuery = this._activatedTable.activeTable.lastQuery;
879
+ const tableConfig = this._activatedTable.activeTable.config;
880
+ const serviceHeaders = this._context.getService().getHeaders();
881
+ const queryModel = lastQuery.getModel();
882
+ let query = this._context.model(queryModel).asQueryable();
883
+ const queryParams = lastQuery.getParams();
884
+ query = this.constructQuery(query, queryParams, tableConfig, serviceHeaders);
885
+ // get export settings
886
+ const exportSettings = this._config.settings as ExportLimitConfiguration;
887
+ // get export limit
888
+ const maxExportItems = exportSettings && exportSettings.tables && exportSettings.tables.exportLimit;
889
+ if (maxExportItems && typeof maxExportItems === 'number' && maxExportItems > 0) {
890
+ query.skip(0).take(maxExportItems);
891
+ } else {
892
+ query.skip(0).take(MAX_EXPORT_ITEMS);
893
+ }
894
+ // This constructs the URI based on the way @themost does
895
+ const url = this.constructURL(query);
896
+ this.downloadFile(url, query.getService().getHeaders(), query.getModel()); */
897
+ }
898
+ return [2 /*return*/];
899
+ });
900
+ });
901
+ };
902
+ /**
903
+ * Sets the parameters to the query based on
904
+ * the active filters of the activated table
905
+ * @param {ClientDataQueryable} query
906
+ * @param params: The filters of the last query of the activated table
907
+ * @return ClientDataQueryable
908
+ */
909
+ BtnExpDirective.prototype.setParams = function (query, params) {
910
+ if (params && typeof params === 'object') {
911
+ Object.keys(params).forEach(function (key) {
912
+ query.setParam(key, params[key]);
913
+ });
914
+ }
915
+ return query;
916
+ };
917
+ /**
918
+ * Sets the headers to the query based on
919
+ * the default headers of the DataContext
920
+ * and appending the accept header to get
921
+ * an xlsx file from the API
922
+ * @param {ClientDataQueryable} query
923
+ * @param {Headers} headers: The headers to append to the query
924
+ * @return ClientDataQueryable
925
+ */
926
+ BtnExpDirective.prototype.setHeaders = function (query, headers) {
927
+ Object.keys(headers).forEach(function (key) {
928
+ if (headers.hasOwnProperty(key)) {
929
+ query.getService().setHeader(key, headers[key]);
930
+ }
931
+ });
932
+ // sets a header to accept xlsx files
933
+ query.getService().setHeader('Accept', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
934
+ return query;
935
+ };
936
+ /**
937
+ * Constructs the select parameter of the
938
+ * ClientDataQuery by replacing the target name
939
+ * of the field based on the localized translation
940
+ * of that property on the advanced tabled
941
+ * @param {ClientDataQueryable} query
942
+ * @param tableConfig: The configuration of the activated table
943
+ * @return ClientDataQueryable
944
+ */
945
+ BtnExpDirective.prototype.constructQueryParam = function (query, tableConfig) {
946
+ var _this = this;
947
+ var selectQuery = query.getParams().$select;
948
+ var selectQueryArray = selectQuery.split(',');
949
+ selectQueryArray = selectQueryArray.map(function (select$$1) {
950
+ var e_1, _a, e_2, _b;
951
+ var words = select$$1.split(' ');
952
+ if (words.length === 3) {
953
+ if (tableConfig && tableConfig.columns) {
954
+ try {
955
+ for (var _c = __values(tableConfig.columns), _d = _c.next(); !_d.done; _d = _c.next()) {
956
+ var column = _d.value;
957
+ if (column.property === words[2] && column.title) {
958
+ words[2] = "\"" + _this._translate.instant(column.title) + "\"";
959
+ }
960
+ else if (column.property === words[2]) {
961
+ words[2] = "\"" + _this._translate.instant(words[2]) + "\"";
962
+ }
963
+ }
964
+ }
965
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
966
+ finally {
967
+ try {
968
+ if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
969
+ }
970
+ finally { if (e_1) throw e_1.error; }
971
+ }
972
+ }
973
+ }
974
+ if (words.length === 1) {
975
+ if (tableConfig && tableConfig.columns) {
976
+ try {
977
+ for (var _e = __values(tableConfig.columns), _f = _e.next(); !_f.done; _f = _e.next()) {
978
+ var column = _f.value;
979
+ if (column.name === words[0] && column.title) {
980
+ words[0] = words[0] + " as \"" + _this._translate.instant(column.title) + "\"";
981
+ break;
982
+ }
983
+ else if (column.name === words[0] && column.property) {
984
+ words[0] = words[0] + " as \"" + _this._translate.instant(column.property) + "\"";
985
+ break;
986
+ }
987
+ else if (words[0] === column.name && words[0] === "id" && column.hidden) {
988
+ break;
989
+ }
990
+ else if (words[0] == column.name || words[0] === column.property) {
991
+ words[0] = words[0] + " as \"" + _this._translate.instant(words[0]) + "\"";
992
+ }
993
+ }
994
+ }
995
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
996
+ finally {
997
+ try {
998
+ if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
999
+ }
1000
+ finally { if (e_2) throw e_2.error; }
1001
+ }
1002
+ }
1003
+ return words[0];
1004
+ }
1005
+ return words.join(' ');
1006
+ });
1007
+ selectQuery = selectQueryArray.join(',');
1008
+ query.setParam('$select', selectQuery);
1009
+ return query;
1010
+ };
1011
+ /**
1012
+ * Constructs the fetch URL based the query parameters
1013
+ * @param {ClientDataQueryable} query
1014
+ * @return String
1015
+ */
1016
+ BtnExpDirective.prototype.constructURL = function (query) {
1017
+ var baseURL = query.getService().getBase();
1018
+ var url = baseURL.endsWith('/') ? (baseURL + query.getModel() + '?') : (baseURL + '/' + query.getModel() + '?');
1019
+ Object.keys(query.getParams()).forEach(function (key, index) {
1020
+ if (index === 0) {
1021
+ url += key + '=' + query.getParams()[key];
1022
+ }
1023
+ else {
1024
+ url += '&' + key + '=' + query.getParams()[key];
1025
+ }
1026
+ });
1027
+ return url;
1028
+ };
1029
+ /**
1030
+ * Constructs the query by setting the parameters of the
1031
+ * advanced table's active filters, sets the necessary headers
1032
+ * and build the select parameter of the query
1033
+ * @param {ClientDataQueryable} query
1034
+ * @param params: The filters of the last query of the activated table
1035
+ * @param tableConfig: The configuration of the activated table
1036
+ * @param {Headers} headers: The headers to append to the query
1037
+ * @return ClientDataQueryable
1038
+ */
1039
+ BtnExpDirective.prototype.constructQuery = function (query, params, tableConfig, headers) {
1040
+ var _query = this.setParams(query, params);
1041
+ _query = this.setHeaders(_query, headers);
1042
+ _query = this.constructQueryParam(_query, tableConfig);
1043
+ return _query;
1044
+ };
1045
+ /**
1046
+ * Fetches and saves the xlsx file
1047
+ * @param {String} url
1048
+ * @param {Headers} serviceHeaders: The headers to append to the query
1049
+ * @param modelName: The model name of the advanced table
1050
+ */
1051
+ BtnExpDirective.prototype.downloadFile = function (url, serviceHeaders, modelName) {
1052
+ var _this = this;
1053
+ this._loadingService.showLoading();
1054
+ fetch(encodeURI(url), {
1055
+ headers: serviceHeaders,
1056
+ credentials: 'include'
1057
+ }).then(function (response) {
1058
+ if (response && !response.ok) {
1059
+ throw new ResponseError(response.statusText, response.status);
1060
+ }
1061
+ return response.blob();
1062
+ }).then(function (blob) {
1063
+ var objectUrl = window.URL.createObjectURL(blob);
1064
+ var a = document.createElement('a');
1065
+ document.body.appendChild(a);
1066
+ a.setAttribute('style', 'display: none');
1067
+ a.href = objectUrl;
1068
+ var downloadName = modelName + ".xlsx";
1069
+ a.download = downloadName;
1070
+ // this adds support for IE and MS Edge (up to version 44.19041)
1071
+ if (window.navigator && window.navigator.msSaveOrOpenBlob) {
1072
+ window.navigator.msSaveOrOpenBlob(blob, downloadName);
1073
+ }
1074
+ else {
1075
+ // for all other browsers
1076
+ a.click();
1077
+ }
1078
+ window.URL.revokeObjectURL(objectUrl);
1079
+ a.remove();
1080
+ _this._loadingService.hideLoading();
1081
+ }).catch(function (err) {
1082
+ _this._loadingService.hideLoading();
1083
+ _this._errorService.showError(err, {
1084
+ continueLink: '.'
1085
+ });
1086
+ });
1087
+ };
1088
+ BtnExpDirective.decorators = [
1089
+ { type: Directive, args: [{
1090
+ selector: '.universis-btn-export'
1091
+ },] }
1092
+ ];
1093
+ /** @nocollapse */
1094
+ BtnExpDirective.ctorParameters = function () { return [
1095
+ { type: ActivatedTableService },
1096
+ { type: AngularDataContext },
1097
+ { type: ConfigurationService },
1098
+ { type: TranslateService },
1099
+ { type: LoadingService },
1100
+ { type: ErrorService }
1101
+ ]; };
1102
+ BtnExpDirective.propDecorators = {
1103
+ clickEvent: [{ type: HostListener, args: ['click', ['$event'],] }]
1104
+ };
1105
+ return BtnExpDirective;
1106
+ }());
1107
+
822
1108
  // restore jquery import to avoid Cannot call a namespace ('jquery') error
823
1109
  var jQuery = jQuery_;
824
1110
  var DataTablesApi = jQuery.fn.dataTable.Api;
@@ -827,6 +1113,12 @@ DataTablesApi.register('processing()', function (show) {
827
1113
  ctx.oApi._fnProcessingDisplay(ctx, show);
828
1114
  });
829
1115
  });
1116
+ var ɵ0 = [];
1117
+ var EMPTY_DATASET = {
1118
+ recordsTotal: 0,
1119
+ recordsFiltered: 0,
1120
+ data: ɵ0,
1121
+ };
830
1122
  var TableTranslationChangeDetector = /** @class */ (function (_super) {
831
1123
  __extends(TableTranslationChangeDetector, _super);
832
1124
  function TableTranslationChangeDetector() {
@@ -845,6 +1137,15 @@ var TableTranslationChangeDetector = /** @class */ (function (_super) {
845
1137
  return TableTranslationChangeDetector;
846
1138
  }(ChangeDetectorRef));
847
1139
  var COLUMN_FORMATTERS = new InjectionToken('column.formatters');
1140
+ var ExportLimitExceededError = /** @class */ (function (_super) {
1141
+ __extends(ExportLimitExceededError, _super);
1142
+ function ExportLimitExceededError(message) {
1143
+ var _this = _super.call(this, message) || this;
1144
+ _this.name = 'ExportLimitExceededError';
1145
+ return _this;
1146
+ }
1147
+ return ExportLimitExceededError;
1148
+ }(RangeError));
848
1149
  var ColumnFormatter = /** @class */ (function (_super) {
849
1150
  __extends(ColumnFormatter, _super);
850
1151
  function ColumnFormatter(injector) {
@@ -875,7 +1176,7 @@ function getRandomIdentifier() {
875
1176
  return (Number(String(Math.random()).slice(2))).toString(36);
876
1177
  }
877
1178
  var AdvancedTableComponent = /** @class */ (function () {
878
- function AdvancedTableComponent(_context, _columnFormatters, _activatedRoute, _translateService, _injector, _advancedFilterValueProvider, _element, _template, _loading, _http, _columnSelector) {
1179
+ function AdvancedTableComponent(_context, _columnFormatters, _activatedRoute, _translateService, _injector, _advancedFilterValueProvider, _element, _template, _loading, _http, _columnSelector, _configuration, _exportSpreadsheet, _modalService, _errorService) {
879
1180
  var _this = this;
880
1181
  this._context = _context;
881
1182
  this._columnFormatters = _columnFormatters;
@@ -888,6 +1189,10 @@ var AdvancedTableComponent = /** @class */ (function () {
888
1189
  this._loading = _loading;
889
1190
  this._http = _http;
890
1191
  this._columnSelector = _columnSelector;
1192
+ this._configuration = _configuration;
1193
+ this._exportSpreadsheet = _exportSpreadsheet;
1194
+ this._modalService = _modalService;
1195
+ this._errorService = _errorService;
891
1196
  this._firstLoad = true;
892
1197
  this._showFooter = false;
893
1198
  this._showHeader = true;
@@ -931,6 +1236,7 @@ var AdvancedTableComponent = /** @class */ (function () {
931
1236
  this.customSelect = false;
932
1237
  this.selected = [];
933
1238
  this.unselected = [];
1239
+ this._lastQueryTotalItems = 0;
934
1240
  // initialize translate pipe
935
1241
  this.translator = new TranslatePipe(this._translateService, new TableTranslationChangeDetector());
936
1242
  jQuery.fn.dataTable.ext.classes.sPageButton = 'btn';
@@ -954,6 +1260,13 @@ var AdvancedTableComponent = /** @class */ (function () {
954
1260
  enumerable: true,
955
1261
  configurable: true
956
1262
  });
1263
+ Object.defineProperty(AdvancedTableComponent.prototype, "lastQueryTotalItems", {
1264
+ get: function () {
1265
+ return this._lastQueryTotalItems;
1266
+ },
1267
+ enumerable: true,
1268
+ configurable: true
1269
+ });
957
1270
  Object.defineProperty(AdvancedTableComponent.prototype, "showFooter", {
958
1271
  get: function () {
959
1272
  return this._showFooter;
@@ -1580,12 +1893,15 @@ var AdvancedTableComponent = /** @class */ (function () {
1580
1893
  recordsFiltered: 0,
1581
1894
  data: [],
1582
1895
  };
1896
+ self._lastQueryTotalItems = 0;
1583
1897
  // emit empty data
1584
1898
  self.load.emit(emptyDataSet);
1585
1899
  // return empty data
1586
1900
  return fnCallback(emptyDataSet);
1587
1901
  }
1588
1902
  }
1903
+ // reset error
1904
+ self.toggleError();
1589
1905
  // get activated route params
1590
1906
  var queryParams = self._activatedRoute.snapshot.queryParams;
1591
1907
  // get columns
@@ -1666,12 +1982,13 @@ var AdvancedTableComponent = /** @class */ (function () {
1666
1982
  q.filter(expressions.join(' and '));
1667
1983
  }
1668
1984
  self.lastQueryParams = q.getParams();
1669
- q.getList().then(function (items) {
1985
+ return q.getList().then(function (items) {
1670
1986
  var dataSet = {
1671
1987
  recordsTotal: items.total,
1672
1988
  recordsFiltered: items.total,
1673
1989
  data: items.value,
1674
1990
  };
1991
+ self._lastQueryTotalItems = items.total;
1675
1992
  if (items.total === 0) {
1676
1993
  self.resetEmptyTable();
1677
1994
  }
@@ -1681,7 +1998,14 @@ var AdvancedTableComponent = /** @class */ (function () {
1681
1998
  return fnCallback(dataSet);
1682
1999
  });
1683
2000
  }).catch(function (err) {
2001
+ // log error to console
1684
2002
  console.error('TABLES', err);
2003
+ // show error
2004
+ self.toggleError(err);
2005
+ self._lastQueryTotalItems = 0;
2006
+ // by returning empty dataset
2007
+ self.load.emit(EMPTY_DATASET);
2008
+ return fnCallback(EMPTY_DATASET);
1685
2009
  });
1686
2010
  }
1687
2011
  self.lastQueryParams = q.getParams();
@@ -1691,6 +2015,7 @@ var AdvancedTableComponent = /** @class */ (function () {
1691
2015
  recordsFiltered: items.total,
1692
2016
  data: items.value,
1693
2017
  };
2018
+ self._lastQueryTotalItems = items.total;
1694
2019
  if (items.total === 0) {
1695
2020
  self.resetEmptyTable();
1696
2021
  }
@@ -1699,7 +2024,13 @@ var AdvancedTableComponent = /** @class */ (function () {
1699
2024
  // return data
1700
2025
  return fnCallback(dataSet);
1701
2026
  }).catch(function (err) {
2027
+ // log error to console
1702
2028
  console.error('TABLES', err);
2029
+ // show error
2030
+ self.toggleError(err);
2031
+ // by returning empty dataset
2032
+ self.load.emit(EMPTY_DATASET);
2033
+ return fnCallback(EMPTY_DATASET);
1703
2034
  });
1704
2035
  },
1705
2036
  language: Object.assign({}, self.translator.transform('Tables.DataTable'), { emptyTable: ' ' }),
@@ -1932,9 +2263,28 @@ var AdvancedTableComponent = /** @class */ (function () {
1932
2263
  this.dataTable.context[0].oLanguage.sZeroRecords = this.emptyTable.nativeElement.innerHTML;
1933
2264
  }
1934
2265
  };
2266
+ AdvancedTableComponent.prototype.toggleError = function (err) {
2267
+ if (this.dataTable && this.dataTable.context[0]) {
2268
+ var innerMessage = this.errorTemplate.nativeElement.getElementsByTagName('small').item(0);
2269
+ if (err) {
2270
+ this.lastError = err;
2271
+ if (innerMessage) {
2272
+ innerMessage.innerHTML = err.error && err.error.message ? err.error.message : err.message;
2273
+ }
2274
+ this.dataTable.context[0].oLanguage.sEmptyTable =
2275
+ this.dataTable.context[0].oLanguage.sZeroRecords = this.errorTemplate.nativeElement.innerHTML;
2276
+ }
2277
+ else {
2278
+ if (innerMessage) {
2279
+ innerMessage.innerHTML = '';
2280
+ }
2281
+ this.dataTable.context[0].oLanguage.sEmptyTable = this.dataTable.context[0].oLanguage.sZeroRecords = '';
2282
+ }
2283
+ }
2284
+ };
1935
2285
  AdvancedTableComponent.prototype.clearEmptyTable = function () {
1936
2286
  if (this.dataTable && this.dataTable.context[0]) {
1937
- this.dataTable.context[0].oLanguage.sEmptyTable = '';
2287
+ this.dataTable.context[0].oLanguage.sEmptyTable = this.dataTable.context[0].oLanguage.sZeroRecords = '';
1938
2288
  }
1939
2289
  };
1940
2290
  AdvancedTableComponent.prototype.export = function () {
@@ -2049,13 +2399,132 @@ var AdvancedTableComponent = /** @class */ (function () {
2049
2399
  }
2050
2400
  });
2051
2401
  };
2402
+ /**
2403
+ *
2404
+ * @param options to pass an errorHandler callback, if desired
2405
+ * @returns void
2406
+ */
2407
+ AdvancedTableComponent.prototype.exportView = function (options) {
2408
+ return __awaiter(this, void 0, void 0, function () {
2409
+ var exportSettings, exportLimit, totalDisplayedItems, _a, body, header, previousDataState, targetDataState, _b, body, header, err_1;
2410
+ return __generator(this, function (_c) {
2411
+ switch (_c.label) {
2412
+ case 0:
2413
+ _c.trys.push([0, 4, 5, 6]);
2414
+ this._loading.showLoading();
2415
+ // validate query items and config
2416
+ if (!(this._lastQueryTotalItems && this.config)) {
2417
+ // do nothing
2418
+ return [2 /*return*/];
2419
+ }
2420
+ exportSettings = this._configuration.settings;
2421
+ exportLimit = (exportSettings && exportSettings.tables && exportSettings.tables.exportLimit > 0)
2422
+ ? exportSettings.tables.exportLimit : MAX_EXPORT_ITEMS;
2423
+ // and validate it
2424
+ if (this._lastQueryTotalItems > exportLimit) {
2425
+ // call error handler
2426
+ // provide a recognizible error type
2427
+ if (options && options.errorHandler) {
2428
+ options.errorHandler(new ExportLimitExceededError('Export limit exceeded'));
2429
+ return [2 /*return*/];
2430
+ }
2431
+ // or show warning modal and exit
2432
+ this._modalService.showWarningDialog(this._translateService.instant('Tables.ExportList'), this._translateService.instant('Tables.ExportLimitExceeded', { dataLength: this._lastQueryTotalItems, exportLimit: exportLimit }), DIALOG_BUTTONS.Ok);
2433
+ return [2 /*return*/];
2434
+ }
2435
+ totalDisplayedItems = Array.from(this.dataTable.context[0].aiDisplay).length;
2436
+ if (!(totalDisplayedItems === this._lastQueryTotalItems)) return [3 /*break*/, 1];
2437
+ _a = this.getExportableData(), body = _a.body, header = _a.header;
2438
+ // and export them to excel
2439
+ this._exportSpreadsheet.export(body, this._translateService.instant(this.config.title || 'Tables.ExportResults') + ".xlsx", {
2440
+ header: header,
2441
+ skipHeader: false
2442
+ });
2443
+ return [3 /*break*/, 3];
2444
+ case 1:
2445
+ previousDataState = this.dataTable.rows().data().toArray();
2446
+ return [4 /*yield*/, this.lastQuery.take(exportLimit).getItems()];
2447
+ case 2:
2448
+ targetDataState = _c.sent();
2449
+ // change table data on the fly, but do not redraw
2450
+ this.dataTable.clear().rows.add(targetDataState);
2451
+ _b = this.getExportableData(), body = _b.body, header = _b.header;
2452
+ // reset table data
2453
+ this.dataTable.clear().rows.add(previousDataState);
2454
+ // and export target data to excel
2455
+ this._exportSpreadsheet.export(body, this._translateService.instant(this.config.title || 'Tables.ExportResults') + ".xlsx", {
2456
+ header: header,
2457
+ skipHeader: false
2458
+ });
2459
+ _c.label = 3;
2460
+ case 3:
2461
+ // exit
2462
+ return [2 /*return*/];
2463
+ case 4:
2464
+ err_1 = _c.sent();
2465
+ // log error
2466
+ console.error(err_1);
2467
+ // call error handler, if defined
2468
+ if (options && options.errorHandler) {
2469
+ options.errorHandler(err_1);
2470
+ }
2471
+ else {
2472
+ // use default error service
2473
+ this._errorService.showError(err_1, {
2474
+ continueLink: '.'
2475
+ });
2476
+ }
2477
+ return [3 /*break*/, 6];
2478
+ case 5:
2479
+ this._loading.hideLoading();
2480
+ return [7 /*endfinally*/];
2481
+ case 6: return [2 /*return*/];
2482
+ }
2483
+ });
2484
+ });
2485
+ };
2486
+ AdvancedTableComponent.prototype.getExportableData = function () {
2487
+ var _this = this;
2488
+ if (!(this.dataTable && this.dataTable.buttons
2489
+ && typeof this.dataTable.buttons.exportData === 'function' && this.config)) {
2490
+ return { body: [], header: [] };
2491
+ }
2492
+ // fetch exportable excel data
2493
+ var _a = this.dataTable.buttons.exportData(), body = _a.body, header = _a.header;
2494
+ var cleanupIndexes = [];
2495
+ // clean up headers
2496
+ header = header.filter(function (headerItem, index) {
2497
+ // exclude empty headers
2498
+ if (headerItem.trim().length === 0) {
2499
+ cleanupIndexes.push(index);
2500
+ return false;
2501
+ }
2502
+ // find item by title
2503
+ var findItem = _this.config.columns.find(function (column) {
2504
+ return column.title && column.title.length && _this._translateService.instant(column.title) === headerItem;
2505
+ });
2506
+ // exclude hidden columns
2507
+ if (findItem && findItem.hidden === true) {
2508
+ cleanupIndexes.push(index);
2509
+ return false;
2510
+ }
2511
+ return true;
2512
+ });
2513
+ // clean up body
2514
+ body = body.map(function (row) {
2515
+ return row.filter(function (_, rowIndex) {
2516
+ return cleanupIndexes.indexOf(rowIndex) === -1;
2517
+ });
2518
+ });
2519
+ return { body: body, header: header };
2520
+ };
2052
2521
  AdvancedTableComponent.decorators = [
2053
2522
  { type: Component, args: [{
2054
2523
  // tslint:disable-next-line: component-selector
2055
2524
  selector: 'app-advanced-table',
2056
- template: "\n <table #table class=\"dataTable\">\n </table>\n <div #emptyTable class=\"d-none\">\n <div>\n <div class=\"mt-4\">\n <div class=\"icon-circle bg-gray-300 border-gray-100\"></div>\n </div>\n <div class=\"mt-4\">\n <h4 class=\"font-3xl text-dark\" [translate]=\"'Tables.EmptyTableTitle'\"></h4>\n <p class=\"font-lg text-dark\" [translate]=\"'Tables.EmptyTableMessage'\"></p>\n </div>\n </div>\n </div>\n ",
2525
+ template: "\n <table #table class=\"dataTable\">\n </table>\n <div #emptyTable class=\"d-none\">\n <div>\n <div class=\"mt-4\">\n <div class=\"icon-circle bg-gray-300 border-gray-100\"></div>\n </div>\n <div class=\"mt-4\">\n <h4 class=\"font-3xl text-dark\" [translate]=\"'Tables.EmptyTableTitle'\"></h4>\n <p class=\"font-lg text-dark\" [translate]=\"'Tables.EmptyTableMessage'\"></p>\n </div>\n </div>\n </div>\n <div #errorTemplate class=\"d-none error-message\">\n <div class=\"text-center\">\n <div class=\"mt-4\">\n <div class=\"icon-circle bg-danger border-gray-100\"></div>\n </div>\n <div class=\"mt-4\">\n <h4 class=\"font-3xl text-secondary\" [translate]=\"'Tables.DataError.Title'\"></h4>\n <p class=\"font-lg text-secondary mb-1\" [translate]=\"'Tables.DataError.Message'\"></p>\n <p class=\"font-lg text-secondary error-inner-message\">\n <small></small>\n </p>\n </div>\n </div>\n </div>\n ",
2057
2526
  encapsulation: ViewEncapsulation.None,
2058
- styles: ["table.dataTable thead .sorting{background-image:none}table.dataTable thead .sorting_asc{background-position:95% 60%;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAACXBIWXMAAAsSAAALEgHS3X78AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAEtJREFUKJFjYBgywAOKMQALFjE/BgaGTCibjYGBYRM+kz0ZGBh2MTAw8DAwMHAxMDBsY2BgCCBGMQzg1IRNMV5NuVAJXIALqmYwAgBBkAlPRCLcLwAAAABJRU5ErkJggg==)}table.dataTable thead .sorting_desc{background-position:95% 60%;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAACXBIWXMAAArzAAAK8wHvFRX1AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAFNJREFUKJHVzTEKgDAQRNGHZfBg2sSTeDMLKwXPYuVJbBKQQEyrH6bZ+cPyWWaElz4kR5cOJ1b0FXnBVRYjjmIUsGGqvX6OmnImYk+JLTkzpPyBGwrtCvfBe56nAAAAAElFTkSuQmCC)}table.dataTable thead th{color:#73818e;font-size:.75rem;font-weight:600;padding-top:16px;padding-bottom:4px;border-bottom:none;padding-left:8px}table.dataTable tbody tr:first-child td:first-child{border-radius:6px 0}table.dataTable tbody tr:first-child td:last-child{border-radius:0 6px}table.dataTable tbody tr{border-radius:6px}table.dataTable tbody tr td:first-child{border-left:1px solid #c2cfd6}table.dataTable tbody tr td:last-child{border-right:1px solid #c2cfd6}table.dataTable tbody tr td{padding-top:8px;padding-bottom:8px;border-top:1px solid #c2cfd6}table.dataTable tbody tr:last-child td:first-child{border-radius:0 0 0 6px}table.dataTable tbody tr:last-child td:last-child{border-radius:0 0 6px}table.dataTable tbody tr:last-child td{border-bottom:1px solid #c2cfd6}table.dataTable td.dataTables_empty{border:none!important}table.dataTable.no-footer{border-bottom:none}.dataTables_paginate .btn.previous{margin-right:8px}.dataTables_paginate .btn.next{margin-left:8px}.dataTables_info,.dataTables_paginate{margin-top:1rem}.dataTables_paginate span .btn{border-radius:1.5rem}.dataTables_filter{display:none}.dataTables_wrapper.no-footer .dataTables_scrollBody{border-bottom:0;overflow:auto}.dataTables_paginate{display:none}.dataTable.processing{opacity:15%}.dataTables_wrapper .dataTables_processing{background:0 0;position:absolute;display:inline-block;top:25%;z-index:5;color:#73818e}.text-decoration-line-through{text-decoration:line-through!important}tr.removed .checkbox+label{visibility:hidden}"]
2527
+ styles: ["table.dataTable thead .sorting{background-image:none}table.dataTable thead .sorting_asc{background-position:95% 60%;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAACXBIWXMAAAsSAAALEgHS3X78AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAEtJREFUKJFjYBgywAOKMQALFjE/BgaGTCibjYGBYRM+kz0ZGBh2MTAw8DAwMHAxMDBsY2BgCCBGMQzg1IRNMV5NuVAJXIALqmYwAgBBkAlPRCLcLwAAAABJRU5ErkJggg==)}table.dataTable thead .sorting_desc{background-position:95% 60%;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAACXBIWXMAAArzAAAK8wHvFRX1AAAAGXRFWHRTb2Z0d2FyZQB3d3cuaW5rc2NhcGUub3Jnm+48GgAAAFNJREFUKJHVzTEKgDAQRNGHZfBg2sSTeDMLKwXPYuVJbBKQQEyrH6bZ+cPyWWaElz4kR5cOJ1b0FXnBVRYjjmIUsGGqvX6OmnImYk+JLTkzpPyBGwrtCvfBe56nAAAAAElFTkSuQmCC)}table.dataTable thead th{color:#73818e;font-size:.75rem;font-weight:600;padding-top:16px;padding-bottom:4px;border-bottom:none;padding-left:8px}table.dataTable tbody tr:first-child td:first-child{border-radius:6px 0}table.dataTable tbody tr:first-child td:last-child{border-radius:0 6px}table.dataTable tbody tr{border-radius:6px}table.dataTable tbody tr td:first-child{border-left:1px solid #c2cfd6}table.dataTable tbody tr td:last-child{border-right:1px solid #c2cfd6}table.dataTable tbody tr td{padding-top:8px;padding-bottom:8px;border-top:1px solid #c2cfd6}table.dataTable tbody tr:last-child td:first-child{border-radius:0 0 0 6px}table.dataTable tbody tr:last-child td:last-child{border-radius:0 0 6px}table.dataTable tbody tr:last-child td{border-bottom:1px solid #c2cfd6}table.dataTable td.dataTables_empty{border:none!important}table.dataTable .error-inner-message>small{overflow-wrap:break-word}table.dataTable.no-footer{border-bottom:none}.dataTables_paginate .btn.previous{margin-right:8px}.dataTables_paginate .btn.next{margin-left:8px}.dataTables_info,.dataTables_paginate{margin-top:1rem}.dataTables_paginate span .btn{border-radius:1.5rem}.dataTables_filter{display:none}.dataTables_wrapper.no-footer .dataTables_scrollBody{border-bottom:0;overflow:auto}.dataTables_paginate{display:none}.dataTable.processing{opacity:15%}.dataTables_wrapper .dataTables_processing{background:0 0;position:absolute;display:inline-block;top:25%;z-index:5;color:#73818e}.text-decoration-line-through{text-decoration:line-through!important}tr.removed .checkbox+label{visibility:hidden}"]
2059
2528
  }] }
2060
2529
  ];
2061
2530
  /** @nocollapse */
@@ -2070,11 +2539,16 @@ var AdvancedTableComponent = /** @class */ (function () {
2070
2539
  { type: TemplatePipe },
2071
2540
  { type: LoadingService },
2072
2541
  { type: HttpClient },
2073
- { type: ColumnSelectorService }
2542
+ { type: ColumnSelectorService },
2543
+ { type: ConfigurationService },
2544
+ { type: ExportSpreadsheetService },
2545
+ { type: ModalService },
2546
+ { type: ErrorService }
2074
2547
  ]; };
2075
2548
  AdvancedTableComponent.propDecorators = {
2076
2549
  table: [{ type: ViewChild, args: ['table',] }],
2077
2550
  emptyTable: [{ type: ViewChild, args: ['emptyTable',] }],
2551
+ errorTemplate: [{ type: ViewChild, args: ['errorTemplate',] }],
2078
2552
  loadingTable: [{ type: ViewChild, args: ['loadingTable',] }],
2079
2553
  height: [{ type: Input }],
2080
2554
  showActions: [{ type: Input }],
@@ -3048,63 +3522,26 @@ var AdvancedTableConfigurationResolver = /** @class */ (function () {
3048
3522
  ]; };
3049
3523
  return AdvancedTableConfigurationResolver;
3050
3524
  }());
3051
- var AdvancedSearchConfigurationResolver = /** @class */ (function () {
3052
- function AdvancedSearchConfigurationResolver(_http) {
3053
- this._http = _http;
3054
- }
3055
- AdvancedSearchConfigurationResolver.prototype.resolve = function (route, state) {
3056
- // get list
3057
- var list = route.data.list || route.params.list;
3058
- // get model
3059
- var model = route.data.model || route.params.model;
3060
- // get configuration
3061
- return this._http.get("assets/lists/" + model + "/search." + list + ".json").toPromise();
3062
- };
3063
- AdvancedSearchConfigurationResolver.decorators = [
3064
- { type: Injectable }
3065
- ];
3066
- /** @nocollapse */
3067
- AdvancedSearchConfigurationResolver.ctorParameters = function () { return [
3068
- { type: HttpClient }
3069
- ]; };
3070
- return AdvancedSearchConfigurationResolver;
3071
- }());
3072
-
3073
- var ActivatedTableService = /** @class */ (function () {
3074
- function ActivatedTableService(_router, _activatedRoute) {
3075
- var _this = this;
3076
- this._router = _router;
3077
- this._activatedRoute = _activatedRoute;
3078
- _router.events.forEach(function (event) {
3079
- if (event instanceof NavigationStart) {
3080
- if (_this._activeTable) {
3081
- _this._activeTable = null;
3082
- }
3083
- }
3084
- });
3085
- }
3086
- Object.defineProperty(ActivatedTableService.prototype, "activeTable", {
3087
- get: function () {
3088
- return this._activeTable;
3089
- },
3090
- set: function (tableComponent) {
3091
- this._activeTable = tableComponent;
3092
- },
3093
- enumerable: true,
3094
- configurable: true
3095
- });
3096
- ActivatedTableService.decorators = [
3097
- { type: Injectable, args: [{
3098
- providedIn: 'root'
3099
- },] }
3525
+ var AdvancedSearchConfigurationResolver = /** @class */ (function () {
3526
+ function AdvancedSearchConfigurationResolver(_http) {
3527
+ this._http = _http;
3528
+ }
3529
+ AdvancedSearchConfigurationResolver.prototype.resolve = function (route, state) {
3530
+ // get list
3531
+ var list = route.data.list || route.params.list;
3532
+ // get model
3533
+ var model = route.data.model || route.params.model;
3534
+ // get configuration
3535
+ return this._http.get("assets/lists/" + model + "/search." + list + ".json").toPromise();
3536
+ };
3537
+ AdvancedSearchConfigurationResolver.decorators = [
3538
+ { type: Injectable }
3100
3539
  ];
3101
3540
  /** @nocollapse */
3102
- ActivatedTableService.ctorParameters = function () { return [
3103
- { type: Router },
3104
- { type: ActivatedRoute }
3541
+ AdvancedSearchConfigurationResolver.ctorParameters = function () { return [
3542
+ { type: HttpClient }
3105
3543
  ]; };
3106
- ActivatedTableService.ngInjectableDef = defineInjectable({ factory: function ActivatedTableService_Factory() { return new ActivatedTableService(inject(Router), inject(ActivatedRoute)); }, token: ActivatedTableService, providedIn: "root" });
3107
- return ActivatedTableService;
3544
+ return AdvancedSearchConfigurationResolver;
3108
3545
  }());
3109
3546
 
3110
3547
  var AdvancedTableSettingsComponent = /** @class */ (function () {
@@ -4018,251 +4455,6 @@ var AdvancedTableEditorDirective = /** @class */ (function () {
4018
4455
  return AdvancedTableEditorDirective;
4019
4456
  }());
4020
4457
 
4021
- var MAX_EXPORT_ITEMS = 500;
4022
- var BtnExpDirective = /** @class */ (function () {
4023
- function BtnExpDirective(_activatedTable, _context, _config, _translate, _loadingService, _errorService) {
4024
- this._activatedTable = _activatedTable;
4025
- this._context = _context;
4026
- this._config = _config;
4027
- this._translate = _translate;
4028
- this._loadingService = _loadingService;
4029
- this._errorService = _errorService;
4030
- }
4031
- BtnExpDirective.prototype.clickEvent = function (event) {
4032
- return __awaiter(this, void 0, void 0, function () {
4033
- var lastQuery, tableConfig, serviceHeaders, queryModel, query, queryParams, exportSettings, maxExportItems, url;
4034
- return __generator(this, function (_a) {
4035
- event.preventDefault();
4036
- event.stopPropagation();
4037
- if (this._activatedTable.activeTable) {
4038
- lastQuery = this._activatedTable.activeTable.lastQuery;
4039
- tableConfig = this._activatedTable.activeTable.config;
4040
- serviceHeaders = this._context.getService().getHeaders();
4041
- queryModel = lastQuery.getModel();
4042
- query = this._context.model(queryModel).asQueryable();
4043
- queryParams = lastQuery.getParams();
4044
- query = this.constructQuery(query, queryParams, tableConfig, serviceHeaders);
4045
- exportSettings = this._config.settings;
4046
- maxExportItems = exportSettings && exportSettings.tables && exportSettings.tables.exportLimit;
4047
- if (maxExportItems && typeof maxExportItems === 'number' && maxExportItems > 0) {
4048
- query.skip(0).take(maxExportItems);
4049
- }
4050
- else {
4051
- query.skip(0).take(MAX_EXPORT_ITEMS);
4052
- }
4053
- url = this.constructURL(query);
4054
- this.downloadFile(url, query.getService().getHeaders(), query.getModel());
4055
- }
4056
- return [2 /*return*/];
4057
- });
4058
- });
4059
- };
4060
- /**
4061
- * Sets the parameters to the query based on
4062
- * the active filters of the activated table
4063
- * @param {ClientDataQueryable} query
4064
- * @param params: The filters of the last query of the activated table
4065
- * @return ClientDataQueryable
4066
- */
4067
- BtnExpDirective.prototype.setParams = function (query, params) {
4068
- if (params && typeof params === 'object') {
4069
- Object.keys(params).forEach(function (key) {
4070
- query.setParam(key, params[key]);
4071
- });
4072
- }
4073
- return query;
4074
- };
4075
- /**
4076
- * Sets the headers to the query based on
4077
- * the default headers of the DataContext
4078
- * and appending the accept header to get
4079
- * an xlsx file from the API
4080
- * @param {ClientDataQueryable} query
4081
- * @param {Headers} headers: The headers to append to the query
4082
- * @return ClientDataQueryable
4083
- */
4084
- BtnExpDirective.prototype.setHeaders = function (query, headers) {
4085
- Object.keys(headers).forEach(function (key) {
4086
- if (headers.hasOwnProperty(key)) {
4087
- query.getService().setHeader(key, headers[key]);
4088
- }
4089
- });
4090
- // sets a header to accept xlsx files
4091
- query.getService().setHeader('Accept', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
4092
- return query;
4093
- };
4094
- /**
4095
- * Constructs the select parameter of the
4096
- * ClientDataQuery by replacing the target name
4097
- * of the field based on the localized translation
4098
- * of that property on the advanced tabled
4099
- * @param {ClientDataQueryable} query
4100
- * @param tableConfig: The configuration of the activated table
4101
- * @return ClientDataQueryable
4102
- */
4103
- BtnExpDirective.prototype.constructQueryParam = function (query, tableConfig) {
4104
- var _this = this;
4105
- var selectQuery = query.getParams().$select;
4106
- var selectQueryArray = selectQuery.split(',');
4107
- selectQueryArray = selectQueryArray.map(function (select$$1) {
4108
- var e_1, _a, e_2, _b;
4109
- var words = select$$1.split(' ');
4110
- if (words.length === 3) {
4111
- if (tableConfig && tableConfig.columns) {
4112
- try {
4113
- for (var _c = __values(tableConfig.columns), _d = _c.next(); !_d.done; _d = _c.next()) {
4114
- var column = _d.value;
4115
- if (column.property === words[2] && column.title) {
4116
- words[2] = "\"" + _this._translate.instant(column.title) + "\"";
4117
- }
4118
- else if (column.property === words[2]) {
4119
- words[2] = "\"" + _this._translate.instant(words[2]) + "\"";
4120
- }
4121
- }
4122
- }
4123
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
4124
- finally {
4125
- try {
4126
- if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
4127
- }
4128
- finally { if (e_1) throw e_1.error; }
4129
- }
4130
- }
4131
- }
4132
- if (words.length === 1) {
4133
- if (tableConfig && tableConfig.columns) {
4134
- try {
4135
- for (var _e = __values(tableConfig.columns), _f = _e.next(); !_f.done; _f = _e.next()) {
4136
- var column = _f.value;
4137
- if (column.name === words[0] && column.title) {
4138
- words[0] = words[0] + " as \"" + _this._translate.instant(column.title) + "\"";
4139
- break;
4140
- }
4141
- else if (column.name === words[0] && column.property) {
4142
- words[0] = words[0] + " as \"" + _this._translate.instant(column.property) + "\"";
4143
- break;
4144
- }
4145
- else if (words[0] === column.name && words[0] === "id" && column.hidden) {
4146
- break;
4147
- }
4148
- else if (words[0] == column.name || words[0] === column.property) {
4149
- words[0] = words[0] + " as \"" + _this._translate.instant(words[0]) + "\"";
4150
- }
4151
- }
4152
- }
4153
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
4154
- finally {
4155
- try {
4156
- if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
4157
- }
4158
- finally { if (e_2) throw e_2.error; }
4159
- }
4160
- }
4161
- return words[0];
4162
- }
4163
- return words.join(' ');
4164
- });
4165
- selectQuery = selectQueryArray.join(',');
4166
- query.setParam('$select', selectQuery);
4167
- return query;
4168
- };
4169
- /**
4170
- * Constructs the fetch URL based the query parameters
4171
- * @param {ClientDataQueryable} query
4172
- * @return String
4173
- */
4174
- BtnExpDirective.prototype.constructURL = function (query) {
4175
- var baseURL = query.getService().getBase();
4176
- var url = baseURL.endsWith('/') ? (baseURL + query.getModel() + '?') : (baseURL + '/' + query.getModel() + '?');
4177
- Object.keys(query.getParams()).forEach(function (key, index) {
4178
- if (index === 0) {
4179
- url += key + '=' + query.getParams()[key];
4180
- }
4181
- else {
4182
- url += '&' + key + '=' + query.getParams()[key];
4183
- }
4184
- });
4185
- return url;
4186
- };
4187
- /**
4188
- * Constructs the query by setting the parameters of the
4189
- * advanced table's active filters, sets the necessary headers
4190
- * and build the select parameter of the query
4191
- * @param {ClientDataQueryable} query
4192
- * @param params: The filters of the last query of the activated table
4193
- * @param tableConfig: The configuration of the activated table
4194
- * @param {Headers} headers: The headers to append to the query
4195
- * @return ClientDataQueryable
4196
- */
4197
- BtnExpDirective.prototype.constructQuery = function (query, params, tableConfig, headers) {
4198
- var _query = this.setParams(query, params);
4199
- _query = this.setHeaders(_query, headers);
4200
- _query = this.constructQueryParam(_query, tableConfig);
4201
- return _query;
4202
- };
4203
- /**
4204
- * Fetches and saves the xlsx file
4205
- * @param {String} url
4206
- * @param {Headers} serviceHeaders: The headers to append to the query
4207
- * @param modelName: The model name of the advanced table
4208
- */
4209
- BtnExpDirective.prototype.downloadFile = function (url, serviceHeaders, modelName) {
4210
- var _this = this;
4211
- this._loadingService.showLoading();
4212
- fetch(encodeURI(url), {
4213
- headers: serviceHeaders,
4214
- credentials: 'include'
4215
- }).then(function (response) {
4216
- if (response && !response.ok) {
4217
- throw new ResponseError(response.statusText, response.status);
4218
- }
4219
- return response.blob();
4220
- }).then(function (blob) {
4221
- var objectUrl = window.URL.createObjectURL(blob);
4222
- var a = document.createElement('a');
4223
- document.body.appendChild(a);
4224
- a.setAttribute('style', 'display: none');
4225
- a.href = objectUrl;
4226
- var downloadName = modelName + ".xlsx";
4227
- a.download = downloadName;
4228
- // this adds support for IE and MS Edge (up to version 44.19041)
4229
- if (window.navigator && window.navigator.msSaveOrOpenBlob) {
4230
- window.navigator.msSaveOrOpenBlob(blob, downloadName);
4231
- }
4232
- else {
4233
- // for all other browsers
4234
- a.click();
4235
- }
4236
- window.URL.revokeObjectURL(objectUrl);
4237
- a.remove();
4238
- _this._loadingService.hideLoading();
4239
- }).catch(function (err) {
4240
- _this._loadingService.hideLoading();
4241
- _this._errorService.showError(err, {
4242
- continueLink: '.'
4243
- });
4244
- });
4245
- };
4246
- BtnExpDirective.decorators = [
4247
- { type: Directive, args: [{
4248
- selector: '.universis-btn-export'
4249
- },] }
4250
- ];
4251
- /** @nocollapse */
4252
- BtnExpDirective.ctorParameters = function () { return [
4253
- { type: ActivatedTableService },
4254
- { type: AngularDataContext },
4255
- { type: ConfigurationService },
4256
- { type: TranslateService },
4257
- { type: LoadingService },
4258
- { type: ErrorService }
4259
- ]; };
4260
- BtnExpDirective.propDecorators = {
4261
- clickEvent: [{ type: HostListener, args: ['click', ['$event'],] }]
4262
- };
4263
- return BtnExpDirective;
4264
- }());
4265
-
4266
4458
  var AdvancedAggregatorService = /** @class */ (function () {
4267
4459
  function AdvancedAggregatorService(_context, _template) {
4268
4460
  this._context = _context;
@@ -4825,6 +5017,8 @@ var ParseTitlePipe = /** @class */ (function () {
4825
5017
  return ParseTitlePipe;
4826
5018
  }());
4827
5019
 
5020
+ // tslint:disable: quotemark
5021
+ // tslint:disable: max-line-length
4828
5022
  var TABLES_EL = {
4829
5023
  "Tables": {
4830
5024
  "Export": "Εξαγωγή",
@@ -4904,7 +5098,14 @@ var TABLES_EL = {
4904
5098
  "MoveColumnHelp": "Χρησιμοποιήστε τα πλήκτρα 'Επάνω' και 'Κάτω' για να αλλάξετε την σειρά εμφάνισης των στηλών του πίνακα.",
4905
5099
  "UnknownColumn": "Άγνωστο",
4906
5100
  "SelectColumn": "Επιλογή",
4907
- "ActionLinkColumn": "Ενέργειες"
5101
+ "ActionLinkColumn": "Ενέργειες",
5102
+ "DataError": {
5103
+ "Title": "Σφάλμα κατά την παραλαβή των δεδομένων",
5104
+ "Message": "Συνέβη σφάλμα κατά την παραλαβή των δεδομένων. Προσπαθήστε ξανά ή τροποποιήστε τα στοιχεία αναζήτησης."
5105
+ },
5106
+ "ExportList": "Εξαγωγή λίστας",
5107
+ "ExportLimitExceeded": "Το πλήθος των στοιχείων προς εξαγωγή ({{dataLength}}) ξεπερνάει το μέγιστο επιτρεπτό ({{exportLimit}}). Παρακαλούμε προσαρμόστε τα φίλτρα της αναζήτησης και προσπαθήστε ξανά.",
5108
+ "ExportResults": "Δεδομένα λίστας"
4908
5109
  },
4909
5110
  "TrueFalse": {
4910
5111
  "long": {
@@ -4945,6 +5146,8 @@ var TABLES_EL = {
4945
5146
  }
4946
5147
  };
4947
5148
 
5149
+ // tslint:disable: quotemark
5150
+ // tslint:disable: max-line-length
4948
5151
  var TABLES_EN = {
4949
5152
  "Tables": {
4950
5153
  "Export": "Export",
@@ -5023,7 +5226,14 @@ var TABLES_EN = {
5023
5226
  "MoveColumnHelp": "Use 'Move up' and 'Move down' buttons to change column order.",
5024
5227
  "UnknownColumn": "Unknown",
5025
5228
  "SelectColumn": "Select",
5026
- "ActionLinkColumn": "Actions"
5229
+ "ActionLinkColumn": "Actions",
5230
+ "DataError": {
5231
+ "Title": "Error while getting data",
5232
+ "Message": "An error occurred while getting data. Please try again or change your criteria."
5233
+ },
5234
+ "ExportList": "Export list",
5235
+ "ExportLimitExceeded": "The number of items that are to be exported ({{dataLength}}) exceeds the export limit ({{exportLimit}}). Please apply more specific filters to the search.",
5236
+ "ExportResults": "Exported list"
5027
5237
  },
5028
5238
  "TrueFalse": {
5029
5239
  "long": {
@@ -5337,7 +5547,7 @@ var AdvancedSearchRouterState = /** @class */ (function (_super) {
5337
5547
  return AdvancedSearchRouterState;
5338
5548
  }(AdvancedSearchState));
5339
5549
 
5340
- var ɵ0 = FORMATTERS;
5550
+ var ɵ0$1 = FORMATTERS;
5341
5551
  var TablesModule = /** @class */ (function () {
5342
5552
  function TablesModule(_translateService) {
5343
5553
  this._translateService = _translateService;
@@ -5375,7 +5585,7 @@ var TablesModule = /** @class */ (function () {
5375
5585
  providers: [DatePipe, TemplatePipe,
5376
5586
  {
5377
5587
  provide: COLUMN_FORMATTERS,
5378
- useValue: ɵ0
5588
+ useValue: ɵ0$1
5379
5589
  },
5380
5590
  AdvancedTableConfigurationResolver,
5381
5591
  AdvancedSearchConfigurationResolver,
@@ -5454,6 +5664,6 @@ var TablesModule = /** @class */ (function () {
5454
5664
  * Generated bundle index. Do not edit.
5455
5665
  */
5456
5666
 
5457
- export { AdvancedSearchState as ɵa, AdvancedTableState as ɵc, AdvancedSearchRouterState as ɵd, AdvancedListComponent, AdvancedRowActionComponent, AdvancedSearchFormComponent, AdvancedSelectComponent, AdvancedSelectService, AdvancedTableConfigurationResolver, AdvancedSearchConfigurationResolver, AdvancedColumnFormatter, NestedPropertyFormatter, ButtonFormatter, LinkFormatter, ActionLinkFormatter, ActionButtonFormatter, ActionSplitButtonFormatter, SelectRowFormatter, TemplateFormatter, TrueFalseFormatter, TranslationFormatter, DateTimeFormatter, NgClassFormatter, LanguageFormatter, COLUMN_FORMATTERS, AdvancedTableConfiguration, AdvancedTableComponent, AdvancedTableSettingsComponent, AdvancedTableSearchBaseComponent, AdvancedTableSearchComponent, FORMATTERS, AdvancedFilterValueProvider, AdvancedTableModalBaseTemplate, AdvancedTableModalBaseComponent, SimpleHeaderToolsComponent, TableSimpleHeaderComponent, AdvancedTableNotNullError, AdvancedTableEditorDirective, BtnExpDirective, AdvancedAggregatorComponent, AdvancedAggregatorListComponent, AddItemsComponent, AdvancedAggregatorPipe, ParseTitlePipe, AdvancedAggregatorService, TablesModule, ɵ0, ActivatedTableService, ColumnSelectorService, ColumnSelectorComponent, initialState, tableInitialState, tableReducer, tableReducers, featureName, getTablesState, selectTable };
5667
+ export { AdvancedSearchState as ɵa, AdvancedTableState as ɵc, AdvancedSearchRouterState as ɵd, AdvancedListComponent, AdvancedRowActionComponent, AdvancedSearchFormComponent, AdvancedSelectComponent, AdvancedSelectService, AdvancedTableConfigurationResolver, AdvancedSearchConfigurationResolver, AdvancedColumnFormatter, NestedPropertyFormatter, ButtonFormatter, LinkFormatter, ActionLinkFormatter, ActionButtonFormatter, ActionSplitButtonFormatter, SelectRowFormatter, TemplateFormatter, TrueFalseFormatter, TranslationFormatter, DateTimeFormatter, NgClassFormatter, LanguageFormatter, COLUMN_FORMATTERS, ExportLimitExceededError, AdvancedTableConfiguration, AdvancedTableComponent, ɵ0, AdvancedTableSettingsComponent, AdvancedTableSearchBaseComponent, AdvancedTableSearchComponent, FORMATTERS, AdvancedFilterValueProvider, AdvancedTableModalBaseTemplate, AdvancedTableModalBaseComponent, SimpleHeaderToolsComponent, TableSimpleHeaderComponent, AdvancedTableNotNullError, AdvancedTableEditorDirective, MAX_EXPORT_ITEMS, BtnExpDirective, AdvancedAggregatorComponent, AdvancedAggregatorListComponent, AddItemsComponent, AdvancedAggregatorPipe, ParseTitlePipe, AdvancedAggregatorService, TablesModule, ActivatedTableService, ColumnSelectorService, ColumnSelectorComponent, initialState, tableInitialState, tableReducer, tableReducers, featureName, getTablesState, selectTable };
5458
5668
 
5459
5669
  //# sourceMappingURL=universis-ngx-tables.js.map