ngx-material-entity 15.1.4 → 15.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/table/default.actions.d.ts +21 -0
- package/components/table/table-data.builder.d.ts +3 -1
- package/components/table/table-data.d.ts +11 -0
- package/components/table/table.component.d.ts +3 -0
- package/encapsulation/js-2-xml.utilities.d.ts +15 -0
- package/encapsulation/jszip.utilities.d.ts +3 -2
- package/encapsulation/lodash.utilities.d.ts +7 -0
- package/esm2020/components/table/default.actions.mjs +65 -0
- package/esm2020/components/table/table-data.builder.mjs +11 -3
- package/esm2020/components/table/table-data.mjs +1 -1
- package/esm2020/components/table/table.component.mjs +34 -3
- package/esm2020/encapsulation/js-2-xml.utilities.mjs +18 -0
- package/esm2020/encapsulation/jszip.utilities.mjs +1 -1
- package/esm2020/encapsulation/lodash.utilities.mjs +13 -1
- package/esm2020/public-api.mjs +2 -1
- package/esm2020/services/entity.service.mjs +17 -1
- package/esm2020/utilities/file.utilities.mjs +17 -4
- package/fesm2015/ngx-material-entity.mjs +166 -8
- package/fesm2015/ngx-material-entity.mjs.map +1 -1
- package/fesm2020/ngx-material-entity.mjs +165 -7
- package/fesm2020/ngx-material-entity.mjs.map +1 -1
- package/package.json +3 -2
- package/public-api.d.ts +1 -0
- package/services/entity.service.d.ts +7 -0
- package/utilities/file.utilities.d.ts +7 -0
|
@@ -47,6 +47,7 @@ import { MatPaginator, MatPaginatorModule } from '@angular/material/paginator';
|
|
|
47
47
|
import { MatSort } from '@angular/material/sort';
|
|
48
48
|
import * as i10 from '@angular/material/menu';
|
|
49
49
|
import { MatMenuModule } from '@angular/material/menu';
|
|
50
|
+
import * as js2xml from 'js2xmlparser';
|
|
50
51
|
|
|
51
52
|
/**
|
|
52
53
|
* The enum Values for all the different DecoratorTypes.
|
|
@@ -152,6 +153,18 @@ class LodashUtilities {
|
|
|
152
153
|
static isArray(value) {
|
|
153
154
|
return isArray(value);
|
|
154
155
|
}
|
|
156
|
+
/* istanbul ignore next */
|
|
157
|
+
/**
|
|
158
|
+
* Checks if value is classified as an object that is not an array.
|
|
159
|
+
*
|
|
160
|
+
* @param value - The value to check.
|
|
161
|
+
* @returns Returns true if value is correctly classified, else false.
|
|
162
|
+
*/
|
|
163
|
+
static isObject(value) {
|
|
164
|
+
return value !== null
|
|
165
|
+
&& typeof value === 'object'
|
|
166
|
+
&& !LodashUtilities.isArray(value);
|
|
167
|
+
}
|
|
155
168
|
}
|
|
156
169
|
|
|
157
170
|
/**
|
|
@@ -494,10 +507,23 @@ class FileUtilities {
|
|
|
494
507
|
* @param fileData - The file data. Needs to contain a blob.
|
|
495
508
|
*/
|
|
496
509
|
static downloadSingleFile(fileData) {
|
|
510
|
+
this.downLoadBlob(fileData.file, fileData.name);
|
|
511
|
+
}
|
|
512
|
+
// TODO: Find a way to use blobs with jest
|
|
513
|
+
/* istanbul ignore next */
|
|
514
|
+
/**
|
|
515
|
+
* Downloads a blob.
|
|
516
|
+
*
|
|
517
|
+
* @param blob - The blob to download.
|
|
518
|
+
* @param name - The name of the downloaded file.
|
|
519
|
+
*/
|
|
520
|
+
static downLoadBlob(blob, name) {
|
|
497
521
|
const a = document.createElement('a');
|
|
498
|
-
const objectUrl = URL.createObjectURL(
|
|
522
|
+
const objectUrl = URL.createObjectURL(blob);
|
|
499
523
|
a.href = objectUrl;
|
|
500
|
-
|
|
524
|
+
if (name) {
|
|
525
|
+
a.download = name;
|
|
526
|
+
}
|
|
501
527
|
a.click();
|
|
502
528
|
URL.revokeObjectURL(objectUrl);
|
|
503
529
|
}
|
|
@@ -1748,6 +1774,22 @@ class EntityService {
|
|
|
1748
1774
|
}
|
|
1749
1775
|
// TODO: Find a way to use blobs with jest
|
|
1750
1776
|
/* istanbul ignore next */
|
|
1777
|
+
/**
|
|
1778
|
+
* Imports everything from the provided json file.
|
|
1779
|
+
*
|
|
1780
|
+
* @param file - The json file to import from.
|
|
1781
|
+
* @returns All entities that have been imported.
|
|
1782
|
+
*/
|
|
1783
|
+
async import(file) {
|
|
1784
|
+
const formData = new FormData();
|
|
1785
|
+
formData.append('import', file);
|
|
1786
|
+
const result = await firstValueFrom(this.http.post(`${this.baseUrl}/import`, formData));
|
|
1787
|
+
this.entities.push(...result);
|
|
1788
|
+
this.entitiesSubject.next(this.entities);
|
|
1789
|
+
return result;
|
|
1790
|
+
}
|
|
1791
|
+
// TODO: Find a way to use blobs with jest
|
|
1792
|
+
/* istanbul ignore next */
|
|
1751
1793
|
/**
|
|
1752
1794
|
* Creates the entity with form data when the entity contains files in contrast to creating it with a normal json body.
|
|
1753
1795
|
* All file values are stored inside their respective property key and their name.
|
|
@@ -3993,14 +4035,19 @@ class BaseDataBuilder extends BaseBuilder {
|
|
|
3993
4035
|
}
|
|
3994
4036
|
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
3995
4037
|
generateBaseData(data) {
|
|
3996
|
-
return new BaseDataInternal(data.title, data.displayColumns, data.EntityServiceClass, data.searchLabel ?? 'Search', data.createButtonLabel ?? 'Create', data.defaultEdit ?? 'dialog', data.searchString ?? defaultSearchFunction, data.allowCreate ?? (() => true), data.allowRead ?? (() => true), data.allowUpdate ?? (() => true), data.allowDelete ?? (() => true), data.multiSelectActions ?? [], data.multiSelectLabel ?? 'Actions', data.displayLoadingSpinner ?? true, data.
|
|
4038
|
+
return new BaseDataInternal(data.title, data.displayColumns, data.EntityServiceClass, data.searchLabel ?? 'Search', data.createButtonLabel ?? 'Create', data.defaultEdit ?? 'dialog', data.searchString ?? defaultSearchFunction, data.allowCreate ?? (() => true), data.allowRead ?? (() => true), data.allowUpdate ?? (() => true), data.allowDelete ?? (() => true), data.multiSelectActions ?? [], data.multiSelectLabel ?? 'Actions', data.displayLoadingSpinner ?? true, data.allowJsonImport ?? false, data.importActionData ?? {
|
|
4039
|
+
displayName: 'Import (JSON)',
|
|
4040
|
+
confirmDialogData: new ConfirmDialogDataBuilder()
|
|
4041
|
+
.withDefault('text', ['Do you really want to import entities from the provided file?'])
|
|
4042
|
+
.getResult()
|
|
4043
|
+
}, data.EntityClass, data.edit, data.create);
|
|
3997
4044
|
}
|
|
3998
4045
|
}
|
|
3999
4046
|
/**
|
|
4000
4047
|
* The internal TableData. Requires all default values the user can leave out.
|
|
4001
4048
|
*/
|
|
4002
4049
|
class BaseDataInternal {
|
|
4003
|
-
constructor(title, displayColumns, EntityServiceClass, searchLabel, createButtonLabel, defaultEdit, searchString, allowCreate, allowRead, allowUpdate, allowDelete, multiSelectActions, multiSelectLabel, displayLoadingSpinner, EntityClass, edit, create) {
|
|
4050
|
+
constructor(title, displayColumns, EntityServiceClass, searchLabel, createButtonLabel, defaultEdit, searchString, allowCreate, allowRead, allowUpdate, allowDelete, multiSelectActions, multiSelectLabel, displayLoadingSpinner, allowJsonImport, importActionData, EntityClass, edit, create) {
|
|
4004
4051
|
this.title = title;
|
|
4005
4052
|
this.displayColumns = displayColumns;
|
|
4006
4053
|
this.EntityServiceClass = EntityServiceClass;
|
|
@@ -4016,6 +4063,8 @@ class BaseDataInternal {
|
|
|
4016
4063
|
this.multiSelectActions = multiSelectActions;
|
|
4017
4064
|
this.multiSelectLabel = multiSelectLabel;
|
|
4018
4065
|
this.displayLoadingSpinner = displayLoadingSpinner;
|
|
4066
|
+
this.allowJsonImport = allowJsonImport;
|
|
4067
|
+
this.importActionData = importActionData;
|
|
4019
4068
|
this.edit = edit;
|
|
4020
4069
|
this.create = create;
|
|
4021
4070
|
}
|
|
@@ -4104,6 +4153,10 @@ class NgxMatEntityTableComponent {
|
|
|
4104
4153
|
*/
|
|
4105
4154
|
ngOnInit() {
|
|
4106
4155
|
this.data = new TableDataBuilder(this.tableData).getResult();
|
|
4156
|
+
this.importAction = {
|
|
4157
|
+
...this.data.baseData.importActionData,
|
|
4158
|
+
action: () => this.startImportJson()
|
|
4159
|
+
};
|
|
4107
4160
|
this.entityService = this.injector.get(this.data.baseData.EntityServiceClass);
|
|
4108
4161
|
const givenDisplayColumns = this.data.baseData.displayColumns.map((v) => v.displayName);
|
|
4109
4162
|
if (this.data.baseData.multiSelectActions.length) {
|
|
@@ -4132,6 +4185,33 @@ class NgxMatEntityTableComponent {
|
|
|
4132
4185
|
this.isLoading = false;
|
|
4133
4186
|
});
|
|
4134
4187
|
}
|
|
4188
|
+
startImportJson() {
|
|
4189
|
+
const input = document.createElement('input');
|
|
4190
|
+
input.type = 'file';
|
|
4191
|
+
input.accept = 'application/json';
|
|
4192
|
+
input.onchange = async () => {
|
|
4193
|
+
if (input.files) {
|
|
4194
|
+
this.importJson(input.files[0]);
|
|
4195
|
+
}
|
|
4196
|
+
};
|
|
4197
|
+
input.click();
|
|
4198
|
+
}
|
|
4199
|
+
importJson(file) {
|
|
4200
|
+
const dialogData = new ConfirmDialogDataBuilder(this.importAction.confirmDialogData)
|
|
4201
|
+
.withDefault('text', this.data.baseData.importActionData.confirmDialogData?.text)
|
|
4202
|
+
.withDefault('title', this.importAction.displayName)
|
|
4203
|
+
.getResult();
|
|
4204
|
+
const dialogRef = this.dialog.open(NgxMatEntityConfirmDialogComponent, {
|
|
4205
|
+
data: dialogData,
|
|
4206
|
+
autoFocus: false,
|
|
4207
|
+
restoreFocus: false
|
|
4208
|
+
});
|
|
4209
|
+
dialogRef.afterClosed().subscribe(res => {
|
|
4210
|
+
if (res == true) {
|
|
4211
|
+
void this.entityService.import(file);
|
|
4212
|
+
}
|
|
4213
|
+
});
|
|
4214
|
+
}
|
|
4135
4215
|
/**
|
|
4136
4216
|
* Edits an entity. This either calls the edit-Method provided by the user or uses a default edit-dialog.
|
|
4137
4217
|
*
|
|
@@ -4270,10 +4350,10 @@ class NgxMatEntityTableComponent {
|
|
|
4270
4350
|
}
|
|
4271
4351
|
}
|
|
4272
4352
|
NgxMatEntityTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.3", ngImport: i0, type: NgxMatEntityTableComponent, deps: [{ token: i1.MatDialog }, { token: i0.Injector }, { token: i3$1.Router }], target: i0.ɵɵFactoryTarget.Component });
|
|
4273
|
-
NgxMatEntityTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.3", type: NgxMatEntityTableComponent, selector: "ngx-mat-entity-table", inputs: { tableData: "tableData" }, viewQueries: [{ propertyName: "paginator", first: true, predicate: MatPaginator, descendants: true, static: true }, { propertyName: "sort", first: true, predicate: MatSort, descendants: true, static: true }, { propertyName: "filter", first: true, predicate: ["filter"], descendants: true, static: true }], ngImport: i0, template: "<h1 class=\"title\">{{data.baseData.title}}</h1>\n\n<div class=\"row\">\n <mat-form-field class=\"col-lg-8 col-md-6 col-sm-12\">\n <mat-label>{{data.baseData.searchLabel}}</mat-label>\n <input matInput (keyup)=\"applyFilter($event)\">\n </mat-form-field>\n <div\n *ngIf=\"data.baseData.multiSelectActions.length\"\n [class.col-lg-2]=\"data.baseData.allowCreate()\"\n [class.col-lg-4]=\"!data.baseData.allowCreate()\"\n [class.col-md-3]=\"data.baseData.allowCreate()\"\n [class.col-md-6]=\"!data.baseData.allowCreate()\"\n [class.col-sm-6]=\"data.baseData.allowCreate()\"\n [class.col-sm-12]=\"!data.baseData.allowCreate()\"\n >\n <button type=\"button\" class=\"actions-button\" [matMenuTriggerFor]=\"menu\" mat-raised-button>\n {{data.baseData.multiSelectLabel}}\n </button>\n </div>\n <mat-menu #menu=\"matMenu\">\n <button type=\"button\" *ngFor=\"let action of data.baseData.multiSelectActions\" [disabled]=\"multiActionDisabled(action)\" (click)=\"runMultiAction(action)\" mat-menu-item>\n {{action.displayName}}\n </button>\n </mat-menu>\n\n <div\n *ngIf=\"data.baseData.allowCreate()\"\n [class.col-lg-2]=\"data.baseData.multiSelectActions.length\"\n [class.col-lg-4]=\"!data.baseData.multiSelectActions.length\"\n [class.col-md-3]=\"data.baseData.multiSelectActions.length\"\n [class.col-md-6]=\"!data.baseData.multiSelectActions.length\"\n [class.col-sm-6]=\"data.baseData.multiSelectActions.length\"\n [class.col-sm-12]=\"!data.baseData.multiSelectActions.length\"\n >\n <button type=\"button\" class=\"create-button\" (click)=\"createEntity()\" mat-raised-button>\n {{data.baseData.createButtonLabel}}\n </button>\n </div>\n</div>\n\n<div class=\"mat-elevation-z8\">\n <mat-table [dataSource]=\"dataSource\" matSort>\n <!-- select Column -->\n <ng-container matColumnDef=\"select\">\n <mat-header-cell *matHeaderCellDef>\n <mat-checkbox (change)=\"$event ? SelectionUtilities.masterToggle(selection, dataSource) : null\" [checked]=\"selection.hasValue() && SelectionUtilities.isAllSelected(selection, dataSource)\" [indeterminate]=\"selection.hasValue() && !SelectionUtilities.isAllSelected(selection, dataSource)\"> </mat-checkbox>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let module\" class=\"module\">\n <mat-checkbox (click)=\"$event.stopPropagation()\" (change)=\"$event ? selection.toggle(module) : null\" [checked]=\"selection.isSelected(module)\"> </mat-checkbox>\n </mat-cell>\n </ng-container>\n\n <ng-container *ngFor=\"let dCol of data.baseData.displayColumns\" [matColumnDef]=\"dCol.displayName\">\n <mat-header-cell *matHeaderCellDef mat-sort-header>\n {{dCol.displayName}}\n </mat-header-cell>\n <mat-cell class=\"entity\" [class.enabled]=\"data.baseData.allowUpdate(entity) || data.baseData.allowRead(entity)\" (click)=\"editEntity(entity)\" *matCellDef=\"let entity\">\n {{dCol.value(entity)}}\n </mat-cell>\n </ng-container>\n\n <mat-header-row *matHeaderRowDef=\"displayedColumns\"></mat-header-row>\n <mat-row *matRowDef=\"let row; columns: displayedColumns\"></mat-row>\n </mat-table>\n\n <mat-spinner *ngIf=\"isLoading && data.baseData.displayLoadingSpinner\" style=\"margin-left: auto; margin-right: auto; margin-top: 10px; margin-bottom: 10px;\">\n </mat-spinner>\n\n <mat-paginator [length]=\"dataSource.filteredData.length\" [pageIndex]=\"0\" [pageSize]=\"10\" [pageSizeOptions]=\"[5, 10, 25, 50]\"></mat-paginator>\n</div>", styles: [".mdc-data-table__row:last-child .mdc-data-table__cell{border-bottom:1px solid rgba(0,0,0,.12)}button{width:100%}.title{text-align:center}.actions-button,.create-button{height:56px;line-height:24px;font-size:16px}.mat-column-select{flex:0 0 75px}.enabled:hover{cursor:pointer}@media (max-width: 767px){.actions-button,.create-button{margin-bottom:15px}}\n"], dependencies: [{ kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.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"] }, { kind: "component", type: i2$1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i2$1.MatLabel, selector: "mat-label" }, { kind: "component", type: i4$1.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex"], exportAs: ["matCheckbox"] }, { kind: "component", type: i5$1.MatTable, selector: "mat-table, table[mat-table]", exportAs: ["matTable"] }, { kind: "directive", type: i5$1.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { kind: "directive", type: i5$1.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { kind: "directive", type: i5$1.MatColumnDef, selector: "[matColumnDef]", inputs: ["sticky", "matColumnDef"] }, { kind: "directive", type: i5$1.MatCellDef, selector: "[matCellDef]" }, { kind: "directive", type: i5$1.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }, { kind: "directive", type: i5$1.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { kind: "directive", type: i5$1.MatCell, selector: "mat-cell, td[mat-cell]" }, { kind: "component", type: i5$1.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { kind: "component", type: i5$1.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }, { kind: "component", type: i8.MatPaginator, selector: "mat-paginator", inputs: ["disabled"], exportAs: ["matPaginator"] }, { kind: "component", type: i5.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i10.MatMenu, selector: "mat-menu", exportAs: ["matMenu"] }, { kind: "component", type: i10.MatMenuItem, selector: "[mat-menu-item]", inputs: ["disabled", "disableRipple", "role"], exportAs: ["matMenuItem"] }, { kind: "directive", type: i10.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", exportAs: ["matMenuTrigger"] }, { kind: "component", type: i7.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }] });
|
|
4353
|
+
NgxMatEntityTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "15.2.3", type: NgxMatEntityTableComponent, selector: "ngx-mat-entity-table", inputs: { tableData: "tableData" }, viewQueries: [{ propertyName: "paginator", first: true, predicate: MatPaginator, descendants: true, static: true }, { propertyName: "sort", first: true, predicate: MatSort, descendants: true, static: true }, { propertyName: "filter", first: true, predicate: ["filter"], descendants: true, static: true }], ngImport: i0, template: "<h1 class=\"title\">{{data.baseData.title}}</h1>\n\n<div class=\"row\">\n <mat-form-field class=\"col-lg-8 col-md-6 col-sm-12\">\n <mat-label>{{data.baseData.searchLabel}}</mat-label>\n <input matInput (keyup)=\"applyFilter($event)\">\n </mat-form-field>\n <div\n *ngIf=\"data.baseData.multiSelectActions.length\"\n [class.col-lg-2]=\"data.baseData.allowCreate()\"\n [class.col-lg-4]=\"!data.baseData.allowCreate()\"\n [class.col-md-3]=\"data.baseData.allowCreate()\"\n [class.col-md-6]=\"!data.baseData.allowCreate()\"\n [class.col-sm-6]=\"data.baseData.allowCreate()\"\n [class.col-sm-12]=\"!data.baseData.allowCreate()\"\n >\n <button type=\"button\" class=\"actions-button\" [matMenuTriggerFor]=\"menu\" mat-raised-button>\n {{data.baseData.multiSelectLabel}}\n </button>\n </div>\n <mat-menu #menu=\"matMenu\">\n <button *ngIf=\"data.baseData.allowJsonImport\" type=\"button\" [disabled]=\"importAction.enabled?.(this.selection.selected) === false\" (click)=\"runMultiAction(importAction)\" mat-menu-item>\n {{importAction.displayName}}\n </button>\n <button type=\"button\" *ngFor=\"let action of data.baseData.multiSelectActions\" [disabled]=\"multiActionDisabled(action)\" (click)=\"runMultiAction(action)\" mat-menu-item>\n {{action.displayName}}\n </button>\n </mat-menu>\n\n <div\n *ngIf=\"data.baseData.allowCreate()\"\n [class.col-lg-2]=\"data.baseData.multiSelectActions.length\"\n [class.col-lg-4]=\"!data.baseData.multiSelectActions.length\"\n [class.col-md-3]=\"data.baseData.multiSelectActions.length\"\n [class.col-md-6]=\"!data.baseData.multiSelectActions.length\"\n [class.col-sm-6]=\"data.baseData.multiSelectActions.length\"\n [class.col-sm-12]=\"!data.baseData.multiSelectActions.length\"\n >\n <button type=\"button\" class=\"create-button\" (click)=\"createEntity()\" mat-raised-button>\n {{data.baseData.createButtonLabel}}\n </button>\n </div>\n</div>\n\n<div class=\"mat-elevation-z8\">\n <mat-table [dataSource]=\"dataSource\" matSort>\n <!-- select Column -->\n <ng-container matColumnDef=\"select\">\n <mat-header-cell *matHeaderCellDef>\n <mat-checkbox (change)=\"$event ? SelectionUtilities.masterToggle(selection, dataSource) : null\" [checked]=\"selection.hasValue() && SelectionUtilities.isAllSelected(selection, dataSource)\" [indeterminate]=\"selection.hasValue() && !SelectionUtilities.isAllSelected(selection, dataSource)\"> </mat-checkbox>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let module\" class=\"module\">\n <mat-checkbox (click)=\"$event.stopPropagation()\" (change)=\"$event ? selection.toggle(module) : null\" [checked]=\"selection.isSelected(module)\"> </mat-checkbox>\n </mat-cell>\n </ng-container>\n\n <ng-container *ngFor=\"let dCol of data.baseData.displayColumns\" [matColumnDef]=\"dCol.displayName\">\n <mat-header-cell *matHeaderCellDef mat-sort-header>\n {{dCol.displayName}}\n </mat-header-cell>\n <mat-cell class=\"entity\" [class.enabled]=\"data.baseData.allowUpdate(entity) || data.baseData.allowRead(entity)\" (click)=\"editEntity(entity)\" *matCellDef=\"let entity\">\n {{dCol.value(entity)}}\n </mat-cell>\n </ng-container>\n\n <mat-header-row *matHeaderRowDef=\"displayedColumns\"></mat-header-row>\n <mat-row *matRowDef=\"let row; columns: displayedColumns\"></mat-row>\n </mat-table>\n\n <mat-spinner *ngIf=\"isLoading && data.baseData.displayLoadingSpinner\" style=\"margin-left: auto; margin-right: auto; margin-top: 10px; margin-bottom: 10px;\">\n </mat-spinner>\n\n <mat-paginator [length]=\"dataSource.filteredData.length\" [pageIndex]=\"0\" [pageSize]=\"10\" [pageSizeOptions]=\"[5, 10, 25, 50]\"></mat-paginator>\n</div>", styles: [".mdc-data-table__row:last-child .mdc-data-table__cell{border-bottom:1px solid rgba(0,0,0,.12)}button{width:100%}.title{text-align:center}.actions-button,.create-button{height:56px;line-height:24px;font-size:16px}.mat-column-select{flex:0 0 75px}.enabled:hover{cursor:pointer}@media (max-width: 767px){.actions-button,.create-button{margin-bottom:15px}}\n"], dependencies: [{ kind: "directive", type: i1$1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1$1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.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"] }, { kind: "component", type: i2$1.MatFormField, selector: "mat-form-field", inputs: ["hideRequiredMarker", "color", "floatLabel", "appearance", "subscriptSizing", "hintLabel"], exportAs: ["matFormField"] }, { kind: "directive", type: i2$1.MatLabel, selector: "mat-label" }, { kind: "component", type: i4$1.MatCheckbox, selector: "mat-checkbox", inputs: ["disableRipple", "color", "tabIndex"], exportAs: ["matCheckbox"] }, { kind: "component", type: i5$1.MatTable, selector: "mat-table, table[mat-table]", exportAs: ["matTable"] }, { kind: "directive", type: i5$1.MatHeaderCellDef, selector: "[matHeaderCellDef]" }, { kind: "directive", type: i5$1.MatHeaderRowDef, selector: "[matHeaderRowDef]", inputs: ["matHeaderRowDef", "matHeaderRowDefSticky"] }, { kind: "directive", type: i5$1.MatColumnDef, selector: "[matColumnDef]", inputs: ["sticky", "matColumnDef"] }, { kind: "directive", type: i5$1.MatCellDef, selector: "[matCellDef]" }, { kind: "directive", type: i5$1.MatRowDef, selector: "[matRowDef]", inputs: ["matRowDefColumns", "matRowDefWhen"] }, { kind: "directive", type: i5$1.MatHeaderCell, selector: "mat-header-cell, th[mat-header-cell]" }, { kind: "directive", type: i5$1.MatCell, selector: "mat-cell, td[mat-cell]" }, { kind: "component", type: i5$1.MatHeaderRow, selector: "mat-header-row, tr[mat-header-row]", exportAs: ["matHeaderRow"] }, { kind: "component", type: i5$1.MatRow, selector: "mat-row, tr[mat-row]", exportAs: ["matRow"] }, { kind: "component", type: i8.MatPaginator, selector: "mat-paginator", inputs: ["disabled"], exportAs: ["matPaginator"] }, { kind: "component", type: i5.MatButton, selector: " button[mat-button], button[mat-raised-button], button[mat-flat-button], button[mat-stroked-button] ", inputs: ["disabled", "disableRipple", "color"], exportAs: ["matButton"] }, { kind: "component", type: i10.MatMenu, selector: "mat-menu", exportAs: ["matMenu"] }, { kind: "component", type: i10.MatMenuItem, selector: "[mat-menu-item]", inputs: ["disabled", "disableRipple", "role"], exportAs: ["matMenuItem"] }, { kind: "directive", type: i10.MatMenuTrigger, selector: "[mat-menu-trigger-for], [matMenuTriggerFor]", exportAs: ["matMenuTrigger"] }, { kind: "component", type: i7.MatProgressSpinner, selector: "mat-progress-spinner, mat-spinner", inputs: ["color", "mode", "value", "diameter", "strokeWidth"], exportAs: ["matProgressSpinner"] }] });
|
|
4274
4354
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.3", ngImport: i0, type: NgxMatEntityTableComponent, decorators: [{
|
|
4275
4355
|
type: Component,
|
|
4276
|
-
args: [{ selector: 'ngx-mat-entity-table', template: "<h1 class=\"title\">{{data.baseData.title}}</h1>\n\n<div class=\"row\">\n <mat-form-field class=\"col-lg-8 col-md-6 col-sm-12\">\n <mat-label>{{data.baseData.searchLabel}}</mat-label>\n <input matInput (keyup)=\"applyFilter($event)\">\n </mat-form-field>\n <div\n *ngIf=\"data.baseData.multiSelectActions.length\"\n [class.col-lg-2]=\"data.baseData.allowCreate()\"\n [class.col-lg-4]=\"!data.baseData.allowCreate()\"\n [class.col-md-3]=\"data.baseData.allowCreate()\"\n [class.col-md-6]=\"!data.baseData.allowCreate()\"\n [class.col-sm-6]=\"data.baseData.allowCreate()\"\n [class.col-sm-12]=\"!data.baseData.allowCreate()\"\n >\n <button type=\"button\" class=\"actions-button\" [matMenuTriggerFor]=\"menu\" mat-raised-button>\n {{data.baseData.multiSelectLabel}}\n </button>\n </div>\n <mat-menu #menu=\"matMenu\">\n <button type=\"button\" *ngFor=\"let action of data.baseData.multiSelectActions\" [disabled]=\"multiActionDisabled(action)\" (click)=\"runMultiAction(action)\" mat-menu-item>\n {{action.displayName}}\n </button>\n </mat-menu>\n\n <div\n *ngIf=\"data.baseData.allowCreate()\"\n [class.col-lg-2]=\"data.baseData.multiSelectActions.length\"\n [class.col-lg-4]=\"!data.baseData.multiSelectActions.length\"\n [class.col-md-3]=\"data.baseData.multiSelectActions.length\"\n [class.col-md-6]=\"!data.baseData.multiSelectActions.length\"\n [class.col-sm-6]=\"data.baseData.multiSelectActions.length\"\n [class.col-sm-12]=\"!data.baseData.multiSelectActions.length\"\n >\n <button type=\"button\" class=\"create-button\" (click)=\"createEntity()\" mat-raised-button>\n {{data.baseData.createButtonLabel}}\n </button>\n </div>\n</div>\n\n<div class=\"mat-elevation-z8\">\n <mat-table [dataSource]=\"dataSource\" matSort>\n <!-- select Column -->\n <ng-container matColumnDef=\"select\">\n <mat-header-cell *matHeaderCellDef>\n <mat-checkbox (change)=\"$event ? SelectionUtilities.masterToggle(selection, dataSource) : null\" [checked]=\"selection.hasValue() && SelectionUtilities.isAllSelected(selection, dataSource)\" [indeterminate]=\"selection.hasValue() && !SelectionUtilities.isAllSelected(selection, dataSource)\"> </mat-checkbox>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let module\" class=\"module\">\n <mat-checkbox (click)=\"$event.stopPropagation()\" (change)=\"$event ? selection.toggle(module) : null\" [checked]=\"selection.isSelected(module)\"> </mat-checkbox>\n </mat-cell>\n </ng-container>\n\n <ng-container *ngFor=\"let dCol of data.baseData.displayColumns\" [matColumnDef]=\"dCol.displayName\">\n <mat-header-cell *matHeaderCellDef mat-sort-header>\n {{dCol.displayName}}\n </mat-header-cell>\n <mat-cell class=\"entity\" [class.enabled]=\"data.baseData.allowUpdate(entity) || data.baseData.allowRead(entity)\" (click)=\"editEntity(entity)\" *matCellDef=\"let entity\">\n {{dCol.value(entity)}}\n </mat-cell>\n </ng-container>\n\n <mat-header-row *matHeaderRowDef=\"displayedColumns\"></mat-header-row>\n <mat-row *matRowDef=\"let row; columns: displayedColumns\"></mat-row>\n </mat-table>\n\n <mat-spinner *ngIf=\"isLoading && data.baseData.displayLoadingSpinner\" style=\"margin-left: auto; margin-right: auto; margin-top: 10px; margin-bottom: 10px;\">\n </mat-spinner>\n\n <mat-paginator [length]=\"dataSource.filteredData.length\" [pageIndex]=\"0\" [pageSize]=\"10\" [pageSizeOptions]=\"[5, 10, 25, 50]\"></mat-paginator>\n</div>", styles: [".mdc-data-table__row:last-child .mdc-data-table__cell{border-bottom:1px solid rgba(0,0,0,.12)}button{width:100%}.title{text-align:center}.actions-button,.create-button{height:56px;line-height:24px;font-size:16px}.mat-column-select{flex:0 0 75px}.enabled:hover{cursor:pointer}@media (max-width: 767px){.actions-button,.create-button{margin-bottom:15px}}\n"] }]
|
|
4356
|
+
args: [{ selector: 'ngx-mat-entity-table', template: "<h1 class=\"title\">{{data.baseData.title}}</h1>\n\n<div class=\"row\">\n <mat-form-field class=\"col-lg-8 col-md-6 col-sm-12\">\n <mat-label>{{data.baseData.searchLabel}}</mat-label>\n <input matInput (keyup)=\"applyFilter($event)\">\n </mat-form-field>\n <div\n *ngIf=\"data.baseData.multiSelectActions.length\"\n [class.col-lg-2]=\"data.baseData.allowCreate()\"\n [class.col-lg-4]=\"!data.baseData.allowCreate()\"\n [class.col-md-3]=\"data.baseData.allowCreate()\"\n [class.col-md-6]=\"!data.baseData.allowCreate()\"\n [class.col-sm-6]=\"data.baseData.allowCreate()\"\n [class.col-sm-12]=\"!data.baseData.allowCreate()\"\n >\n <button type=\"button\" class=\"actions-button\" [matMenuTriggerFor]=\"menu\" mat-raised-button>\n {{data.baseData.multiSelectLabel}}\n </button>\n </div>\n <mat-menu #menu=\"matMenu\">\n <button *ngIf=\"data.baseData.allowJsonImport\" type=\"button\" [disabled]=\"importAction.enabled?.(this.selection.selected) === false\" (click)=\"runMultiAction(importAction)\" mat-menu-item>\n {{importAction.displayName}}\n </button>\n <button type=\"button\" *ngFor=\"let action of data.baseData.multiSelectActions\" [disabled]=\"multiActionDisabled(action)\" (click)=\"runMultiAction(action)\" mat-menu-item>\n {{action.displayName}}\n </button>\n </mat-menu>\n\n <div\n *ngIf=\"data.baseData.allowCreate()\"\n [class.col-lg-2]=\"data.baseData.multiSelectActions.length\"\n [class.col-lg-4]=\"!data.baseData.multiSelectActions.length\"\n [class.col-md-3]=\"data.baseData.multiSelectActions.length\"\n [class.col-md-6]=\"!data.baseData.multiSelectActions.length\"\n [class.col-sm-6]=\"data.baseData.multiSelectActions.length\"\n [class.col-sm-12]=\"!data.baseData.multiSelectActions.length\"\n >\n <button type=\"button\" class=\"create-button\" (click)=\"createEntity()\" mat-raised-button>\n {{data.baseData.createButtonLabel}}\n </button>\n </div>\n</div>\n\n<div class=\"mat-elevation-z8\">\n <mat-table [dataSource]=\"dataSource\" matSort>\n <!-- select Column -->\n <ng-container matColumnDef=\"select\">\n <mat-header-cell *matHeaderCellDef>\n <mat-checkbox (change)=\"$event ? SelectionUtilities.masterToggle(selection, dataSource) : null\" [checked]=\"selection.hasValue() && SelectionUtilities.isAllSelected(selection, dataSource)\" [indeterminate]=\"selection.hasValue() && !SelectionUtilities.isAllSelected(selection, dataSource)\"> </mat-checkbox>\n </mat-header-cell>\n <mat-cell *matCellDef=\"let module\" class=\"module\">\n <mat-checkbox (click)=\"$event.stopPropagation()\" (change)=\"$event ? selection.toggle(module) : null\" [checked]=\"selection.isSelected(module)\"> </mat-checkbox>\n </mat-cell>\n </ng-container>\n\n <ng-container *ngFor=\"let dCol of data.baseData.displayColumns\" [matColumnDef]=\"dCol.displayName\">\n <mat-header-cell *matHeaderCellDef mat-sort-header>\n {{dCol.displayName}}\n </mat-header-cell>\n <mat-cell class=\"entity\" [class.enabled]=\"data.baseData.allowUpdate(entity) || data.baseData.allowRead(entity)\" (click)=\"editEntity(entity)\" *matCellDef=\"let entity\">\n {{dCol.value(entity)}}\n </mat-cell>\n </ng-container>\n\n <mat-header-row *matHeaderRowDef=\"displayedColumns\"></mat-header-row>\n <mat-row *matRowDef=\"let row; columns: displayedColumns\"></mat-row>\n </mat-table>\n\n <mat-spinner *ngIf=\"isLoading && data.baseData.displayLoadingSpinner\" style=\"margin-left: auto; margin-right: auto; margin-top: 10px; margin-bottom: 10px;\">\n </mat-spinner>\n\n <mat-paginator [length]=\"dataSource.filteredData.length\" [pageIndex]=\"0\" [pageSize]=\"10\" [pageSizeOptions]=\"[5, 10, 25, 50]\"></mat-paginator>\n</div>", styles: [".mdc-data-table__row:last-child .mdc-data-table__cell{border-bottom:1px solid rgba(0,0,0,.12)}button{width:100%}.title{text-align:center}.actions-button,.create-button{height:56px;line-height:24px;font-size:16px}.mat-column-select{flex:0 0 75px}.enabled:hover{cursor:pointer}@media (max-width: 767px){.actions-button,.create-button{margin-bottom:15px}}\n"] }]
|
|
4277
4357
|
}], ctorParameters: function () { return [{ type: i1.MatDialog }, { type: i0.Injector }, { type: i3$1.Router }]; }, propDecorators: { tableData: [{
|
|
4278
4358
|
type: Input
|
|
4279
4359
|
}], paginator: [{
|
|
@@ -4339,6 +4419,84 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.3", ngImpor
|
|
|
4339
4419
|
}]
|
|
4340
4420
|
}] });
|
|
4341
4421
|
|
|
4422
|
+
/**
|
|
4423
|
+
* Encapsulates functionality of the js2xml package.
|
|
4424
|
+
*/
|
|
4425
|
+
class Js2XmlUtilities {
|
|
4426
|
+
/**
|
|
4427
|
+
* Returns a XML string representation of the specified object using the specified options.
|
|
4428
|
+
*
|
|
4429
|
+
* @param root - Name of the xml root element.
|
|
4430
|
+
* @param value - The json value to convert. Will be a child of root.
|
|
4431
|
+
* @param options - Additional options for the conversion.
|
|
4432
|
+
* @returns The converted xml string.
|
|
4433
|
+
*/
|
|
4434
|
+
static parse(root, value, options) {
|
|
4435
|
+
return js2xml.parse(root, value, options);
|
|
4436
|
+
}
|
|
4437
|
+
}
|
|
4438
|
+
|
|
4439
|
+
const CSV_SEPARATOR = ';';
|
|
4440
|
+
/**
|
|
4441
|
+
* A multi select action that exports the data as a json file.
|
|
4442
|
+
*
|
|
4443
|
+
* @param selectedEntities - The selected entities to export.
|
|
4444
|
+
*/
|
|
4445
|
+
function exportAsJsonMultiAction(selectedEntities) {
|
|
4446
|
+
const blob = new Blob([JSON.stringify(selectedEntities, null, '\t')], { type: '.json' });
|
|
4447
|
+
FileUtilities.downLoadBlob(blob, 'export.json');
|
|
4448
|
+
}
|
|
4449
|
+
/**
|
|
4450
|
+
* A multi select action that exports the data as a csv file.
|
|
4451
|
+
* Object values get stringified.
|
|
4452
|
+
*
|
|
4453
|
+
* @param selectedEntities - The selected entities to export.
|
|
4454
|
+
*/
|
|
4455
|
+
function exportAsCsvMultiAction(selectedEntities) {
|
|
4456
|
+
const blob = new Blob([convertToCsv(selectedEntities, ReflectUtilities.ownKeys(selectedEntities[0]))], { type: '.csv' });
|
|
4457
|
+
FileUtilities.downLoadBlob(blob, 'export.csv');
|
|
4458
|
+
}
|
|
4459
|
+
/**
|
|
4460
|
+
* A multi select action that exports the data as a xml file.
|
|
4461
|
+
* Object values get stringified.
|
|
4462
|
+
*
|
|
4463
|
+
* @param selectedEntities - The selected entities to export.
|
|
4464
|
+
*/
|
|
4465
|
+
function exportAsXmlMultiAction(selectedEntities) {
|
|
4466
|
+
const xmlString = Js2XmlUtilities.parse('values', selectedEntities);
|
|
4467
|
+
const blob = new Blob([xmlString], { type: '.xml' });
|
|
4468
|
+
FileUtilities.downLoadBlob(blob, 'export.xml');
|
|
4469
|
+
}
|
|
4470
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
4471
|
+
function convertToCsv(array, headerList) {
|
|
4472
|
+
const headerRow = headerList.join(CSV_SEPARATOR);
|
|
4473
|
+
let result = headerRow + '\r\n';
|
|
4474
|
+
for (const entity of array) {
|
|
4475
|
+
result += getLineForEntity(headerList, entity) + '\r\n';
|
|
4476
|
+
}
|
|
4477
|
+
return result;
|
|
4478
|
+
}
|
|
4479
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
4480
|
+
function getLineForEntity(headerList, entity) {
|
|
4481
|
+
let line = '';
|
|
4482
|
+
for (const head of headerList) {
|
|
4483
|
+
line = line += getLineForHeader(entity, head);
|
|
4484
|
+
}
|
|
4485
|
+
line.slice(0, line.length - 1);
|
|
4486
|
+
return line;
|
|
4487
|
+
}
|
|
4488
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
4489
|
+
function getLineForHeader(entity, head) {
|
|
4490
|
+
const value = entity[head];
|
|
4491
|
+
if (LodashUtilities.isObject(value)) {
|
|
4492
|
+
return `${JSON.stringify(value)}${CSV_SEPARATOR}`;
|
|
4493
|
+
}
|
|
4494
|
+
if (LodashUtilities.isArray(value) && LodashUtilities.isObject(value[0])) {
|
|
4495
|
+
return `${value.map(v => JSON.stringify(v))}${CSV_SEPARATOR}`;
|
|
4496
|
+
}
|
|
4497
|
+
return `${entity[head]}${CSV_SEPARATOR}`;
|
|
4498
|
+
}
|
|
4499
|
+
|
|
4342
4500
|
/**
|
|
4343
4501
|
* The base options for all propertyDecorators.
|
|
4344
4502
|
*/
|
|
@@ -4957,5 +5115,5 @@ function UnsavedChangesGuard(component) {
|
|
|
4957
5115
|
* Generated bundle index. Do not edit.
|
|
4958
5116
|
*/
|
|
4959
5117
|
|
|
4960
|
-
export { ArrayDecoratorConfig, DateUtilities, DecoratorTypes, Entity, EntityService, EntityUtilities, FileUtilities, NGX_EDIT_DATA, NGX_EDIT_DATA_ENTITY, NGX_EDIT_DATA_ENTITY_SERVICE, NGX_GET_VALIDATION_ERROR_MESSAGE, NgxMatEntityBaseInputComponent, NgxMatEntityConfirmDialogComponent, NgxMatEntityConfirmDialogModule, NgxMatEntityCreateDialogComponent, NgxMatEntityCreateDialogModule, NgxMatEntityEditDialogComponent, NgxMatEntityEditDialogModule, NgxMatEntityEditPageComponent, NgxMatEntityInputComponent, NgxMatEntityInputModule, NgxMatEntityTableComponent, NgxMatEntityTableModule, UnsavedChangesGuard, array, boolean, custom, date, defaultEditDataRoute, file, number, object, referencesMany, string };
|
|
5118
|
+
export { ArrayDecoratorConfig, DateUtilities, DecoratorTypes, Entity, EntityService, EntityUtilities, FileUtilities, NGX_EDIT_DATA, NGX_EDIT_DATA_ENTITY, NGX_EDIT_DATA_ENTITY_SERVICE, NGX_GET_VALIDATION_ERROR_MESSAGE, NgxMatEntityBaseInputComponent, NgxMatEntityConfirmDialogComponent, NgxMatEntityConfirmDialogModule, NgxMatEntityCreateDialogComponent, NgxMatEntityCreateDialogModule, NgxMatEntityEditDialogComponent, NgxMatEntityEditDialogModule, NgxMatEntityEditPageComponent, NgxMatEntityInputComponent, NgxMatEntityInputModule, NgxMatEntityTableComponent, NgxMatEntityTableModule, UnsavedChangesGuard, array, boolean, custom, date, defaultEditDataRoute, exportAsCsvMultiAction, exportAsJsonMultiAction, exportAsXmlMultiAction, file, number, object, referencesMany, string };
|
|
4961
5119
|
//# sourceMappingURL=ngx-material-entity.mjs.map
|