@porscheinformatik/material-addons 10.2.5 → 10.3.2

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.
@@ -1,8 +1,8 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/router'), require('@angular/material/button'), require('@angular/material/icon'), require('@angular/material/tooltip'), require('@angular/material/form-field'), require('@angular/material/input'), require('@angular/forms'), require('@angular/platform-browser'), require('@ngx-translate/core'), require('rxjs'), require('@angular/cdk/layout'), require('rxjs/operators'), require('@angular/material/menu'), require('@angular/material/toolbar'), require('@angular/material/badge'), require('@angular/material/card'), require('@angular/animations'), require('@angular/material/table'), require('@angular/material/sort'), require('@angular/material/paginator'), require('@angular/cdk/bidi'), require('@angular/cdk/stepper'), require('@angular/cdk/a11y'), require('@angular/flex-layout'), require('@angular/material/stepper')) :
3
- typeof define === 'function' && define.amd ? define('@porscheinformatik/material-addons', ['exports', '@angular/core', '@angular/common', '@angular/router', '@angular/material/button', '@angular/material/icon', '@angular/material/tooltip', '@angular/material/form-field', '@angular/material/input', '@angular/forms', '@angular/platform-browser', '@ngx-translate/core', 'rxjs', '@angular/cdk/layout', 'rxjs/operators', '@angular/material/menu', '@angular/material/toolbar', '@angular/material/badge', '@angular/material/card', '@angular/animations', '@angular/material/table', '@angular/material/sort', '@angular/material/paginator', '@angular/cdk/bidi', '@angular/cdk/stepper', '@angular/cdk/a11y', '@angular/flex-layout', '@angular/material/stepper'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.porscheinformatik = global.porscheinformatik || {}, global.porscheinformatik['material-addons'] = {}), global.ng.core, global.ng.common, global.ng.router, global.ng.material.button, global.ng.material.icon, global.ng.material.tooltip, global.ng.material.formField, global.ng.material.input, global.ng.forms, global.ng.platformBrowser, global.i2, global.rxjs, global.ng.cdk.layout, global.rxjs.operators, global.ng.material.menu, global.ng.material.toolbar, global.ng.material.badge, global.ng.material.card, global.ng.animations, global.ng.material.table, global.ng.material.sort, global.ng.material.paginator, global.ng.cdk.bidi, global.ng.cdk.stepper, global.ng.cdk.a11y, global.ng.flexLayout, global.ng.material.stepper));
5
- }(this, (function (exports, i0, common, i1, button, icon, tooltip, formField, input, forms, platformBrowser, i2, rxjs, layout, operators, menu, toolbar, badge, card, animations, table, sort, paginator, bidi, stepper, a11y, flexLayout, stepper$1) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('@angular/router'), require('@angular/material/button'), require('@angular/material/icon'), require('@angular/material/tooltip'), require('@angular/material/form-field'), require('@angular/material/input'), require('@angular/forms'), require('@angular/platform-browser'), require('@ngx-translate/core'), require('rxjs'), require('@angular/cdk/layout'), require('rxjs/operators'), require('@angular/material/menu'), require('@angular/material/toolbar'), require('@angular/material/badge'), require('@angular/material/card'), require('@angular/animations'), require('@angular/material/table'), require('@angular/material/sort'), require('@angular/material/paginator'), require('@angular/cdk/collections'), require('uuid'), require('@angular/material/checkbox'), require('@angular/material/progress-spinner'), require('@angular/cdk/bidi'), require('@angular/cdk/stepper'), require('@angular/cdk/a11y'), require('@angular/flex-layout'), require('@angular/material/stepper')) :
3
+ typeof define === 'function' && define.amd ? define('@porscheinformatik/material-addons', ['exports', '@angular/core', '@angular/common', '@angular/router', '@angular/material/button', '@angular/material/icon', '@angular/material/tooltip', '@angular/material/form-field', '@angular/material/input', '@angular/forms', '@angular/platform-browser', '@ngx-translate/core', 'rxjs', '@angular/cdk/layout', 'rxjs/operators', '@angular/material/menu', '@angular/material/toolbar', '@angular/material/badge', '@angular/material/card', '@angular/animations', '@angular/material/table', '@angular/material/sort', '@angular/material/paginator', '@angular/cdk/collections', 'uuid', '@angular/material/checkbox', '@angular/material/progress-spinner', '@angular/cdk/bidi', '@angular/cdk/stepper', '@angular/cdk/a11y', '@angular/flex-layout', '@angular/material/stepper'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.porscheinformatik = global.porscheinformatik || {}, global.porscheinformatik['material-addons'] = {}), global.ng.core, global.ng.common, global.ng.router, global.ng.material.button, global.ng.material.icon, global.ng.material.tooltip, global.ng.material.formField, global.ng.material.input, global.ng.forms, global.ng.platformBrowser, global.i2, global.rxjs, global.ng.cdk.layout, global.rxjs.operators, global.ng.material.menu, global.ng.material.toolbar, global.ng.material.badge, global.ng.material.card, global.ng.animations, global.ng.material.table, global.ng.material.sort, global.ng.material.paginator, global.ng.cdk.collections, global.uuid, global.ng.material.checkbox, global.ng.material.progressSpinner, global.ng.cdk.bidi, global.ng.cdk.stepper, global.ng.cdk.a11y, global.ng.flexLayout, global.ng.material.stepper));
5
+ }(this, (function (exports, i0, common, i1, button, icon, tooltip, formField, input, forms, platformBrowser, i2, rxjs, layout, operators, menu, toolbar, badge, card, animations, table, sort, paginator, collections, uuid, checkbox, progressSpinner, bidi, stepper, a11y, flexLayout, stepper$1) { 'use strict';
6
6
 
7
7
  var MaterialActionButtonComponent = /** @class */ (function () {
8
8
  function MaterialActionButtonComponent() {
@@ -1001,7 +1001,8 @@
1001
1001
  this.translate = translate;
1002
1002
  this.mainActions = []; // shown on the left, next to title, as big buttons
1003
1003
  this.toolbarActions = []; // shown on the right as icons
1004
- this.liftFabButtonHigher = false;
1004
+ this.toolbarActionsAlwaysAsMenu = false; // show the mobile view (burger menu) for toolbar actions
1005
+ this.toolbarActionsMenuTitle = 'More'; // title of the burger menu
1005
1006
  this.routerSubscription = this.router.events.subscribe(function (routingEvent) {
1006
1007
  if (routingEvent instanceof i1.NavigationEnd) {
1007
1008
  if (_this.currentUrl !== routingEvent.urlAfterRedirects) {
@@ -1045,6 +1046,12 @@
1045
1046
  ToolbarService.prototype.setDataTitle = function (dataTitle) {
1046
1047
  this.dataTitle = dataTitle;
1047
1048
  };
1049
+ ToolbarService.prototype.setToolbarActionsAlwaysAsMenu = function (toolbarActionsAlwaysAsMenu) {
1050
+ this.toolbarActionsAlwaysAsMenu = toolbarActionsAlwaysAsMenu;
1051
+ };
1052
+ ToolbarService.prototype.getToolbarActionsAlwaysAsMenu = function () {
1053
+ return this.toolbarActionsAlwaysAsMenu;
1054
+ };
1048
1055
  ToolbarService.prototype.getDataTitle = function () {
1049
1056
  return this.dataTitle;
1050
1057
  };
@@ -1057,6 +1064,12 @@
1057
1064
  ToolbarService.prototype.getBackAction = function () {
1058
1065
  return this.backAction;
1059
1066
  };
1067
+ ToolbarService.prototype.setToolbarActionsMenuTitle = function (toolbarActionsMenuTitle) {
1068
+ this.toolbarActionsMenuTitle = toolbarActionsMenuTitle;
1069
+ };
1070
+ ToolbarService.prototype.getToolbarActionsMenuTitle = function () {
1071
+ return this.toolbarActionsMenuTitle;
1072
+ };
1060
1073
  ToolbarService.prototype.addMainAction = function (mainAction) {
1061
1074
  var _this = this;
1062
1075
  this.translate
@@ -1149,12 +1162,23 @@
1149
1162
  ToolbarComponent.prototype.getBackAction = function () {
1150
1163
  return this.toolbarService.getBackAction();
1151
1164
  };
1165
+ ToolbarComponent.prototype.getToolbarActionsAlwaysAsMenu = function () {
1166
+ return this.toolbarService.getToolbarActionsAlwaysAsMenu();
1167
+ };
1168
+ ToolbarComponent.prototype.getToolbarActionsMenuTitle = function () {
1169
+ return this.toolbarService.getToolbarActionsMenuTitle();
1170
+ };
1171
+ ToolbarComponent.prototype.showBadgeForMenu = function () {
1172
+ return this.getToolbarActions()
1173
+ .slice(1) // the first icon is not shown in menu
1174
+ .filter(function (value) { return value.badge && value.badge.value; }).length > 0;
1175
+ };
1152
1176
  return ToolbarComponent;
1153
1177
  }());
1154
1178
  ToolbarComponent.decorators = [
1155
1179
  { type: i0.Component, args: [{
1156
1180
  selector: 'mad-toolbar',
1157
- template: "<mat-toolbar class=\"content-toolbar\">\n <a [routerLink]=\"getBackAction().routerLink\" *ngIf=\"isRouterLink()\">\n <button [id]=\"'go-back'\" color=\"primary\" mat-icon-button class=\"go-back-button\">\n <mat-icon>{{ getBackAction().matIcon }}</mat-icon>\n </button>\n </a>\n <a [href]=\"getBackAction().href\" *ngIf=\"isAbsoluteLink()\">\n <button [id]=\"'go-back'\" class=\"go-back-button\" color=\"primary\" mat-icon-button>\n <mat-icon>{{ getBackAction().matIcon }}</mat-icon>\n </button>\n </a>\n <a (click)=\"getBackAction().action()\" *ngIf=\"isAction()\">\n <button [id]=\"'go-back'\" color=\"primary\" mat-icon-button class=\"go-back-button\">\n <mat-icon>{{ getBackAction().matIcon }}</mat-icon>\n </button>\n </a>\n\n <span class=\"toolbar-title\">{{ getTitle() }}</span>\n\n <ng-container *ngFor=\"let mainAction of getMainActions(); let i = index\">\n <ng-container *ngIf=\"hasPermission(mainAction) | async\">\n <div *ngIf=\"!(isHandset$ | async)\">\n <a [routerLink]=\"mainAction.routerLink\">\n <mad-primary-button [id]=\"mainAction.matIcon\" style=\"margin-left: 56px\">\n <mat-icon>{{ mainAction.matIcon }}</mat-icon>\n {{ mainAction.actionName }}\n </mad-primary-button>\n </a>\n </div>\n <div *ngIf=\"isHandset$ | async\">\n <mad-material-action-button\n [actionName]=\"mainAction.actionName\"\n [icon]=\"mainAction.matIcon\"\n [liftHigher]=\"mainAction.liftHigherOnMobile\"\n [liftHigher2]=\"i > 0\"\n [routerLink]=\"mainAction.routerLink\"\n [id]=\"mainAction.matIcon\"\n >\n </mad-material-action-button>\n </div>\n </ng-container>\n </ng-container>\n\n <div class=\"right-aligned no-print\">\n <ng-container *ngFor=\"let action of getToolbarActions(); let i = index\">\n <ng-container *ngIf=\"hasPermission(action) | async\">\n <mad-icon-button\n (click)=\"action.action()\"\n *ngIf=\"!(isHandset$ | async) || i < (getToolbarActions().length > 2 ? 1 : 2)\"\n [id]=\"action.matIcon\"\n [matTooltip]=\"action.actionName\"\n type=\"button\"\n >\n <mat-icon\n [matBadgeColor]=\"action.badge ? action.badge.color : 'primary'\"\n matBadgePosition=\"below after\"\n [matBadge]=\"action.badge ? action.badge.value : null\"\n >{{ action.matIcon }}</mat-icon\n >\n </mad-icon-button>\n </ng-container>\n </ng-container>\n\n <ng-container *ngIf=\"isHandset$ | async\">\n <ng-container *ngIf=\"getToolbarActions().length > 2\">\n <mad-icon-button type=\"button\" [matMenuTriggerFor]=\"burgerMenu\" matTooltip=\"More\">\n <mat-icon>more_vert</mat-icon>\n </mad-icon-button>\n <mat-menu #burgerMenu=\"matMenu\">\n <ng-container *ngFor=\"let action of getToolbarActions(); let i = index\">\n <ng-container *ngIf=\"hasPermission(action) | async\">\n <button *ngIf=\"i >= 1\" mat-menu-item (click)=\"action.action()\">\n <mat-icon\n color=\"primary\"\n [matBadgeColor]=\"action.badge ? action.badge.color : 'primary'\"\n [matBadge]=\"action.badge ? action.badge.value : null\"\n matBadgePosition=\"below after\"\n >{{ action.matIcon }}</mat-icon\n >\n {{ action.actionName }}\n </button>\n </ng-container>\n </ng-container>\n </mat-menu>\n </ng-container>\n </ng-container>\n </div>\n</mat-toolbar>\n",
1181
+ template: "<mat-toolbar class=\"content-toolbar\">\n <a [routerLink]=\"getBackAction().routerLink\" *ngIf=\"isRouterLink()\">\n <button [id]=\"'go-back'\" color=\"primary\" mat-icon-button class=\"go-back-button\">\n <mat-icon>{{ getBackAction().matIcon }}</mat-icon>\n </button>\n </a>\n <a [href]=\"getBackAction().href\" *ngIf=\"isAbsoluteLink()\">\n <button [id]=\"'go-back'\" class=\"go-back-button\" color=\"primary\" mat-icon-button>\n <mat-icon>{{ getBackAction().matIcon }}</mat-icon>\n </button>\n </a>\n <a (click)=\"getBackAction().action()\" *ngIf=\"isAction()\">\n <button [id]=\"'go-back'\" color=\"primary\" mat-icon-button class=\"go-back-button\">\n <mat-icon>{{ getBackAction().matIcon }}</mat-icon>\n </button>\n </a>\n\n <span class=\"toolbar-title\">{{ getTitle() }}</span>\n\n <ng-container *ngFor=\"let mainAction of getMainActions(); let i = index\">\n <ng-container *ngIf=\"hasPermission(mainAction) | async\">\n <div *ngIf=\"!(isHandset$ | async)\">\n <a [routerLink]=\"mainAction.routerLink\">\n <mad-primary-button [id]=\"mainAction.matIcon\" style=\"margin-left: 56px\">\n <mat-icon>{{ mainAction.matIcon }}</mat-icon>\n {{ mainAction.actionName }}\n </mad-primary-button>\n </a>\n </div>\n <div *ngIf=\"isHandset$ | async\">\n <mad-material-action-button\n [actionName]=\"mainAction.actionName\"\n [icon]=\"mainAction.matIcon\"\n [liftHigher]=\"mainAction.liftHigherOnMobile\"\n [liftHigher2]=\"i > 0\"\n [routerLink]=\"mainAction.routerLink\"\n [id]=\"mainAction.matIcon\"\n >\n </mad-material-action-button>\n </div>\n </ng-container>\n </ng-container>\n\n <div class=\"right-aligned no-print\">\n <ng-container *ngFor=\"let action of getToolbarActions(); let i = index\">\n <ng-container *ngIf=\"hasPermission(action) | async\">\n <mad-icon-button\n (click)=\"action.action()\"\n *ngIf=\"(!(isHandset$ | async) && !getToolbarActionsAlwaysAsMenu()) || i < (getToolbarActions().length > 2 ? 1 : 2)\"\n [id]=\"action.matIcon\"\n [matTooltip]=\"action.actionName\"\n type=\"button\">\n <mat-icon\n [matBadgeColor]=\"action.badge ? action.badge.color : 'primary'\"\n matBadgePosition=\"below after\"\n [matBadge]=\"action.badge ? action.badge.value : null\"\n >{{ action.matIcon }}</mat-icon>\n </mad-icon-button>\n </ng-container>\n </ng-container>\n\n <ng-container *ngIf=\"(isHandset$ | async) || getToolbarActionsAlwaysAsMenu()\">\n <ng-container *ngIf=\"getToolbarActions().length > 2\">\n <mad-icon-button type=\"button\" [matMenuTriggerFor]=\"burgerMenu\" [matTooltip]=\"getToolbarActionsMenuTitle()\">\n <mat-icon\n matBadgeColor=\"warn\"\n [matBadge]=\"showBadgeForMenu() ? '&#8288;' : null\"\n matBadgeSize=\"small\"\n matBadgePosition=\"above after\"\n >more_vert\n </mat-icon>\n </mad-icon-button>\n <mat-menu #burgerMenu=\"matMenu\" class=\"no-print\">\n <ng-container *ngFor=\"let action of getToolbarActions(); let i = index\">\n <ng-container *ngIf=\"hasPermission(action) | async\">\n <button *ngIf=\"i >= 1\" mat-menu-item (click)=\"action.action()\">\n <mat-icon\n color=\"primary\"\n [matBadgeColor]=\"action.badge ? action.badge.color : 'primary'\"\n [matBadge]=\"action.badge ? action.badge.value : null\"\n matBadgePosition=\"below after\"\n >{{ action.matIcon }}</mat-icon\n >\n {{ action.actionName }}\n </button>\n </ng-container>\n </ng-container>\n </mat-menu>\n </ng-container>\n </ng-container>\n </div>\n</mat-toolbar>\n",
1158
1182
  styles: ["mat-toolbar{background:#fff}.content-toolbar{border-bottom:1px solid #dcdcdc;height:57px}.right-aligned{margin-left:auto;margin-right:0;overflow:hidden}.go-back-button{padding-left:0;padding-right:0}.toolbar-title{margin-right:72px}::ng-deep.mat-badge-content{bottom:-7px!important;right:-7px!important}"]
1159
1183
  },] }
1160
1184
  ];
@@ -1905,31 +1929,57 @@
1905
1929
  },] }
1906
1930
  ];
1907
1931
 
1932
+ var DataTableActionType = /** @class */ (function () {
1933
+ function DataTableActionType() {
1934
+ }
1935
+ return DataTableActionType;
1936
+ }());
1937
+ DataTableActionType.SINGLE = "SINGLE";
1938
+ DataTableActionType.BATCH = "BATCH";
1939
+ DataTableActionType.NONE = "NONE";
1940
+
1908
1941
  var DataTableComponent = /** @class */ (function () {
1909
1942
  function DataTableComponent() {
1910
1943
  var _a;
1911
- this.ACTION_COLUMN_NAME = '__action__';
1944
+ this.ACTION_COLUMN_NAME = "__action__";
1945
+ this.SINGLE = DataTableActionType.SINGLE;
1946
+ this.BATCH = DataTableActionType.BATCH;
1947
+ this.NONE = DataTableActionType.NONE;
1912
1948
  this.columns = [];
1913
- this.filterLabel = 'NOT SET';
1914
- this.filterPlaceholder = 'NOT SET';
1949
+ this.filterLabel = "Filter";
1950
+ this.filterPlaceholder = "";
1951
+ this.noDataText = "No matching data found";
1915
1952
  this.pageSizeOptions = [5, 10, 15];
1916
1953
  this.defaultPageSize = ((_a = this.pageSizeOptions) === null || _a === void 0 ? void 0 : _a[0]) || 10;
1917
- this.rowActions = [];
1918
- this.tableActions = [];
1919
- this.tableAction = new i0.EventEmitter();
1920
- this.rowAction = new i0.EventEmitter();
1954
+ this.actions = [];
1921
1955
  this.sortEvent = new i0.EventEmitter();
1956
+ this.actionEvent = new i0.EventEmitter();
1957
+ this.pagingEvent = new i0.EventEmitter();
1958
+ this.tableActions = [];
1959
+ this.rowActions = [];
1960
+ this.allSelected = false;
1961
+ this.displayedDataMap = new Map();
1962
+ this.actualDataMap = new Map();
1963
+ this.selectionModel = new collections.SelectionModel(true);
1922
1964
  this.isFilterEnabled = false;
1923
1965
  this.isPaginationEnabled = false;
1966
+ this.mode = this.NONE;
1967
+ this.isRowClickable = false;
1968
+ this.isLoading = false;
1924
1969
  }
1925
- Object.defineProperty(DataTableComponent.prototype, "displayedData", {
1970
+ Object.defineProperty(DataTableComponent.prototype, "tableData", {
1926
1971
  set: function (data) {
1927
1972
  if (!this.dataSource) {
1928
1973
  this.dataSource = new table.MatTableDataSource(data);
1929
1974
  }
1930
- else {
1931
- this.dataSource.data = data;
1932
- }
1975
+ this.createDataMapsAndSetDisplayedDataSourceData(data);
1976
+ },
1977
+ enumerable: false,
1978
+ configurable: true
1979
+ });
1980
+ Object.defineProperty(DataTableComponent.prototype, "loading", {
1981
+ set: function (isLoading) {
1982
+ this.isLoading = isLoading;
1933
1983
  },
1934
1984
  enumerable: false,
1935
1985
  configurable: true
@@ -1954,49 +2004,273 @@
1954
2004
  enumerable: false,
1955
2005
  configurable: true
1956
2006
  });
2007
+ Object.defineProperty(DataTableComponent.prototype, "forceMode", {
2008
+ set: function (mode) {
2009
+ if (mode === this.SINGLE || mode === this.BATCH || mode === this.NONE) {
2010
+ this._forceMode = mode;
2011
+ this.mode = mode;
2012
+ this.setActions();
2013
+ }
2014
+ },
2015
+ enumerable: false,
2016
+ configurable: true
2017
+ });
1957
2018
  DataTableComponent.prototype.ngOnInit = function () {
1958
2019
  this.columnNames = this.columns.map(function (column) { return column.label; });
1959
- this.isRowClickable = this.rowActions.length > 0;
1960
- if (this.isRowClickable) {
1961
- this.columnNames.unshift(this.ACTION_COLUMN_NAME);
2020
+ this.mode = this.getTableMode();
2021
+ this.setActions();
2022
+ if (this.mode !== this.NONE) {
2023
+ this.isRowClickable = true;
1962
2024
  this.defaultAction = this.rowActions[0];
1963
2025
  }
2026
+ this.columnNames.unshift(this.ACTION_COLUMN_NAME);
1964
2027
  };
1965
2028
  DataTableComponent.prototype.ngAfterViewInit = function () {
1966
2029
  this.dataSource.paginator = this.paginator;
1967
2030
  this.dataSource.sort = this.sort;
1968
2031
  };
1969
- DataTableComponent.prototype.onFilter = function (value) {
1970
- this.setFilterValue(value);
2032
+ Object.defineProperty(DataTableComponent.prototype, "selectedCount", {
2033
+ get: function () {
2034
+ var _a;
2035
+ return ((_a = this.selectionModel) === null || _a === void 0 ? void 0 : _a.selected) ? this.selectionModel.selected.length : 0;
2036
+ },
2037
+ enumerable: false,
2038
+ configurable: true
2039
+ });
2040
+ Object.defineProperty(DataTableComponent.prototype, "rowCount", {
2041
+ get: function () {
2042
+ var _a;
2043
+ return ((_a = this.dataSource) === null || _a === void 0 ? void 0 : _a._pageData(this.dataSource.data)) ? this.dataSource._pageData(this.dataSource.data).length : 0;
2044
+ },
2045
+ enumerable: false,
2046
+ configurable: true
2047
+ });
2048
+ DataTableComponent.prototype.getSelectedCount = function (actionType) {
2049
+ var count = this.selectedCount;
2050
+ if (actionType != this.BATCH || count < 2) {
2051
+ return "";
2052
+ }
2053
+ return " (" + count + ")";
2054
+ };
2055
+ DataTableComponent.prototype.isDisabled = function (actionType) {
2056
+ switch (actionType) {
2057
+ case this.SINGLE:
2058
+ return this.selectedCount != 1;
2059
+ case this.BATCH:
2060
+ return this.selectedCount < 1;
2061
+ default:
2062
+ return false;
2063
+ }
2064
+ };
2065
+ DataTableComponent.prototype.onToggleSelectAll = function () {
2066
+ var _this = this;
2067
+ // clear all selection first
2068
+ this.selectionModel.clear();
2069
+ // toggle all checkbox
2070
+ this.allSelected = !this.allSelected;
2071
+ if (this.allSelected) {
2072
+ // select all rows of the current page
2073
+ this.dataSource._pageData(this.dataSource.data).forEach(function (row) {
2074
+ var dataRow = row;
2075
+ var rowId = "" + dataRow.rowId;
2076
+ _this.selectionModel.select(rowId);
2077
+ });
2078
+ }
2079
+ };
2080
+ DataTableComponent.prototype.isSelected = function (rowId) {
2081
+ return this.selectionModel.isSelected(rowId);
2082
+ };
2083
+ DataTableComponent.prototype.setFilterValue = function (value) {
2084
+ this.dataSource.filter = value === null || value === void 0 ? void 0 : value.trim().toLowerCase();
2085
+ };
2086
+ DataTableComponent.prototype.onRowCheckbox = function (event, row) {
2087
+ event.stopPropagation(); // no click event on row
2088
+ this.selectionModel.toggle(row.rowId);
1971
2089
  };
1972
2090
  DataTableComponent.prototype.onRowEvent = function (event, row, action) {
1973
2091
  if (action === void 0) { action = this.defaultAction; }
1974
- if (!!action && !this.isClickOnRowMenuIcon(event)) {
1975
- this.rowAction.emit(Object.assign(Object.assign({}, action), { outputRow: row }));
2092
+ switch (this.mode) {
2093
+ case this.BATCH:
2094
+ this.onRowCheckbox(event, row);
2095
+ break;
2096
+ case this.SINGLE:
2097
+ // emit the default action if the row (not the icon!) was clicked
2098
+ if (!!action && !DataTableComponent.isClickOnRowMenuIcon(event)) {
2099
+ var selected = [];
2100
+ // if ID-generator is provided, return the ID, else return the ACTUAL data
2101
+ selected.push(this.idGenerator ? row.rowId : this.actualDataMap.get(row.rowId));
2102
+ this.emitTableAction(action, selected);
2103
+ }
2104
+ break;
2105
+ default:
2106
+ // do nothing if mode is NONE (or null)
2107
+ return;
1976
2108
  }
1977
2109
  };
1978
2110
  DataTableComponent.prototype.onSortingEvent = function (sortingParams) {
1979
2111
  this.sortEvent.emit(sortingParams);
1980
2112
  };
2113
+ DataTableComponent.prototype.onPaginationEvent = function (event) {
2114
+ this.pagingEvent.emit(event);
2115
+ };
1981
2116
  DataTableComponent.prototype.onTableAction = function (tableAction) {
2117
+ var e_1, _b;
1982
2118
  if (!!tableAction) {
1983
- this.tableAction.emit(tableAction);
2119
+ var selection = [];
2120
+ try {
2121
+ for (var _c = __values(this.selectionModel.selected), _d = _c.next(); !_d.done; _d = _c.next()) {
2122
+ var selected = _d.value;
2123
+ selection.push(this.idGenerator ? selected : this.actualDataMap.get(selected));
2124
+ }
2125
+ }
2126
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
2127
+ finally {
2128
+ try {
2129
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
2130
+ }
2131
+ finally { if (e_1) throw e_1.error; }
2132
+ }
2133
+ tableAction.selected = selection;
2134
+ this.actionEvent.emit(tableAction);
1984
2135
  }
1985
2136
  };
1986
- DataTableComponent.prototype.setFilterValue = function (value) {
1987
- this.dataSource.filter = value === null || value === void 0 ? void 0 : value.trim().toLowerCase();
2137
+ DataTableComponent.transformData = function (value, transformer, transformerParams) {
2138
+ if (!transformer || !(transformer instanceof Function)) {
2139
+ return value;
2140
+ }
2141
+ return transformer(value, transformerParams);
1988
2142
  };
1989
- DataTableComponent.prototype.isClickOnRowMenuIcon = function (event) {
2143
+ DataTableComponent.generateRowId = function () {
2144
+ return uuid.v4();
2145
+ };
2146
+ DataTableComponent.isClickOnRowMenuIcon = function (event) {
1990
2147
  var _a;
1991
- return (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.classList.contains('mat-icon');
2148
+ return (_a = event === null || event === void 0 ? void 0 : event.target) === null || _a === void 0 ? void 0 : _a.classList.contains("mat-icon");
2149
+ };
2150
+ DataTableComponent.prototype.emitTableAction = function (action, selected) {
2151
+ var emitAction = Object.assign({}, action);
2152
+ if (action.type !== this.NONE) {
2153
+ emitAction.selected = __spread(selected);
2154
+ }
2155
+ this.actionEvent.emit(emitAction);
2156
+ };
2157
+ DataTableComponent.prototype.generateDisplayedDataElement = function (rowId, actualDataElement) {
2158
+ var e_2, _b;
2159
+ var displayedDataElement = {};
2160
+ displayedDataElement["rowId"] = rowId;
2161
+ try {
2162
+ for (var _c = __values(this.columns), _d = _c.next(); !_d.done; _d = _c.next()) {
2163
+ var column = _d.value;
2164
+ var actualValue = actualDataElement[column.dataPropertyName];
2165
+ displayedDataElement[column.dataPropertyName] = DataTableComponent.transformData(actualValue, column.transformer, column.transformerParams);
2166
+ }
2167
+ }
2168
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
2169
+ finally {
2170
+ try {
2171
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
2172
+ }
2173
+ finally { if (e_2) throw e_2.error; }
2174
+ }
2175
+ return displayedDataElement;
2176
+ };
2177
+ DataTableComponent.prototype.setActions = function () {
2178
+ var e_3, _b;
2179
+ this.rowActions = [];
2180
+ this.tableActions = [];
2181
+ try {
2182
+ for (var _c = __values(this.actions), _d = _c.next(); !_d.done; _d = _c.next()) {
2183
+ var action = _d.value;
2184
+ if (this.mode !== action.hiddenInMode) {
2185
+ switch (action.type) {
2186
+ case this.SINGLE:
2187
+ if (this.mode === this.SINGLE) {
2188
+ this.rowActions.push(action);
2189
+ }
2190
+ else {
2191
+ this.tableActions.push(action);
2192
+ }
2193
+ break;
2194
+ case this.BATCH:
2195
+ if (this.mode !== this.SINGLE) {
2196
+ this.tableActions.push(action);
2197
+ }
2198
+ break;
2199
+ default:
2200
+ this.tableActions.push(action);
2201
+ }
2202
+ }
2203
+ }
2204
+ }
2205
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
2206
+ finally {
2207
+ try {
2208
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
2209
+ }
2210
+ finally { if (e_3) throw e_3.error; }
2211
+ }
2212
+ };
2213
+ DataTableComponent.prototype.createDataMapsAndSetDisplayedDataSourceData = function (data) {
2214
+ var e_4, _b;
2215
+ var displayedDataList = [];
2216
+ this.actualDataMap.clear();
2217
+ this.displayedDataMap.clear();
2218
+ try {
2219
+ for (var data_1 = __values(data), data_1_1 = data_1.next(); !data_1_1.done; data_1_1 = data_1.next()) {
2220
+ var dataEntry = data_1_1.value;
2221
+ var rowId = (this.idGenerator) ? this.idGenerator(dataEntry) : DataTableComponent.generateRowId();
2222
+ this.actualDataMap.set(rowId, dataEntry);
2223
+ var displayedDataElement = this.generateDisplayedDataElement(rowId, dataEntry);
2224
+ this.displayedDataMap.set(rowId, displayedDataElement);
2225
+ displayedDataList.push(displayedDataElement);
2226
+ }
2227
+ }
2228
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
2229
+ finally {
2230
+ try {
2231
+ if (data_1_1 && !data_1_1.done && (_b = data_1.return)) _b.call(data_1);
2232
+ }
2233
+ finally { if (e_4) throw e_4.error; }
2234
+ }
2235
+ this.dataSource.data = displayedDataList;
2236
+ };
2237
+ DataTableComponent.prototype.getTableMode = function () {
2238
+ var e_5, _b;
2239
+ if (this._forceMode) {
2240
+ return this._forceMode;
2241
+ }
2242
+ if (!this.actions) {
2243
+ return this.NONE;
2244
+ }
2245
+ var distinctActionTypes = new Set();
2246
+ try {
2247
+ for (var _c = __values(this.actions), _d = _c.next(); !_d.done; _d = _c.next()) {
2248
+ var rowAction = _d.value;
2249
+ distinctActionTypes.add(rowAction.type);
2250
+ }
2251
+ }
2252
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
2253
+ finally {
2254
+ try {
2255
+ if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
2256
+ }
2257
+ finally { if (e_5) throw e_5.error; }
2258
+ }
2259
+ if (distinctActionTypes.has(this.BATCH)) {
2260
+ return this.BATCH;
2261
+ }
2262
+ if (distinctActionTypes.has(this.SINGLE)) {
2263
+ return this.SINGLE;
2264
+ }
2265
+ return this.NONE;
1992
2266
  };
1993
2267
  return DataTableComponent;
1994
2268
  }());
1995
2269
  DataTableComponent.decorators = [
1996
2270
  { type: i0.Component, args: [{
1997
- selector: 'mad-data-table',
1998
- template: "<!-- Table actions -->\n<div *ngIf=\"tableActions?.length\">\n <mad-primary-button class=\"table-action\" *ngFor=\"let tableAction of tableActions\" (click)=\"onTableAction(tableAction)\">\n {{ tableAction.label }}\n </mad-primary-button>\n</div>\n\n<!-- Row action buttons -->\n<mat-menu #menu=\"matMenu\">\n <ng-template matMenuContent let-element=\"element\">\n <button *ngFor=\"let rowAction of rowActions\" mat-menu-item class=\"row-action\" (click)=\"onRowEvent($event, element, rowAction)\">\n {{ rowAction.label }}\n </button>\n </ng-template>\n</mat-menu>\n\n<!-- Table filter -->\n<mat-form-field *ngIf=\"isFilterEnabled\">\n <mat-label>{{ filterLabel }}</mat-label>\n <input matInput autocomplete=\"off\" (keyup)=\"onFilter($event?.target?.value)\" placeholder=\"{{ filterPlaceholder }}\" />\n</mat-form-field>\n\n<!-- Table -->\n<div *ngIf=\"dataSource?.data?.length > 0; else noData\" class=\"mad-table\">\n <table mat-table [dataSource]=\"dataSource\" matSort (matSortChange)=\"onSortingEvent($event)\">\n <!-- Row actions column -->\n <ng-container [matColumnDef]=\"ACTION_COLUMN_NAME\" *ngIf=\"rowActions?.length\">\n <th scope=\"col\" mat-header-cell *matHeaderCellDef class=\"row-action-button\"></th>\n <td mat-cell *matCellDef=\"let element\" class=\"row-action-button\">\n <mad-icon-button [matMenuTriggerData]=\"{ element: element }\" [matMenuTriggerFor]=\"menu\">\n <mat-icon>more_vert</mat-icon>\n </mad-icon-button>\n </td>\n </ng-container>\n <!-- Columns with data -->\n <ng-container *ngFor=\"let column of columns\" [matColumnDef]=\"column.label\">\n <ng-container *ngIf=\"column.isSortable; else noSort\">\n <th\n scope=\"col\"\n mat-header-cell\n *matHeaderCellDef\n mat-sort-header=\"{{ column.label }}\"\n [arrowPosition]=\"column.isRightAligned ? 'before' : 'after'\"\n [class.text-right]=\"column.isRightAligned\"\n >\n {{ column.label }}\n </th>\n </ng-container>\n <ng-template #noSort>\n <th scope=\"col\" mat-header-cell *matHeaderCellDef [class.text-right]=\"column.isRightAligned\">\n {{ column.label }}\n </th>\n </ng-template>\n <td mat-cell *matCellDef=\"let element\" [class.text-right]=\"column.isRightAligned\">\n {{ element[column.dataPropertyName] }}\n </td>\n </ng-container>\n <tr mat-header-row *matHeaderRowDef=\"columnNames\"></tr>\n <tr\n mat-row\n [class.clickable-table-row]=\"isRowClickable\"\n (click)=\"onRowEvent($event, row)\"\n *matRowDef=\"let row; columns: columnNames\"\n ></tr>\n </table>\n\n <!-- Pagination -->\n <mat-paginator\n [style.display]=\"isPaginationEnabled ? 'block' : 'none'\"\n [pageSize]=\"defaultPageSize\"\n [pageSizeOptions]=\"pageSizeOptions\"\n showFirstLastButtons\n >\n </mat-paginator>\n</div>\n\n<!-- No data alert -->\n<ng-template #noData>\n <div class=\"noDataText\">\n {{ noDataText }}\n </div>\n</ng-template>\n",
1999
- styles: [".text-right{padding-right:24px!important;text-align:right!important}.table-action{margin-bottom:.5em;margin-right:.5em}.row-action-button{width:10px}.noDataText{text-align:center;width:100%}.mad-table{overflow-x:auto;width:100%}"]
2271
+ selector: "mad-data-table",
2272
+ template: "<div class=\"mad-datatable-action-bar\">\n <!-- Table actions: displayed before the table -->\n <div *ngIf=\"tableActions?.length\">\n <mad-outline-button\n [disabled]=\"isDisabled(tableAction.type)\"\n class=\"table-action\"\n *ngFor=\"let tableAction of tableActions\"\n (click)=\"onTableAction(tableAction)\">\n {{ tableAction.label | translate }} {{ getSelectedCount(tableAction.type) }}\n </mad-outline-button>\n </div>\n <!-- Table filter -->\n <mat-form-field *ngIf=\"isFilterEnabled\">\n <mat-label>{{ filterLabel | translate }}</mat-label>\n <input matInput autocomplete=\"off\" (keyup)=\"setFilterValue($event?.target?.value)\"\n placeholder=\"{{ filterPlaceholder }}\" />\n </mat-form-field>\n</div>\n\n\n<!-- Row action menu -->\n<mat-menu #rowActionMenu=\"matMenu\">\n <ng-template matMenuContent let-element=\"element\">\n <button *ngFor=\"let rowAction of rowActions\" mat-menu-item class=\"row-action\"\n (click)=\"onRowEvent($event, element, rowAction)\">\n {{ rowAction.label | translate }}\n </button>\n </ng-template>\n</mat-menu>\n\n<!-- Table -->\n<div *ngIf=\"rowCount > 0; else noData\" class=\"mad-table\">\n <div class=\"datatable-spinner-wrapper\" *ngIf=\"isLoading\">\n <mat-spinner [diameter]=\"50\" [strokeWidth]=\"3\"></mat-spinner>\n </div>\n\n <table mat-table [dataSource]=\"dataSource\" matSort (matSortChange)=\"onSortingEvent($event)\">\n <!-- Row actions column-->\n <ng-container [matColumnDef]=\"ACTION_COLUMN_NAME\">\n <th scope=\"col\" mat-header-cell *matHeaderCellDef class=\"row-action-button\">\n <!-- BATCH: master checkbox -->\n <div *ngIf=\"mode === BATCH\" class=\"mad-datatable-checkbox-container\">\n <mat-checkbox\n (change)=\"onToggleSelectAll()\"\n [checked]=\"allSelected\"\n >\n </mat-checkbox>\n </div>\n <!-- SINGLE / NONE: nothing in header row -->\n </th>\n <td mat-cell *matCellDef=\"let element\" class=\"row-action-button\">\n <!-- BATCH: row checkbox -->\n <div *ngIf=\"mode === BATCH\" class=\"mad-datatable-checkbox-container\">\n <mat-checkbox\n (click)=\"onRowCheckbox($event, element.rowId)\"\n [checked]=\"isSelected(element.rowId)\"\n >\n </mat-checkbox>\n </div>\n <!-- SINGLE: row action menu icon -->\n <mad-icon-button\n *ngIf=\"mode === SINGLE\"\n [matMenuTriggerData]=\"{ element: element }\" [matMenuTriggerFor]=\"rowActionMenu\"\n >\n <mat-icon>more_vert</mat-icon>\n </mad-icon-button>\n <!-- NONE: nothing -->\n </td>\n </ng-container>\n <!-- Columns with data -->\n <ng-container *ngFor=\"let column of columns\" [matColumnDef]=\"column.label\">\n <ng-container *ngIf=\"column.isSortable; else noSort\">\n <th\n scope=\"col\"\n mat-header-cell\n *matHeaderCellDef\n mat-sort-header=\"{{ column.label | translate}}\"\n [arrowPosition]=\"column.isRightAligned ? 'before' : 'after'\"\n [class.text-right]=\"column.isRightAligned\"\n >\n {{ column.label }}\n </th>\n </ng-container>\n <ng-template #noSort>\n <th scope=\"col\" mat-header-cell *matHeaderCellDef [class.text-right]=\"column.isRightAligned\">\n {{ column.label }}\n </th>\n </ng-template>\n <td mat-cell *matCellDef=\"let element\" [class.text-right]=\"column.isRightAligned\" [ngSwitch]=\"column.transformer\">\n <span>\n {{ element[column.dataPropertyName] }}\n </span>\n </td>\n </ng-container>\n <tr mat-header-row *matHeaderRowDef=\"columnNames\"></tr>\n <tr\n mat-row\n [class.clickable-table-row]=\"isRowClickable\"\n (click)=\"onRowEvent($event, row)\"\n *matRowDef=\"let row; columns: columnNames\"\n ></tr>\n </table>\n\n <!-- Pagination -->\n <mat-paginator\n [style.display]=\"isPaginationEnabled ? 'block' : 'none'\"\n [pageSize]=\"defaultPageSize\"\n [pageSizeOptions]=\"pageSizeOptions\"\n (page)=\"onPaginationEvent($event)\"\n showFirstLastButtons\n >\n </mat-paginator>\n</div>\n\n<!-- No data alert -->\n<ng-template #noData>\n <div class=\"noDataText\">\n <div class=\"datatable-spinner-wrapper\" *ngIf=\"isLoading\">\n <mat-spinner [diameter]=\"50\" [strokeWidth]=\"3\"></mat-spinner>\n </div>\n {{ noDataText }}\n </div>\n</ng-template>\n",
2273
+ styles: [".text-right{padding-right:24px!important;text-align:right!important}.table-action{margin-bottom:.5em;margin-right:.5em}.row-action-button{width:10px}.noDataText{text-align:center}.mad-table,.noDataText{position:relative;width:100%}.mad-table{overflow-x:auto}.mad-datatable-action-bar{align-items:baseline;display:flex;justify-content:space-between}.mad-datatable-checkbox-container{margin-right:16px}.datatable-spinner-wrapper{align-items:center;background-color:#fff;display:flex;height:100%;justify-content:center;left:0;opacity:.8;pointer-events:unset;position:absolute;top:0;width:100%;z-index:99999}"]
2000
2274
  },] }
2001
2275
  ];
2002
2276
  DataTableComponent.propDecorators = {
@@ -2006,14 +2280,16 @@
2006
2280
  noDataText: [{ type: i0.Input }],
2007
2281
  pageSizeOptions: [{ type: i0.Input }],
2008
2282
  defaultPageSize: [{ type: i0.Input }],
2009
- rowActions: [{ type: i0.Input }],
2010
- tableActions: [{ type: i0.Input }],
2011
- displayedData: [{ type: i0.Input }],
2283
+ actions: [{ type: i0.Input }],
2284
+ idGenerator: [{ type: i0.Input }],
2285
+ tableData: [{ type: i0.Input }],
2286
+ loading: [{ type: i0.Input }],
2012
2287
  paginationEnabled: [{ type: i0.Input }],
2013
2288
  filterEnabled: [{ type: i0.Input }],
2014
- tableAction: [{ type: i0.Output }],
2015
- rowAction: [{ type: i0.Output }],
2289
+ forceMode: [{ type: i0.Input }],
2016
2290
  sortEvent: [{ type: i0.Output }],
2291
+ actionEvent: [{ type: i0.Output }],
2292
+ pagingEvent: [{ type: i0.Output }],
2017
2293
  paginator: [{ type: i0.ViewChild, args: [paginator.MatPaginator, { static: false },] }],
2018
2294
  sort: [{ type: i0.ViewChild, args: [sort.MatSort, { static: true },] }]
2019
2295
  };
@@ -2036,9 +2312,13 @@
2036
2312
  paginator.MatPaginatorModule,
2037
2313
  sort.MatSortModule,
2038
2314
  table.MatTableModule,
2315
+ progressSpinner.MatProgressSpinnerModule,
2039
2316
  ButtonModule,
2317
+ i2.TranslateModule,
2318
+ checkbox.MatCheckboxModule,
2319
+ badge.MatBadgeModule
2040
2320
  ],
2041
- exports: [DataTableComponent],
2321
+ exports: [DataTableComponent]
2042
2322
  },] }
2043
2323
  ];
2044
2324