ngx-st-tables 1.0.0
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/README.md +24 -0
- package/esm2020/lib/components/local-table/configurations/configurations.component.mjs +70 -0
- package/esm2020/lib/components/local-table/local-table.component.mjs +191 -0
- package/esm2020/lib/components/select-table/select-table.mjs +101 -0
- package/esm2020/lib/models/local-table/st-configurations-settings.model.mjs +2 -0
- package/esm2020/lib/models/local-table/st-global-search-settings.model.mjs +2 -0
- package/esm2020/lib/models/local-table/st-local-storage-configuration.model.mjs +2 -0
- package/esm2020/lib/models/local-table/st-local-table-column.model.mjs +2 -0
- package/esm2020/lib/models/local-table/st-local-table-columns.model.mjs +2 -0
- package/esm2020/lib/models/local-table/st-table-settings.model.mjs +2 -0
- package/esm2020/lib/services/local-table.service.mjs +33 -0
- package/esm2020/lib/st-tables.module.mjs +99 -0
- package/esm2020/ngx-st-tables.mjs +5 -0
- package/esm2020/public-api.mjs +15 -0
- package/fesm2015/ngx-st-tables.mjs +476 -0
- package/fesm2015/ngx-st-tables.mjs.map +1 -0
- package/fesm2020/ngx-st-tables.mjs +474 -0
- package/fesm2020/ngx-st-tables.mjs.map +1 -0
- package/lib/components/local-table/configurations/configurations.component.d.ts +27 -0
- package/lib/components/local-table/local-table.component.d.ts +56 -0
- package/lib/components/select-table/select-table.d.ts +37 -0
- package/lib/models/local-table/st-configurations-settings.model.d.ts +6 -0
- package/lib/models/local-table/st-global-search-settings.model.d.ts +4 -0
- package/lib/models/local-table/st-local-storage-configuration.model.d.ts +8 -0
- package/lib/models/local-table/st-local-table-column.model.d.ts +22 -0
- package/lib/models/local-table/st-local-table-columns.model.d.ts +4 -0
- package/lib/models/local-table/st-table-settings.model.d.ts +3 -0
- package/lib/services/local-table.service.d.ts +10 -0
- package/lib/st-tables.module.d.ts +24 -0
- package/ngx-st-tables.d.ts +5 -0
- package/package.json +33 -0
- package/public-api.d.ts +11 -0
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { Injectable, EventEmitter, Component, ChangeDetectionStrategy, Input, Output, ViewChild, NgModule } from '@angular/core';
|
|
3
|
+
import * as i8 from '@angular/material/table';
|
|
4
|
+
import { MatTableDataSource, MatTableModule } from '@angular/material/table';
|
|
5
|
+
import * as i10 from '@angular/material/paginator';
|
|
6
|
+
import { MatPaginator, MatPaginatorModule } from '@angular/material/paginator';
|
|
7
|
+
import * as i9 from '@angular/material/sort';
|
|
8
|
+
import { MatSort, MatSortModule } from '@angular/material/sort';
|
|
9
|
+
import * as i4 from '@angular/material/button';
|
|
10
|
+
import { MatButtonModule } from '@angular/material/button';
|
|
11
|
+
import * as i3$1 from '@angular/material/menu';
|
|
12
|
+
import { MatMenuModule } from '@angular/material/menu';
|
|
13
|
+
import * as i4$1 from '@angular/material/checkbox';
|
|
14
|
+
import { MatCheckboxModule } from '@angular/material/checkbox';
|
|
15
|
+
import * as i6 from '@angular/material/form-field';
|
|
16
|
+
import { MatFormFieldModule } from '@angular/material/form-field';
|
|
17
|
+
import * as i2 from '@angular/material/select';
|
|
18
|
+
import { MatSelectModule } from '@angular/material/select';
|
|
19
|
+
import * as i3 from '@angular/material/core';
|
|
20
|
+
import * as i11 from '@angular/common';
|
|
21
|
+
import { CommonModule } from '@angular/common';
|
|
22
|
+
import * as i6$1 from '@angular/forms';
|
|
23
|
+
import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
24
|
+
import * as i7 from '@angular/material/input';
|
|
25
|
+
import { MatInputModule } from '@angular/material/input';
|
|
26
|
+
import * as i7$1 from '@angular/material/icon';
|
|
27
|
+
import { MatIconModule } from '@angular/material/icon';
|
|
28
|
+
import * as i14 from '@angular/material/tooltip';
|
|
29
|
+
import { MatTooltipModule } from '@angular/material/tooltip';
|
|
30
|
+
import * as i15 from '@angular/router';
|
|
31
|
+
import { RouterModule } from '@angular/router';
|
|
32
|
+
import * as i16 from 'ngx-st-date-format';
|
|
33
|
+
import { StDateFormatModule } from 'ngx-st-date-format';
|
|
34
|
+
|
|
35
|
+
class LocalTableService {
|
|
36
|
+
constructor() {
|
|
37
|
+
this.localStorageName = '';
|
|
38
|
+
}
|
|
39
|
+
getConfigs() {
|
|
40
|
+
if (this.checkLocalStorageName()) {
|
|
41
|
+
return JSON.parse(localStorage.getItem(this.localStorageName) || '[]');
|
|
42
|
+
}
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
saveConfigs(configs) {
|
|
46
|
+
if (this.checkLocalStorageName()) {
|
|
47
|
+
localStorage.setItem(this.localStorageName, JSON.stringify(configs));
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
checkLocalStorageName() {
|
|
51
|
+
if (this.localStorageName) {
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
console.warn('YOu have to add configurationsSettings');
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
LocalTableService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: LocalTableService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
61
|
+
LocalTableService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: LocalTableService });
|
|
62
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: LocalTableService, decorators: [{
|
|
63
|
+
type: Injectable
|
|
64
|
+
}] });
|
|
65
|
+
|
|
66
|
+
class ConfigurationsComponent {
|
|
67
|
+
constructor() {
|
|
68
|
+
this.createNewConfig = new EventEmitter();
|
|
69
|
+
this.removeConfig = new EventEmitter();
|
|
70
|
+
this.changeConfig = new EventEmitter();
|
|
71
|
+
this.creatingConfiguration = false;
|
|
72
|
+
this.createConfigurationName = '';
|
|
73
|
+
this.removingConfiguration = false;
|
|
74
|
+
}
|
|
75
|
+
set initSelectedConfig(config) {
|
|
76
|
+
this.selectedConfig = config;
|
|
77
|
+
}
|
|
78
|
+
ngOnInit() {
|
|
79
|
+
}
|
|
80
|
+
showCreateConfiguration() {
|
|
81
|
+
this.creatingConfiguration = true;
|
|
82
|
+
this.createConfigurationName = '';
|
|
83
|
+
}
|
|
84
|
+
hideCreateConfiguration() {
|
|
85
|
+
this.creatingConfiguration = false;
|
|
86
|
+
this.createConfigurationName = '';
|
|
87
|
+
}
|
|
88
|
+
saveCreateConfiguration() {
|
|
89
|
+
this.creatingConfiguration = false;
|
|
90
|
+
this.selectedConfig = null;
|
|
91
|
+
this.createNewConfig.emit(this.createConfigurationName);
|
|
92
|
+
}
|
|
93
|
+
deleteConfiguration() {
|
|
94
|
+
this.removingConfiguration = true;
|
|
95
|
+
}
|
|
96
|
+
acceptDeleteConfiguration() {
|
|
97
|
+
this.removingConfiguration = false;
|
|
98
|
+
this.selectedConfig = null;
|
|
99
|
+
this.removeConfig.emit(this.selectedConfig.configId);
|
|
100
|
+
}
|
|
101
|
+
declineDeleteConfiguration() {
|
|
102
|
+
this.removingConfiguration = false;
|
|
103
|
+
}
|
|
104
|
+
selectedConfigChanged() {
|
|
105
|
+
var _a;
|
|
106
|
+
this.changeConfig.emit(((_a = this.selectedConfig) === null || _a === void 0 ? void 0 : _a.configId) || null);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
ConfigurationsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: ConfigurationsComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
110
|
+
ConfigurationsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: ConfigurationsComponent, selector: "app-configurations[configurationsSettings]", inputs: { configurationsSettings: "configurationsSettings", configurations: "configurations", initSelectedConfig: "initSelectedConfig" }, outputs: { createNewConfig: "createNewConfig", removeConfig: "removeConfig", changeConfig: "changeConfig" }, ngImport: i0, template: "<div class=\"col-auto row align-items-center\" style=\"padding: 0;\">\n <ng-container *ngIf=\"!creatingConfiguration && !removingConfiguration\">\n <mat-form-field class=\"col-auto\" style=\"padding-right: 0;\">\n <mat-label>{{configurationsSettings.selectLabel}}</mat-label>\n <mat-select [(ngModel)]=\"selectedConfig\" (ngModelChange)=\"selectedConfigChanged()\">\n <mat-option [value]=\"null\"></mat-option>\n <mat-option *ngFor=\"let config of configurations\" [value]=\"config\">{{config.configName}}</mat-option>\n </mat-select>\n </mat-form-field>\n <button mat-icon-button class=\"col-auto green-icon\" (click)=\"showCreateConfiguration()\">\n <span class=\"material-icons-outlined\">\n add\n </span>\n </button>\n <button mat-icon-button class=\"col-auto red-icon\" [disabled]=\"!selectedConfig\" (click)=\"deleteConfiguration()\">\n <span class=\"material-icons-outlined\">\n delete\n </span>\n </button>\n </ng-container>\n\n <ng-container *ngIf=\"creatingConfiguration\">\n <mat-form-field class=\"col-auto\">\n <mat-label>{{configurationsSettings.createLabel}}</mat-label>\n <input matInput [(ngModel)]=\"createConfigurationName\">\n </mat-form-field>\n <button mat-icon-button class=\"col-auto green-icon\" (click)=\"saveCreateConfiguration()\" [disabled]=\"!createConfigurationName\">\n <span class=\"material-icons-outlined\">\n done\n </span>\n </button>\n <button mat-icon-button class=\"col-auto red-icon\" (click)=\"hideCreateConfiguration()\">\n <span class=\"material-icons-outlined\">\n close\n </span>\n </button>\n </ng-container>\n\n <ng-container *ngIf=\"removingConfiguration\">\n <p class=\"col-auto\" style=\"margin: 0; font-weight: bold;font-size: 16px;\">{{configurationsSettings.deleteWarningTitle}}</p>\n <button mat-icon-button class=\"col-auto green-icon\" (click)=\"acceptDeleteConfiguration()\">\n <span class=\"material-icons-outlined\">\n done\n </span>\n </button>\n <button mat-icon-button class=\"col-auto red-icon\" (click)=\"declineDeleteConfiguration()\">\n <span class=\"material-icons-outlined\">\n close\n </span>\n </button>\n </ng-container>\n</div>\n", styles: [".green-icon span{color:#2e7d32}.red-icon span{color:#c62828}\n"], components: [{ type: i6.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i2.MatSelect, selector: "mat-select", inputs: ["disabled", "disableRipple", "tabIndex"], exportAs: ["matSelect"] }, { type: i3.MatOption, selector: "mat-option", exportAs: ["matOption"] }, { type: i4.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }], directives: [{ type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i6.MatLabel, selector: "mat-label" }, { type: i6$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i6$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i11.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i7.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i6$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
111
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: ConfigurationsComponent, decorators: [{
|
|
112
|
+
type: Component,
|
|
113
|
+
args: [{ selector: 'app-configurations[configurationsSettings]', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"col-auto row align-items-center\" style=\"padding: 0;\">\n <ng-container *ngIf=\"!creatingConfiguration && !removingConfiguration\">\n <mat-form-field class=\"col-auto\" style=\"padding-right: 0;\">\n <mat-label>{{configurationsSettings.selectLabel}}</mat-label>\n <mat-select [(ngModel)]=\"selectedConfig\" (ngModelChange)=\"selectedConfigChanged()\">\n <mat-option [value]=\"null\"></mat-option>\n <mat-option *ngFor=\"let config of configurations\" [value]=\"config\">{{config.configName}}</mat-option>\n </mat-select>\n </mat-form-field>\n <button mat-icon-button class=\"col-auto green-icon\" (click)=\"showCreateConfiguration()\">\n <span class=\"material-icons-outlined\">\n add\n </span>\n </button>\n <button mat-icon-button class=\"col-auto red-icon\" [disabled]=\"!selectedConfig\" (click)=\"deleteConfiguration()\">\n <span class=\"material-icons-outlined\">\n delete\n </span>\n </button>\n </ng-container>\n\n <ng-container *ngIf=\"creatingConfiguration\">\n <mat-form-field class=\"col-auto\">\n <mat-label>{{configurationsSettings.createLabel}}</mat-label>\n <input matInput [(ngModel)]=\"createConfigurationName\">\n </mat-form-field>\n <button mat-icon-button class=\"col-auto green-icon\" (click)=\"saveCreateConfiguration()\" [disabled]=\"!createConfigurationName\">\n <span class=\"material-icons-outlined\">\n done\n </span>\n </button>\n <button mat-icon-button class=\"col-auto red-icon\" (click)=\"hideCreateConfiguration()\">\n <span class=\"material-icons-outlined\">\n close\n </span>\n </button>\n </ng-container>\n\n <ng-container *ngIf=\"removingConfiguration\">\n <p class=\"col-auto\" style=\"margin: 0; font-weight: bold;font-size: 16px;\">{{configurationsSettings.deleteWarningTitle}}</p>\n <button mat-icon-button class=\"col-auto green-icon\" (click)=\"acceptDeleteConfiguration()\">\n <span class=\"material-icons-outlined\">\n done\n </span>\n </button>\n <button mat-icon-button class=\"col-auto red-icon\" (click)=\"declineDeleteConfiguration()\">\n <span class=\"material-icons-outlined\">\n close\n </span>\n </button>\n </ng-container>\n</div>\n", styles: [".green-icon span{color:#2e7d32}.red-icon span{color:#c62828}\n"] }]
|
|
114
|
+
}], ctorParameters: function () { return []; }, propDecorators: { configurationsSettings: [{
|
|
115
|
+
type: Input
|
|
116
|
+
}], configurations: [{
|
|
117
|
+
type: Input
|
|
118
|
+
}], initSelectedConfig: [{
|
|
119
|
+
type: Input
|
|
120
|
+
}], createNewConfig: [{
|
|
121
|
+
type: Output
|
|
122
|
+
}], removeConfig: [{
|
|
123
|
+
type: Output
|
|
124
|
+
}], changeConfig: [{
|
|
125
|
+
type: Output
|
|
126
|
+
}] } });
|
|
127
|
+
|
|
128
|
+
class LocalTableComponent {
|
|
129
|
+
constructor(localTableService, changeDetector) {
|
|
130
|
+
this.localTableService = localTableService;
|
|
131
|
+
this.changeDetector = changeDetector;
|
|
132
|
+
this.pageSize = 10;
|
|
133
|
+
this.allowPickColumns = false;
|
|
134
|
+
this.localStorageName = '';
|
|
135
|
+
this.searchModel = '';
|
|
136
|
+
this.displayedColumns = [];
|
|
137
|
+
this.configurations = [];
|
|
138
|
+
this.initConfig = null;
|
|
139
|
+
this.activeConfig = null;
|
|
140
|
+
this._data = [];
|
|
141
|
+
this._columns = {};
|
|
142
|
+
}
|
|
143
|
+
set columns(columns) {
|
|
144
|
+
this._columns = columns;
|
|
145
|
+
this.columnsArray = this.getColumnsArray();
|
|
146
|
+
this.setDisplayedColumns();
|
|
147
|
+
}
|
|
148
|
+
get columns() {
|
|
149
|
+
return this._columns;
|
|
150
|
+
}
|
|
151
|
+
set data(data) {
|
|
152
|
+
this._data = data || [];
|
|
153
|
+
this.setTableSource();
|
|
154
|
+
}
|
|
155
|
+
get data() {
|
|
156
|
+
return this._data;
|
|
157
|
+
}
|
|
158
|
+
ngOnInit() {
|
|
159
|
+
var _a;
|
|
160
|
+
if (this.localStorageName) {
|
|
161
|
+
const pageSize = localStorage.getItem(this.localStorageName);
|
|
162
|
+
if (pageSize) {
|
|
163
|
+
this.pageSize = parseInt(pageSize);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (this.configurationsSettings) {
|
|
167
|
+
this.localTableService.localStorageName = ((_a = this.configurationsSettings) === null || _a === void 0 ? void 0 : _a.localStorageName) || '';
|
|
168
|
+
this.loadConfigs();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
ngAfterViewInit() {
|
|
172
|
+
if (this.configurationsSettings) {
|
|
173
|
+
this.paginator.page.subscribe(res => {
|
|
174
|
+
if (this.activeConfig) {
|
|
175
|
+
this.activeConfig.pageSize = res.pageSize;
|
|
176
|
+
this.updateConfigsToLocalStorage();
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
this.sort.sortChange.subscribe((res) => {
|
|
180
|
+
if (this.activeConfig) {
|
|
181
|
+
this.activeConfig.sortFieldName = res.active;
|
|
182
|
+
this.activeConfig.sortDirection = res.direction;
|
|
183
|
+
this.updateConfigsToLocalStorage();
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
this.paginator.pageSize = this.pageSize;
|
|
188
|
+
}
|
|
189
|
+
applySearch(event) {
|
|
190
|
+
const searchValue = event.target.value;
|
|
191
|
+
this.tableSource.filter = searchValue.trim().toLowerCase();
|
|
192
|
+
}
|
|
193
|
+
clearSearch() {
|
|
194
|
+
this.searchModel = '';
|
|
195
|
+
this.tableSource.filter = this.searchModel;
|
|
196
|
+
}
|
|
197
|
+
checkIfActionVisible(row, action) {
|
|
198
|
+
if (action.show) {
|
|
199
|
+
return action.show(row);
|
|
200
|
+
}
|
|
201
|
+
else {
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
columnVisibleChanged(column) {
|
|
206
|
+
this.setDisplayedColumns();
|
|
207
|
+
this.updateConfigsToLocalStorage();
|
|
208
|
+
}
|
|
209
|
+
newConfigCreated(name) {
|
|
210
|
+
const newConfig = this.generateNewConfig(name);
|
|
211
|
+
this.configurations.push(newConfig);
|
|
212
|
+
this.updateConfigsToLocalStorage();
|
|
213
|
+
this.initConfig = newConfig;
|
|
214
|
+
}
|
|
215
|
+
configRemoved(configId) {
|
|
216
|
+
this.configurations = this.configurations.filter(config => config.configId !== configId);
|
|
217
|
+
this.updateConfigsToLocalStorage();
|
|
218
|
+
}
|
|
219
|
+
configChanged(configId) {
|
|
220
|
+
this.activeConfig = (configId) ? this.configurations.find(config => config.configId === configId) : null;
|
|
221
|
+
if (this.activeConfig) {
|
|
222
|
+
this.setTableConfig(this.activeConfig.pageSize, this.activeConfig.columnsDisabled, this.activeConfig.sortFieldName, this.activeConfig.sortDirection);
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
this.setTableConfig(this.pageSize, [], null, null);
|
|
226
|
+
this.clearSearch();
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
updateConfigsToLocalStorage() {
|
|
230
|
+
this.localTableService.saveConfigs(this.configurations);
|
|
231
|
+
}
|
|
232
|
+
setTableSource() {
|
|
233
|
+
this.tableSource = new MatTableDataSource(this._data);
|
|
234
|
+
this.tableSource.paginator = this.paginator;
|
|
235
|
+
this.tableSource.sort = this.sort;
|
|
236
|
+
this.clearSearch();
|
|
237
|
+
this.changeDetector.markForCheck();
|
|
238
|
+
}
|
|
239
|
+
setDisplayedColumns() {
|
|
240
|
+
this.displayedColumns = Object.keys(this.columns).filter((column) => {
|
|
241
|
+
return this._columns[column].visible;
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
getColumnsArray() {
|
|
245
|
+
return Object.keys(this._columns)
|
|
246
|
+
.map((column) => this._columns[column]);
|
|
247
|
+
}
|
|
248
|
+
loadConfigs() {
|
|
249
|
+
this.configurations = this.localTableService.getConfigs();
|
|
250
|
+
}
|
|
251
|
+
generateNewConfig(configName) {
|
|
252
|
+
return {
|
|
253
|
+
configId: Date.now().toString(),
|
|
254
|
+
configName: configName,
|
|
255
|
+
columnsDisabled: this.columnsArray.filter(column => !column.visible).map(column => column.translateColumnName),
|
|
256
|
+
pageSize: this.paginator.pageSize,
|
|
257
|
+
sortFieldName: (this.sort.direction && this.sort.active) ? this.sort.active : null,
|
|
258
|
+
sortDirection: this.sort.direction || null
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
setTableConfig(pageSize, disabledColumns, sortFieldName, sortDirection) {
|
|
262
|
+
this.paginator.pageSize = pageSize;
|
|
263
|
+
this.sort.sort({ id: sortFieldName || '', start: sortDirection || 'asc', disableClear: false });
|
|
264
|
+
this.columnsArray.forEach(column => {
|
|
265
|
+
column.visible = disabledColumns.indexOf(column.translateColumnName) === -1;
|
|
266
|
+
});
|
|
267
|
+
this.setDisplayedColumns();
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
LocalTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: LocalTableComponent, deps: [{ token: LocalTableService }, { token: i0.ChangeDetectorRef }], target: i0.ɵɵFactoryTarget.Component });
|
|
271
|
+
LocalTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: LocalTableComponent, selector: "ngx-st-local-table", inputs: { tableSettings: "tableSettings", globalSearchSettings: "globalSearchSettings", pageSize: "pageSize", allowPickColumns: "allowPickColumns", configurationsSettings: "configurationsSettings", localStorageName: "localStorageName", columns: "columns", data: "data" }, viewQueries: [{ propertyName: "paginator", first: true, predicate: MatPaginator, descendants: true }, { propertyName: "sort", first: true, predicate: MatSort, descendants: true }], ngImport: i0, template: "<div class=\"local-table\">\r\n <div class=\"row align-items-center\">\r\n <div class=\"col row align-items-center\" style=\"padding: 0;\" *ngIf=\"configurationsSettings || allowPickColumns\">\r\n <div class=\"col-auto\" style=\"padding: 0;\" *ngIf=\"allowPickColumns\">\r\n <button mat-icon-button class=\"col-auto\" [matMenuTriggerFor]=\"columnsMenu\">\r\n <span class=\"material-icons-outlined\">\r\n view_week\r\n </span>\r\n </button>\r\n <mat-menu #columnsMenu=\"matMenu\" xPosition=\"after\">\r\n <ng-container *ngFor=\"let column of columnsArray\">\r\n <div mat-menu-item *ngIf=\"!column.notShowInColumnPick\">\r\n <mat-checkbox\r\n [(ngModel)]=\"column.visible\"\r\n (ngModelChange)=\"columnVisibleChanged(column)\"\r\n style=\"margin-top: 5px;\"\r\n (click)=\"$event.stopPropagation()\"\r\n >\r\n {{column.translateColumnName}}\r\n </mat-checkbox>\r\n </div>\r\n </ng-container>\r\n </mat-menu>\r\n </div>\r\n\r\n <app-configurations\r\n *ngIf=\"configurationsSettings\"\r\n [configurationsSettings]=\"configurationsSettings\"\r\n [configurations]=\"configurations\"\r\n [initSelectedConfig]=\"initConfig\"\r\n (createNewConfig)=\"newConfigCreated($event)\"\r\n (removeConfig)=\"configRemoved($event)\"\r\n (changeConfig)=\"configChanged($event)\"\r\n ></app-configurations>\r\n </div>\r\n\r\n <div class=\"col\" style=\"padding: 0;\" *ngIf=\"globalSearchSettings?.show\">\r\n <mat-form-field class=\"col\">\r\n <mat-label>{{globalSearchSettings?.label || 'Search'}}</mat-label>\r\n <input matInput (keyup)=\"applySearch($event)\" [(ngModel)]=\"searchModel\">\r\n <button matSuffix mat-icon-button aria-label=\"Clear\" (click)=\"clearSearch()\">\r\n <mat-icon style=\"font-size: 22px\">close</mat-icon>\r\n </button>\r\n </mat-form-field>\r\n </div>\r\n\r\n </div>\r\n\r\n <table [ngClass]=\"{'no-hover': !tableSettings?.rowClickAction}\" mat-table [dataSource]=\"tableSource\" matSort>\r\n\r\n <ng-container [matColumnDef]=\"column\" *ngFor=\"let column of displayedColumns\">\r\n <th\r\n mat-header-cell\r\n *matHeaderCellDef\r\n style=\"{{columns[column].width ? ('width:' + columns[column].width) : ''}}\"\r\n mat-sort-header\r\n [disabled]=\"!columns[column].sort\"\r\n >\r\n {{columns[column].translateColumnName }}\r\n <span class=\"material-icons search-icon\" [matMenuTriggerFor]=\"menu\" (click)=\"$event.stopPropagation()\"\r\n *ngIf=\"columns[column].search\">\r\n search\r\n </span>\r\n <mat-menu #menu=\"matMenu\" xPosition=\"before\">\r\n <mat-form-field class=\"col\">\r\n <mat-label>{{columns[column].searchLabel || 'Search'}}</mat-label>\r\n <input matInput (keyup)=\"applySearch($event)\" [(ngModel)]=\"searchModel\"\r\n (click)=\"$event.stopPropagation()\">\r\n <button matSuffix mat-icon-button aria-label=\"Clear\" (click)=\"searchModel=''\">\r\n <mat-icon>close</mat-icon>\r\n </button>\r\n </mat-form-field>\r\n </mat-menu>\r\n </th>\r\n <td mat-cell *matCellDef=\"let element\"\r\n style=\"{{columns[column].width ? ('width:' + columns[column].width) : ''}}\">\r\n <div class=\"actions-container\" [ngClass]=\"{'justify-content-end': columns[column].flexRight}\"\r\n *ngIf=\"columns[column].actions && columns[column].actions!.length > 0\">\r\n <ng-container *ngFor=\"let action of columns[column].actions\">\r\n <ng-container *ngIf=\"checkIfActionVisible(element, action)\">\r\n <button class=\"col-auto\" mat-icon-button\r\n type=\"button\"\r\n *ngIf=\"!action.url && action.action\"\r\n matTooltip=\"{{(action.tooltipName || '') }}\"\r\n [matTooltipDisabled]=\"!!!(action.tooltipName)\"\r\n (click)=\"action.action(element)\"\r\n >\r\n <span class=\"material-icons\">{{action.iconName}}</span>\r\n </button>\r\n\r\n <a *ngIf=\"action.url\" [routerLink]=\"action.url\">\r\n <button class=\"col-auto\" mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"{{(action.tooltipName || '') }}\"\r\n [matTooltipDisabled]=\"!!!(action.tooltipName)\"\r\n >\r\n <span class=\"material-icons\">{{action.iconName}}</span>\r\n </button>\r\n </a>\r\n </ng-container>\r\n </ng-container>\r\n </div>\r\n\r\n <ng-container *ngIf=\"!columns[column].actions\">\r\n <ng-container *ngIf=\"columns[column].translateValue\">\r\n <p style=\"margin:0;padding:0\">{{columns[column].translateValue![element[column]] || '' }}</p>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"!columns[column].translateValue\">\r\n <ng-container *ngIf=\"!columns[column].type || columns[column].type === 'string'\">\r\n <p style=\"margin:0;padding:0\">{{element[column]}}</p>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"columns[column].type === 'date'\">\r\n <p style=\"margin:0;padding:0\">{{element[column] | stDateTimeFormatPipe}}</p>\r\n </ng-container>\r\n </ng-container>\r\n </ng-container>\r\n </td>\r\n </ng-container>\r\n\r\n <tr mat-header-row *matHeaderRowDef=\"displayedColumns\"></tr>\r\n <tr mat-row *matRowDef=\"let row; columns: displayedColumns;\" (click)=\"tableSettings?.rowClickAction ? tableSettings.rowClickAction(row) : null\"></tr>\r\n </table>\r\n <mat-paginator [pageSizeOptions]=\"[5, 10, 15, 20, 25]\" showFirstLastButtons></mat-paginator>\r\n</div>\r\n", styles: [".search-form button{height:40px}.search-form mat-form-field:first-child{padding-left:0}.search-form mat-form-field:last-child{padding-right:0}.search-form .clear{padding:0}.search-form .clear i{height:20px;width:20px;font-size:20px;cursor:pointer}table{width:100%}table::ng-deep thead tr{background-color:#fff9c4}table::ng-deep thead tr th{border-color:#fdd835}table::ng-deep thead tr th:hover .order-icon{display:none}table::ng-deep thead tr th .order-icon{opacity:.4;font-size:20px}table::ng-deep thead tr th .search-icon{position:absolute;top:3px;right:0;opacity:.5;font-size:20px;margin:0 5px;font-weight:600}table::ng-deep thead tr th .search-icon:hover{opacity:.8}table::ng-deep thead tr th .mat-sort-header-content{text-align:left}table::ng-deep tbody tr{cursor:pointer}table::ng-deep tbody tr.active{background-color:#a5d6a7}table::ng-deep tbody tr:hover{background-color:#a5d6a7}table::ng-deep tbody tr.disabled{cursor:not-allowed}table::ng-deep tbody tr.disabled:hover{background-color:inherit}table::ng-deep tbody tr td i.active-row{color:#1b5e20;font-weight:700;font-size:25px;height:25px;width:25px;margin-top:2px}table::ng-deep tbody tr td>div{max-height:200px;overflow:hidden;overflow-y:auto}table::ng-deep tbody tr td .actions-container{display:flex}table::ng-deep tbody tr td a button{color:#000}table::ng-deep tbody tr td a i{color:#333}table::ng-deep .mat-column-active{width:48px}table.no-hover::ng-deep tbody tr{cursor:default}table.no-hover::ng-deep tbody tr.active{background-color:transparent}table.no-hover::ng-deep tbody tr:hover{background-color:transparent}table.admin-table::ng-deep .actions-cell{width:100px}\n"], components: [{ type: i4.MatButton, selector: "button[mat-button], button[mat-raised-button], button[mat-icon-button], button[mat-fab], button[mat-mini-fab], button[mat-stroked-button], button[mat-flat-button]", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { type: i3$1.MatMenu, selector: "mat-menu", exportAs: ["matMenu"] }, { type: i3$1.MatMenuItem, selector: "[mat-menu-item]", inputs: ["disabled", "disableRipple", "role"], exportAs: ["matMenuItem"] }, { type: i4$1.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex", "aria-label", "aria-labelledby", "aria-describedby", "id", "required", "labelPosition", "name", "value", "checked", "disabled", "indeterminate"], outputs: ["change", "indeterminateChange"], exportAs: ["matCheckbox"] }, { type: ConfigurationsComponent, selector: "app-configurations[configurationsSettings]", inputs: ["configurationsSettings", "configurations", "initSelectedConfig"], outputs: ["createNewConfig", "removeConfig", "changeConfig"] }, { type: i6.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i7$1.MatIcon, selector: "mat-icon", inputs: ["color", "inline", "svgIcon", "fontSet", "fontIcon"], exportAs: ["matIcon"] }, { type: i8.MatTable, selector: "mat-table, table[mat-table]", exportAs: ["matTable"] }, { type: i9.MatSortHeader, selector: "[mat-sort-header]", inputs: ["disabled", "mat-sort-header", "arrowPosition", "start", "sortActionDescription", "disableClear"], exportAs: ["matSortHeader"] }, { type: i8.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { type: i8.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }, { type: i10.MatPaginator, selector: "mat-paginator", inputs: ["disabled"], exportAs: ["matPaginator"] }], directives: [{ type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i3$1.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", exportAs: ["matMenuTrigger"] }, { type: i11.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i6$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i6$1.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { type: i6.MatLabel, selector: "mat-label" }, { type: i7.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i6$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i6.MatSuffix, selector: "[matSuffix]" }, { type: i9.MatSort, selector: "[matSort]", inputs: ["matSortDisabled", "matSortActive", "matSortStart", "matSortDirection", "matSortDisableClear"], outputs: ["matSortChange"], exportAs: ["matSort"] }, { type: i11.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i8.MatColumnDef, selector: "[matColumnDef]", inputs: ["sticky", "matColumnDef"] }, { type: i8.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { type: i8.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { type: i8.MatCellDef, selector: "[matCellDef]" }, { type: i8.MatCell, selector: "mat-cell, td[mat-cell]" }, { type: i14.MatTooltip, selector: "[matTooltip]", exportAs: ["matTooltip"] }, { type: i15.RouterLinkWithHref, selector: "a[routerLink],area[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "preserveFragment", "skipLocationChange", "replaceUrl", "state", "relativeTo", "routerLink"] }, { type: i8.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { type: i8.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }], pipes: { "stDateTimeFormatPipe": i16.DateTimeFormatPipe }, changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
272
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: LocalTableComponent, decorators: [{
|
|
273
|
+
type: Component,
|
|
274
|
+
args: [{ selector: 'ngx-st-local-table', changeDetection: ChangeDetectionStrategy.OnPush, template: "<div class=\"local-table\">\r\n <div class=\"row align-items-center\">\r\n <div class=\"col row align-items-center\" style=\"padding: 0;\" *ngIf=\"configurationsSettings || allowPickColumns\">\r\n <div class=\"col-auto\" style=\"padding: 0;\" *ngIf=\"allowPickColumns\">\r\n <button mat-icon-button class=\"col-auto\" [matMenuTriggerFor]=\"columnsMenu\">\r\n <span class=\"material-icons-outlined\">\r\n view_week\r\n </span>\r\n </button>\r\n <mat-menu #columnsMenu=\"matMenu\" xPosition=\"after\">\r\n <ng-container *ngFor=\"let column of columnsArray\">\r\n <div mat-menu-item *ngIf=\"!column.notShowInColumnPick\">\r\n <mat-checkbox\r\n [(ngModel)]=\"column.visible\"\r\n (ngModelChange)=\"columnVisibleChanged(column)\"\r\n style=\"margin-top: 5px;\"\r\n (click)=\"$event.stopPropagation()\"\r\n >\r\n {{column.translateColumnName}}\r\n </mat-checkbox>\r\n </div>\r\n </ng-container>\r\n </mat-menu>\r\n </div>\r\n\r\n <app-configurations\r\n *ngIf=\"configurationsSettings\"\r\n [configurationsSettings]=\"configurationsSettings\"\r\n [configurations]=\"configurations\"\r\n [initSelectedConfig]=\"initConfig\"\r\n (createNewConfig)=\"newConfigCreated($event)\"\r\n (removeConfig)=\"configRemoved($event)\"\r\n (changeConfig)=\"configChanged($event)\"\r\n ></app-configurations>\r\n </div>\r\n\r\n <div class=\"col\" style=\"padding: 0;\" *ngIf=\"globalSearchSettings?.show\">\r\n <mat-form-field class=\"col\">\r\n <mat-label>{{globalSearchSettings?.label || 'Search'}}</mat-label>\r\n <input matInput (keyup)=\"applySearch($event)\" [(ngModel)]=\"searchModel\">\r\n <button matSuffix mat-icon-button aria-label=\"Clear\" (click)=\"clearSearch()\">\r\n <mat-icon style=\"font-size: 22px\">close</mat-icon>\r\n </button>\r\n </mat-form-field>\r\n </div>\r\n\r\n </div>\r\n\r\n <table [ngClass]=\"{'no-hover': !tableSettings?.rowClickAction}\" mat-table [dataSource]=\"tableSource\" matSort>\r\n\r\n <ng-container [matColumnDef]=\"column\" *ngFor=\"let column of displayedColumns\">\r\n <th\r\n mat-header-cell\r\n *matHeaderCellDef\r\n style=\"{{columns[column].width ? ('width:' + columns[column].width) : ''}}\"\r\n mat-sort-header\r\n [disabled]=\"!columns[column].sort\"\r\n >\r\n {{columns[column].translateColumnName }}\r\n <span class=\"material-icons search-icon\" [matMenuTriggerFor]=\"menu\" (click)=\"$event.stopPropagation()\"\r\n *ngIf=\"columns[column].search\">\r\n search\r\n </span>\r\n <mat-menu #menu=\"matMenu\" xPosition=\"before\">\r\n <mat-form-field class=\"col\">\r\n <mat-label>{{columns[column].searchLabel || 'Search'}}</mat-label>\r\n <input matInput (keyup)=\"applySearch($event)\" [(ngModel)]=\"searchModel\"\r\n (click)=\"$event.stopPropagation()\">\r\n <button matSuffix mat-icon-button aria-label=\"Clear\" (click)=\"searchModel=''\">\r\n <mat-icon>close</mat-icon>\r\n </button>\r\n </mat-form-field>\r\n </mat-menu>\r\n </th>\r\n <td mat-cell *matCellDef=\"let element\"\r\n style=\"{{columns[column].width ? ('width:' + columns[column].width) : ''}}\">\r\n <div class=\"actions-container\" [ngClass]=\"{'justify-content-end': columns[column].flexRight}\"\r\n *ngIf=\"columns[column].actions && columns[column].actions!.length > 0\">\r\n <ng-container *ngFor=\"let action of columns[column].actions\">\r\n <ng-container *ngIf=\"checkIfActionVisible(element, action)\">\r\n <button class=\"col-auto\" mat-icon-button\r\n type=\"button\"\r\n *ngIf=\"!action.url && action.action\"\r\n matTooltip=\"{{(action.tooltipName || '') }}\"\r\n [matTooltipDisabled]=\"!!!(action.tooltipName)\"\r\n (click)=\"action.action(element)\"\r\n >\r\n <span class=\"material-icons\">{{action.iconName}}</span>\r\n </button>\r\n\r\n <a *ngIf=\"action.url\" [routerLink]=\"action.url\">\r\n <button class=\"col-auto\" mat-icon-button\r\n type=\"button\"\r\n matTooltip=\"{{(action.tooltipName || '') }}\"\r\n [matTooltipDisabled]=\"!!!(action.tooltipName)\"\r\n >\r\n <span class=\"material-icons\">{{action.iconName}}</span>\r\n </button>\r\n </a>\r\n </ng-container>\r\n </ng-container>\r\n </div>\r\n\r\n <ng-container *ngIf=\"!columns[column].actions\">\r\n <ng-container *ngIf=\"columns[column].translateValue\">\r\n <p style=\"margin:0;padding:0\">{{columns[column].translateValue![element[column]] || '' }}</p>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"!columns[column].translateValue\">\r\n <ng-container *ngIf=\"!columns[column].type || columns[column].type === 'string'\">\r\n <p style=\"margin:0;padding:0\">{{element[column]}}</p>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"columns[column].type === 'date'\">\r\n <p style=\"margin:0;padding:0\">{{element[column] | stDateTimeFormatPipe}}</p>\r\n </ng-container>\r\n </ng-container>\r\n </ng-container>\r\n </td>\r\n </ng-container>\r\n\r\n <tr mat-header-row *matHeaderRowDef=\"displayedColumns\"></tr>\r\n <tr mat-row *matRowDef=\"let row; columns: displayedColumns;\" (click)=\"tableSettings?.rowClickAction ? tableSettings.rowClickAction(row) : null\"></tr>\r\n </table>\r\n <mat-paginator [pageSizeOptions]=\"[5, 10, 15, 20, 25]\" showFirstLastButtons></mat-paginator>\r\n</div>\r\n", styles: [".search-form button{height:40px}.search-form mat-form-field:first-child{padding-left:0}.search-form mat-form-field:last-child{padding-right:0}.search-form .clear{padding:0}.search-form .clear i{height:20px;width:20px;font-size:20px;cursor:pointer}table{width:100%}table::ng-deep thead tr{background-color:#fff9c4}table::ng-deep thead tr th{border-color:#fdd835}table::ng-deep thead tr th:hover .order-icon{display:none}table::ng-deep thead tr th .order-icon{opacity:.4;font-size:20px}table::ng-deep thead tr th .search-icon{position:absolute;top:3px;right:0;opacity:.5;font-size:20px;margin:0 5px;font-weight:600}table::ng-deep thead tr th .search-icon:hover{opacity:.8}table::ng-deep thead tr th .mat-sort-header-content{text-align:left}table::ng-deep tbody tr{cursor:pointer}table::ng-deep tbody tr.active{background-color:#a5d6a7}table::ng-deep tbody tr:hover{background-color:#a5d6a7}table::ng-deep tbody tr.disabled{cursor:not-allowed}table::ng-deep tbody tr.disabled:hover{background-color:inherit}table::ng-deep tbody tr td i.active-row{color:#1b5e20;font-weight:700;font-size:25px;height:25px;width:25px;margin-top:2px}table::ng-deep tbody tr td>div{max-height:200px;overflow:hidden;overflow-y:auto}table::ng-deep tbody tr td .actions-container{display:flex}table::ng-deep tbody tr td a button{color:#000}table::ng-deep tbody tr td a i{color:#333}table::ng-deep .mat-column-active{width:48px}table.no-hover::ng-deep tbody tr{cursor:default}table.no-hover::ng-deep tbody tr.active{background-color:transparent}table.no-hover::ng-deep tbody tr:hover{background-color:transparent}table.admin-table::ng-deep .actions-cell{width:100px}\n"] }]
|
|
275
|
+
}], ctorParameters: function () { return [{ type: LocalTableService }, { type: i0.ChangeDetectorRef }]; }, propDecorators: { paginator: [{
|
|
276
|
+
type: ViewChild,
|
|
277
|
+
args: [MatPaginator]
|
|
278
|
+
}], sort: [{
|
|
279
|
+
type: ViewChild,
|
|
280
|
+
args: [MatSort]
|
|
281
|
+
}], tableSettings: [{
|
|
282
|
+
type: Input
|
|
283
|
+
}], globalSearchSettings: [{
|
|
284
|
+
type: Input
|
|
285
|
+
}], pageSize: [{
|
|
286
|
+
type: Input
|
|
287
|
+
}], allowPickColumns: [{
|
|
288
|
+
type: Input
|
|
289
|
+
}], configurationsSettings: [{
|
|
290
|
+
type: Input
|
|
291
|
+
}], localStorageName: [{
|
|
292
|
+
type: Input
|
|
293
|
+
}], columns: [{
|
|
294
|
+
type: Input
|
|
295
|
+
}], data: [{
|
|
296
|
+
type: Input
|
|
297
|
+
}] } });
|
|
298
|
+
|
|
299
|
+
class SelectTable {
|
|
300
|
+
constructor() {
|
|
301
|
+
this.search = new FormControl('');
|
|
302
|
+
this.rowSelected = [];
|
|
303
|
+
this._validError = false;
|
|
304
|
+
this.required = false;
|
|
305
|
+
this.multiple = false;
|
|
306
|
+
this.searchLabel = 'Search';
|
|
307
|
+
this.selectedLabel = 'Selected';
|
|
308
|
+
this.returnRowSelected = new EventEmitter();
|
|
309
|
+
}
|
|
310
|
+
set setInitColumns(col) {
|
|
311
|
+
this.columns = ['active', ...Object.keys(col)];
|
|
312
|
+
this.initColumns = col;
|
|
313
|
+
}
|
|
314
|
+
set tableData(data) {
|
|
315
|
+
this.tableSource = new MatTableDataSource(data);
|
|
316
|
+
this.tableSource.paginator = this.paginator;
|
|
317
|
+
}
|
|
318
|
+
set validError(error) {
|
|
319
|
+
this._validError = error;
|
|
320
|
+
}
|
|
321
|
+
get validError() {
|
|
322
|
+
return this._validError;
|
|
323
|
+
}
|
|
324
|
+
ngOnInit() {
|
|
325
|
+
this.search.valueChanges.subscribe(res => {
|
|
326
|
+
this.tableSource.filter = res.trim().toLowerCase();
|
|
327
|
+
});
|
|
328
|
+
setTimeout(() => {
|
|
329
|
+
if (this.initSearchVal) {
|
|
330
|
+
this.search.setValue(this.initSearchVal);
|
|
331
|
+
this.rowClick(this.initSelected);
|
|
332
|
+
}
|
|
333
|
+
}, 1000);
|
|
334
|
+
}
|
|
335
|
+
clearSearch() {
|
|
336
|
+
this.search.setValue('');
|
|
337
|
+
}
|
|
338
|
+
rowClick(row) {
|
|
339
|
+
const found = this.rowSelected.find((tmpRow) => tmpRow === row);
|
|
340
|
+
if (found) {
|
|
341
|
+
this.rowSelected = this.rowSelected.filter((tmpRow) => tmpRow !== row);
|
|
342
|
+
}
|
|
343
|
+
else {
|
|
344
|
+
if (this.multiple) {
|
|
345
|
+
this.rowSelected.push(row);
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
this.rowSelected = [row];
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
this.returnRowSelected.emit(this.rowSelected);
|
|
352
|
+
}
|
|
353
|
+
checkActiveRow(row) {
|
|
354
|
+
return !!(this.rowSelected.find(activeRow => activeRow === row));
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
SelectTable.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SelectTable, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
358
|
+
SelectTable.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.2.7", type: SelectTable, selector: "ngx-st-select-table", inputs: { title: "title", required: "required", multiple: "multiple", initSelected: "initSelected", initSearchVal: "initSearchVal", searchLabel: "searchLabel", selectedLabel: "selectedLabel", setInitColumns: "setInitColumns", tableData: "tableData", validError: "validError" }, outputs: { returnRowSelected: "returnRowSelected" }, viewQueries: [{ propertyName: "paginator", first: true, predicate: MatPaginator, descendants: true }], ngImport: i0, template: "<div class=\"shared-table-selector\">\r\n <p class=\"title\" [ngClass]=\"{'error-text': validError}\">{{title}} {{required ? '*' : ''}}</p>\r\n\r\n <div class=\"search-form row align-items-center\">\r\n <div class=\"col-sm-12 col-md row align-items-center\">\r\n <mat-form-field class=\"col\">\r\n <input matInput placeholder=\"{{searchLabel}}\" [formControl]=\"search\">\r\n </mat-form-field>\r\n <div class=\"clear col-auto\">\r\n <i class=\"material-icons\" (click)=\"clearSearch()\">clear</i>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <table mat-table [dataSource]=\"tableSource\">\r\n <ng-container *ngFor=\"let col of columns\" [matColumnDef]=\"col\" >\r\n <th mat-header-cell *matHeaderCellDef> {{(col === 'active') ? selectedLabel : initColumns[col]}} </th>\r\n <td mat-cell *matCellDef=\"let element\">\r\n <ng-container *ngIf=\"col === 'active'\">\r\n <i *ngIf=\"checkActiveRow(element)\" class=\"material-icons active-row\">done</i>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"col !== 'active'\">\r\n {{element[col]}}\r\n </ng-container>\r\n </td>\r\n </ng-container>\r\n\r\n <tr mat-header-row *matHeaderRowDef=\"columns\"></tr>\r\n <tr mat-row *matRowDef=\"let row; columns: columns;\" (click)=\"rowClick(row)\" [ngClass]=\"{'active': checkActiveRow(row)}\"></tr>\r\n </table>\r\n <mat-paginator [pageSizeOptions]=\"[5]\"></mat-paginator>\r\n</div>\r\n", styles: [".title{margin-bottom:0;margin-top:1rem;font-weight:500}.title.error-text{color:#ef5350}\n", ".search-form button{height:40px}.search-form mat-form-field:first-child{padding-left:0}.search-form mat-form-field:last-child{padding-right:0}.search-form .clear{padding:0}.search-form .clear i{height:20px;width:20px;font-size:20px;cursor:pointer}table{width:100%}table::ng-deep thead tr{background-color:#fff9c4}table::ng-deep thead tr th{border-color:#fdd835}table::ng-deep tbody>tr{cursor:pointer}table::ng-deep tbody>tr.active{background-color:#a5d6a7}table::ng-deep tbody>tr:hover{background-color:#a5d6a7}table::ng-deep tbody>tr.disabled{cursor:not-allowed}table::ng-deep tbody>tr.disabled:hover{background-color:inherit}table::ng-deep tbody>tr.detail-row{height:0;cursor:default}table::ng-deep tbody>tr.detail-row:hover{background-color:transparent}table::ng-deep tbody>tr.detail-row .element-detail{overflow:hidden;display:flex}table::ng-deep tbody>tr.detail-row .element-detail p{padding:20px 0;margin-bottom:0;white-space:pre-wrap}table::ng-deep tbody>tr td i.active-row{color:#1b5e20;font-weight:700;font-size:25px;height:25px;width:25px;margin-top:2px}table::ng-deep tbody>tr td>div{max-height:200px;overflow:hidden;overflow-y:auto}table::ng-deep tbody>tr td a button{color:#000}table::ng-deep tbody>tr td a i{color:#333}table::ng-deep .mat-column-active{width:48px}table.no-hover::ng-deep tbody tr{cursor:default}table.no-hover::ng-deep tbody tr.active{background-color:transparent}table.no-hover::ng-deep tbody tr:hover{background-color:transparent}table.admin-table::ng-deep .actions-cell{width:100px}\n"], components: [{ type: i6.MatFormField, selector: "mat-form-field", inputs: ["color", "appearance", "hideRequiredMarker", "hintLabel", "floatLabel"], exportAs: ["matFormField"] }, { type: i8.MatTable, selector: "mat-table, table[mat-table]", exportAs: ["matTable"] }, { type: i8.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { type: i8.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }, { type: i10.MatPaginator, selector: "mat-paginator", inputs: ["disabled"], exportAs: ["matPaginator"] }], directives: [{ type: i11.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i7.MatInput, selector: "input[matInput], textarea[matInput], select[matNativeControl], input[matNativeControl], textarea[matNativeControl]", inputs: ["disabled", "id", "placeholder", "name", "required", "type", "errorStateMatcher", "aria-describedby", "value", "readonly"], exportAs: ["matInput"] }, { type: i6$1.DefaultValueAccessor, selector: "input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]" }, { type: i6$1.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i6$1.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { type: i11.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i8.MatColumnDef, selector: "[matColumnDef]", inputs: ["sticky", "matColumnDef"] }, { type: i8.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { type: i8.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { type: i8.MatCellDef, selector: "[matCellDef]" }, { type: i8.MatCell, selector: "mat-cell, td[mat-cell]" }, { type: i11.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i8.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { type: i8.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }] });
|
|
359
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: SelectTable, decorators: [{
|
|
360
|
+
type: Component,
|
|
361
|
+
args: [{ selector: 'ngx-st-select-table', template: "<div class=\"shared-table-selector\">\r\n <p class=\"title\" [ngClass]=\"{'error-text': validError}\">{{title}} {{required ? '*' : ''}}</p>\r\n\r\n <div class=\"search-form row align-items-center\">\r\n <div class=\"col-sm-12 col-md row align-items-center\">\r\n <mat-form-field class=\"col\">\r\n <input matInput placeholder=\"{{searchLabel}}\" [formControl]=\"search\">\r\n </mat-form-field>\r\n <div class=\"clear col-auto\">\r\n <i class=\"material-icons\" (click)=\"clearSearch()\">clear</i>\r\n </div>\r\n </div>\r\n </div>\r\n\r\n <table mat-table [dataSource]=\"tableSource\">\r\n <ng-container *ngFor=\"let col of columns\" [matColumnDef]=\"col\" >\r\n <th mat-header-cell *matHeaderCellDef> {{(col === 'active') ? selectedLabel : initColumns[col]}} </th>\r\n <td mat-cell *matCellDef=\"let element\">\r\n <ng-container *ngIf=\"col === 'active'\">\r\n <i *ngIf=\"checkActiveRow(element)\" class=\"material-icons active-row\">done</i>\r\n </ng-container>\r\n\r\n <ng-container *ngIf=\"col !== 'active'\">\r\n {{element[col]}}\r\n </ng-container>\r\n </td>\r\n </ng-container>\r\n\r\n <tr mat-header-row *matHeaderRowDef=\"columns\"></tr>\r\n <tr mat-row *matRowDef=\"let row; columns: columns;\" (click)=\"rowClick(row)\" [ngClass]=\"{'active': checkActiveRow(row)}\"></tr>\r\n </table>\r\n <mat-paginator [pageSizeOptions]=\"[5]\"></mat-paginator>\r\n</div>\r\n", styles: [".title{margin-bottom:0;margin-top:1rem;font-weight:500}.title.error-text{color:#ef5350}\n", ".search-form button{height:40px}.search-form mat-form-field:first-child{padding-left:0}.search-form mat-form-field:last-child{padding-right:0}.search-form .clear{padding:0}.search-form .clear i{height:20px;width:20px;font-size:20px;cursor:pointer}table{width:100%}table::ng-deep thead tr{background-color:#fff9c4}table::ng-deep thead tr th{border-color:#fdd835}table::ng-deep tbody>tr{cursor:pointer}table::ng-deep tbody>tr.active{background-color:#a5d6a7}table::ng-deep tbody>tr:hover{background-color:#a5d6a7}table::ng-deep tbody>tr.disabled{cursor:not-allowed}table::ng-deep tbody>tr.disabled:hover{background-color:inherit}table::ng-deep tbody>tr.detail-row{height:0;cursor:default}table::ng-deep tbody>tr.detail-row:hover{background-color:transparent}table::ng-deep tbody>tr.detail-row .element-detail{overflow:hidden;display:flex}table::ng-deep tbody>tr.detail-row .element-detail p{padding:20px 0;margin-bottom:0;white-space:pre-wrap}table::ng-deep tbody>tr td i.active-row{color:#1b5e20;font-weight:700;font-size:25px;height:25px;width:25px;margin-top:2px}table::ng-deep tbody>tr td>div{max-height:200px;overflow:hidden;overflow-y:auto}table::ng-deep tbody>tr td a button{color:#000}table::ng-deep tbody>tr td a i{color:#333}table::ng-deep .mat-column-active{width:48px}table.no-hover::ng-deep tbody tr{cursor:default}table.no-hover::ng-deep tbody tr.active{background-color:transparent}table.no-hover::ng-deep tbody tr:hover{background-color:transparent}table.admin-table::ng-deep .actions-cell{width:100px}\n"] }]
|
|
362
|
+
}], ctorParameters: function () { return []; }, propDecorators: { paginator: [{
|
|
363
|
+
type: ViewChild,
|
|
364
|
+
args: [MatPaginator]
|
|
365
|
+
}], title: [{
|
|
366
|
+
type: Input
|
|
367
|
+
}], required: [{
|
|
368
|
+
type: Input
|
|
369
|
+
}], multiple: [{
|
|
370
|
+
type: Input
|
|
371
|
+
}], initSelected: [{
|
|
372
|
+
type: Input
|
|
373
|
+
}], initSearchVal: [{
|
|
374
|
+
type: Input
|
|
375
|
+
}], searchLabel: [{
|
|
376
|
+
type: Input
|
|
377
|
+
}], selectedLabel: [{
|
|
378
|
+
type: Input
|
|
379
|
+
}], returnRowSelected: [{
|
|
380
|
+
type: Output
|
|
381
|
+
}], setInitColumns: [{
|
|
382
|
+
type: Input
|
|
383
|
+
}], tableData: [{
|
|
384
|
+
type: Input
|
|
385
|
+
}], validError: [{
|
|
386
|
+
type: Input
|
|
387
|
+
}] } });
|
|
388
|
+
|
|
389
|
+
class StTablesModule {
|
|
390
|
+
}
|
|
391
|
+
StTablesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: StTablesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
392
|
+
StTablesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: StTablesModule, declarations: [LocalTableComponent,
|
|
393
|
+
ConfigurationsComponent,
|
|
394
|
+
SelectTable], imports: [CommonModule,
|
|
395
|
+
MatButtonModule,
|
|
396
|
+
MatIconModule,
|
|
397
|
+
MatTableModule,
|
|
398
|
+
MatPaginatorModule,
|
|
399
|
+
MatFormFieldModule,
|
|
400
|
+
MatInputModule,
|
|
401
|
+
MatTooltipModule,
|
|
402
|
+
FormsModule,
|
|
403
|
+
ReactiveFormsModule,
|
|
404
|
+
RouterModule,
|
|
405
|
+
StDateFormatModule,
|
|
406
|
+
MatSortModule,
|
|
407
|
+
MatMenuModule,
|
|
408
|
+
MatSelectModule,
|
|
409
|
+
MatCheckboxModule], exports: [LocalTableComponent,
|
|
410
|
+
SelectTable] });
|
|
411
|
+
StTablesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: StTablesModule, providers: [
|
|
412
|
+
LocalTableService
|
|
413
|
+
], imports: [[
|
|
414
|
+
CommonModule,
|
|
415
|
+
MatButtonModule,
|
|
416
|
+
MatIconModule,
|
|
417
|
+
MatTableModule,
|
|
418
|
+
MatPaginatorModule,
|
|
419
|
+
MatFormFieldModule,
|
|
420
|
+
MatInputModule,
|
|
421
|
+
MatTooltipModule,
|
|
422
|
+
FormsModule,
|
|
423
|
+
ReactiveFormsModule,
|
|
424
|
+
RouterModule,
|
|
425
|
+
StDateFormatModule,
|
|
426
|
+
MatSortModule,
|
|
427
|
+
MatMenuModule,
|
|
428
|
+
MatSelectModule,
|
|
429
|
+
MatCheckboxModule
|
|
430
|
+
]] });
|
|
431
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.2.7", ngImport: i0, type: StTablesModule, decorators: [{
|
|
432
|
+
type: NgModule,
|
|
433
|
+
args: [{
|
|
434
|
+
declarations: [
|
|
435
|
+
LocalTableComponent,
|
|
436
|
+
ConfigurationsComponent,
|
|
437
|
+
SelectTable
|
|
438
|
+
],
|
|
439
|
+
exports: [
|
|
440
|
+
LocalTableComponent,
|
|
441
|
+
SelectTable
|
|
442
|
+
],
|
|
443
|
+
imports: [
|
|
444
|
+
CommonModule,
|
|
445
|
+
MatButtonModule,
|
|
446
|
+
MatIconModule,
|
|
447
|
+
MatTableModule,
|
|
448
|
+
MatPaginatorModule,
|
|
449
|
+
MatFormFieldModule,
|
|
450
|
+
MatInputModule,
|
|
451
|
+
MatTooltipModule,
|
|
452
|
+
FormsModule,
|
|
453
|
+
ReactiveFormsModule,
|
|
454
|
+
RouterModule,
|
|
455
|
+
StDateFormatModule,
|
|
456
|
+
MatSortModule,
|
|
457
|
+
MatMenuModule,
|
|
458
|
+
MatSelectModule,
|
|
459
|
+
MatCheckboxModule
|
|
460
|
+
],
|
|
461
|
+
providers: [
|
|
462
|
+
LocalTableService
|
|
463
|
+
]
|
|
464
|
+
}]
|
|
465
|
+
}] });
|
|
466
|
+
|
|
467
|
+
/*
|
|
468
|
+
* Public API Surface of ngx-st-tables
|
|
469
|
+
*/
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* Generated bundle index. Do not edit.
|
|
473
|
+
*/
|
|
474
|
+
|
|
475
|
+
export { ConfigurationsComponent, LocalTableComponent, LocalTableService, SelectTable, StTablesModule };
|
|
476
|
+
//# sourceMappingURL=ngx-st-tables.mjs.map
|