@lenne.tech/ng-base 13.17.0 → 13.20.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/base-cms/base-cms.module.d.ts +6 -6
- package/base-cms/interfaces/base-cms-module-config.interface.d.ts +6 -6
- package/base-cms/pages/base-cms/base-cms.component.d.ts +0 -7
- package/base-components/base-components.module.d.ts +6 -3
- package/base-components/components/model-form/model-form.component.d.ts +13 -2
- package/base-components/components/model-form-sub/model-form-sub.component.d.ts +26 -0
- package/base-components/components/model-table/model-table.component.d.ts +4 -3
- package/base-components/components/refence-input/refence-input.component.d.ts +23 -0
- package/base-components/components/upload-image/upload-image.component.d.ts +70 -0
- package/base-components/public-api.d.ts +3 -0
- package/base-prototype/base-prototype.module.d.ts +7 -6
- package/base-prototype/pages/profile/profile.component.d.ts +34 -0
- package/base-prototype/public-api.d.ts +1 -0
- package/esm2020/base-cms/base-cms.module.mjs +3 -4
- package/esm2020/base-cms/interfaces/base-cms-module-config.interface.mjs +1 -1
- package/esm2020/base-cms/pages/base-cms/base-cms.component.mjs +10 -24
- package/esm2020/base-components/base-components.module.mjs +15 -3
- package/esm2020/base-components/components/model-form/model-form.component.mjs +47 -12
- package/esm2020/base-components/components/model-form-sub/model-form-sub.component.mjs +48 -0
- package/esm2020/base-components/components/model-table/model-table.component.mjs +14 -10
- package/esm2020/base-components/components/refence-input/refence-input.component.mjs +61 -0
- package/esm2020/base-components/components/upload-image/upload-image.component.mjs +138 -0
- package/esm2020/base-components/public-api.mjs +4 -1
- package/esm2020/base-prototype/base-prototype.module.mjs +8 -4
- package/esm2020/base-prototype/pages/profile/profile.component.mjs +45 -0
- package/esm2020/base-prototype/public-api.mjs +2 -1
- package/esm2020/shared/classes/graphql-meta.class.mjs +14 -2
- package/esm2020/shared/classes/sort.class.mjs +47 -0
- package/esm2020/shared/directives/sort.directive.mjs +54 -0
- package/esm2020/shared/public-api.mjs +4 -1
- package/esm2020/shared/services/graphql.service.mjs +2 -2
- package/esm2020/shared/services/user.service.mjs +2 -1
- package/fesm2015/lenne.tech-ng-base-base-cms.mjs +16 -30
- package/fesm2015/lenne.tech-ng-base-base-cms.mjs.map +1 -1
- package/fesm2015/lenne.tech-ng-base-base-components.mjs +304 -21
- package/fesm2015/lenne.tech-ng-base-base-components.mjs.map +1 -1
- package/fesm2015/lenne.tech-ng-base-base-prototype.mjs +49 -5
- package/fesm2015/lenne.tech-ng-base-base-prototype.mjs.map +1 -1
- package/fesm2015/lenne.tech-ng-base-shared.mjs +118 -4
- package/fesm2015/lenne.tech-ng-base-shared.mjs.map +1 -1
- package/fesm2020/lenne.tech-ng-base-base-cms.mjs +11 -26
- package/fesm2020/lenne.tech-ng-base-base-cms.mjs.map +1 -1
- package/fesm2020/lenne.tech-ng-base-base-components.mjs +298 -18
- package/fesm2020/lenne.tech-ng-base-base-components.mjs.map +1 -1
- package/fesm2020/lenne.tech-ng-base-base-prototype.mjs +49 -5
- package/fesm2020/lenne.tech-ng-base-base-prototype.mjs.map +1 -1
- package/fesm2020/lenne.tech-ng-base-shared.mjs +115 -4
- package/fesm2020/lenne.tech-ng-base-shared.mjs.map +1 -1
- package/package.json +1 -1
- package/shared/classes/sort.class.d.ts +19 -0
- package/shared/directives/sort.directive.d.ts +14 -0
- package/shared/public-api.d.ts +2 -0
|
@@ -8,6 +8,7 @@ import { trigger, transition, query, style, animate } from '@angular/animations'
|
|
|
8
8
|
import { Subscription } from 'rxjs';
|
|
9
9
|
import * as i1$1 from '@lenne.tech/ng-base/shared';
|
|
10
10
|
import { ToastType, GraphQLRequestType } from '@lenne.tech/ng-base/shared';
|
|
11
|
+
import * as i1$2 from '@angular/common/http';
|
|
11
12
|
|
|
12
13
|
class InputComponent {
|
|
13
14
|
constructor() {
|
|
@@ -370,6 +371,235 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImpor
|
|
|
370
371
|
args: [{ selector: 'base-breadcrumb', template: "<ul class=\"pt-3\">\n <li *ngFor=\"let breadcrumb of breadcrumbs$ | async\">\n <a [routerLink]=\"breadcrumb.url\">{{ breadcrumb.label }}</a>\n </li>\n</ul>\n", styles: ["ul{list-style:none;margin:0;padding:0}ul li{display:inline}ul li:before{content:\">\";margin:0 6px}ul li:first-child:before{content:\"\";margin:0}\n"] }]
|
|
371
372
|
}], ctorParameters: function () { return [{ type: i1$1.BreadcrumbService }]; } });
|
|
372
373
|
|
|
374
|
+
class UploadImageComponent {
|
|
375
|
+
constructor(httpClient) {
|
|
376
|
+
this.httpClient = httpClient;
|
|
377
|
+
this.supportText = 'Supports: JPEG, JPG, PNG';
|
|
378
|
+
this.required = false;
|
|
379
|
+
this.dragText = 'Drag & Drop';
|
|
380
|
+
this.validExtensions = ['image/jpeg', 'image/jpg', 'image/png'];
|
|
381
|
+
this.url = 'http://localhost:3000';
|
|
382
|
+
this.uploadPath = '/files/upload';
|
|
383
|
+
this.deletePath = '/files/';
|
|
384
|
+
this.path = '/files/';
|
|
385
|
+
this.dragActive = false;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* The dragOver function is called when the user drags a file over the dropzone. It prevents the default action of the
|
|
389
|
+
* event, and sets the dragText to 'Release to Upload' and the dragActive to true
|
|
390
|
+
*
|
|
391
|
+
* @param event - any - This is the event that is triggered when the user drags a file over the dropzone.
|
|
392
|
+
*/
|
|
393
|
+
dragOver(event) {
|
|
394
|
+
event.preventDefault();
|
|
395
|
+
this.dragText = 'Release to Upload';
|
|
396
|
+
this.dragActive = true;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* When the user drags a file over the drop zone, the dragActive variable is set to true, which will change the color of
|
|
400
|
+
* the drop zone to green
|
|
401
|
+
*
|
|
402
|
+
* @param event - The event object that is passed to the dragLeave event.
|
|
403
|
+
*/
|
|
404
|
+
dragLeave(event) {
|
|
405
|
+
this.dragText = 'Drag & Drop';
|
|
406
|
+
this.dragActive = false;
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* The function takes an event as a parameter, prevents the default action of the event, sets the URL of the image to the
|
|
410
|
+
* file that was dragged and dropped, sets the text of the drag and drop area to the default text, and sets the
|
|
411
|
+
* dragActive variable to false
|
|
412
|
+
*
|
|
413
|
+
* @param event - any - This is the event that is triggered when the user drags and drops a file.
|
|
414
|
+
*/
|
|
415
|
+
drop(event) {
|
|
416
|
+
event.preventDefault();
|
|
417
|
+
this.setUrl(event.dataTransfer.files[0]);
|
|
418
|
+
this.dragText = 'Drag & Drop';
|
|
419
|
+
this.dragActive = false;
|
|
420
|
+
}
|
|
421
|
+
/**
|
|
422
|
+
* It takes a file as an argument, checks if the file type is valid, and if it is, it creates a new FileReader object,
|
|
423
|
+
* sets the onload function to set the fileUrl to the result of the fileReader, sets the selectedFile to the file, and
|
|
424
|
+
* calls the upload function
|
|
425
|
+
*
|
|
426
|
+
* @param file - any - this is the file that is selected by the user.
|
|
427
|
+
*/
|
|
428
|
+
setUrl(file) {
|
|
429
|
+
if (this.validExtensions.includes(file.type)) {
|
|
430
|
+
const fileReader = new FileReader();
|
|
431
|
+
fileReader.onload = () => {
|
|
432
|
+
this.fileUrl = fileReader.result;
|
|
433
|
+
this.selectedFile = file;
|
|
434
|
+
this.upload();
|
|
435
|
+
};
|
|
436
|
+
fileReader.readAsDataURL(file);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
/**
|
|
440
|
+
* The function takes an event as an argument, and then sets the url of the file to the first file in the event's
|
|
441
|
+
* target's files array
|
|
442
|
+
*
|
|
443
|
+
* @param event - any - The event that is triggered when the user selects a file.
|
|
444
|
+
*/
|
|
445
|
+
selectFile(event) {
|
|
446
|
+
this.setUrl(event.target.files[0]);
|
|
447
|
+
}
|
|
448
|
+
/**
|
|
449
|
+
* We create a new FormData object, append the selected file to it, and then send it to the server
|
|
450
|
+
*/
|
|
451
|
+
upload() {
|
|
452
|
+
const data = new FormData();
|
|
453
|
+
data.append('file', this.selectedFile);
|
|
454
|
+
this.httpClient.post(this.url + this.uploadPath, data).subscribe((result) => {
|
|
455
|
+
if (result === null || result === void 0 ? void 0 : result.id) {
|
|
456
|
+
this.control.setValue(result.id);
|
|
457
|
+
}
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
/**
|
|
461
|
+
* It deletes the file from the server and sets the selectedFile and fileUrl to null
|
|
462
|
+
*
|
|
463
|
+
* @param [id] - The id of the file to delete.
|
|
464
|
+
*/
|
|
465
|
+
deleteFile(id) {
|
|
466
|
+
this.selectedFile = null;
|
|
467
|
+
this.fileUrl = null;
|
|
468
|
+
if (id) {
|
|
469
|
+
this.httpClient.delete(this.url + this.deletePath + id).subscribe((result) => {
|
|
470
|
+
this.selectedFile = null;
|
|
471
|
+
this.fileUrl = null;
|
|
472
|
+
this.control.setValue('');
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
UploadImageComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: UploadImageComponent, deps: [{ token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Component });
|
|
478
|
+
UploadImageComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.3", type: UploadImageComponent, selector: "base-upload-image", inputs: { id: "id", name: "name", label: "label", supportText: "supportText", required: "required", dragText: "dragText", validExtensions: "validExtensions", control: "control", url: "url", uploadPath: "uploadPath", deletePath: "deletePath", path: "path" }, ngImport: i0, template: "<div class=\"mt-3\">\n <label [for]=\"id\" class=\"form-label\" [ngClass]=\"{ required: required }\" *ngIf=\"label\">{{ label }}</label>\n <div\n class=\"drag-area\"\n (dragover)=\"dragOver($event)\"\n (dragleave)=\"dragLeave($event)\"\n (drop)=\"drop($event)\"\n [ngClass]=\"{ active: dragActive }\"\n >\n <ng-container *ngIf=\"selectedFile && !control?.value\">\n <img [src]=\"fileUrl\" *ngIf=\"selectedFile\" />\n <button class=\"btn btn-danger\" (click)=\"deleteFile()\">L\u00F6schen</button>\n </ng-container>\n\n <ng-container *ngIf=\"control?.value\">\n <img [src]=\"url + path + control?.value\" />\n <button class=\"btn btn-danger\" (click)=\"deleteFile(control?.value)\">L\u00F6schen</button>\n </ng-container>\n\n <ng-container *ngIf=\"!selectedFile && !control?.value\">\n <div class=\"icon\">\n <i class=\"bi bi-images\"></i>\n </div>\n\n <span class=\"header\">{{ dragText }}</span>\n <span class=\"header\">or <span class=\"button\" (click)=\"fileInput.click()\">browse</span></span>\n <input type=\"file\" (change)=\"selectFile($event)\" hidden #fileInput />\n <span class=\"support\">{{ supportText }}</span>\n </ng-container>\n </div>\n</div>\n", styles: [".required:after{content:\" *\"}.drag-area{height:400px;border:2px dashed #e1e1e1;display:flex;flex-direction:column;justify-content:center;align-items:center;margin:10px auto;padding:20px}.drag-area img{height:100%;max-height:300px;max-width:100%}.drag-area .btn-danger{margin-top:auto}.drag-area .icon{font-size:50px;color:var(--bs-primary)}.drag-area .header{font-size:20px;font-weight:500}.drag-area .support{font-size:12px;color:#e1e1e1;margin:10px 0 15px}.drag-area .button{font-size:20px;font-weight:500;color:var(--bs-primary);cursor:pointer}.active{border:2px solid var(--bs-primary)}\n"], directives: [{ type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
|
|
479
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: UploadImageComponent, decorators: [{
|
|
480
|
+
type: Component,
|
|
481
|
+
args: [{ selector: 'base-upload-image', template: "<div class=\"mt-3\">\n <label [for]=\"id\" class=\"form-label\" [ngClass]=\"{ required: required }\" *ngIf=\"label\">{{ label }}</label>\n <div\n class=\"drag-area\"\n (dragover)=\"dragOver($event)\"\n (dragleave)=\"dragLeave($event)\"\n (drop)=\"drop($event)\"\n [ngClass]=\"{ active: dragActive }\"\n >\n <ng-container *ngIf=\"selectedFile && !control?.value\">\n <img [src]=\"fileUrl\" *ngIf=\"selectedFile\" />\n <button class=\"btn btn-danger\" (click)=\"deleteFile()\">L\u00F6schen</button>\n </ng-container>\n\n <ng-container *ngIf=\"control?.value\">\n <img [src]=\"url + path + control?.value\" />\n <button class=\"btn btn-danger\" (click)=\"deleteFile(control?.value)\">L\u00F6schen</button>\n </ng-container>\n\n <ng-container *ngIf=\"!selectedFile && !control?.value\">\n <div class=\"icon\">\n <i class=\"bi bi-images\"></i>\n </div>\n\n <span class=\"header\">{{ dragText }}</span>\n <span class=\"header\">or <span class=\"button\" (click)=\"fileInput.click()\">browse</span></span>\n <input type=\"file\" (change)=\"selectFile($event)\" hidden #fileInput />\n <span class=\"support\">{{ supportText }}</span>\n </ng-container>\n </div>\n</div>\n", styles: [".required:after{content:\" *\"}.drag-area{height:400px;border:2px dashed #e1e1e1;display:flex;flex-direction:column;justify-content:center;align-items:center;margin:10px auto;padding:20px}.drag-area img{height:100%;max-height:300px;max-width:100%}.drag-area .btn-danger{margin-top:auto}.drag-area .icon{font-size:50px;color:var(--bs-primary)}.drag-area .header{font-size:20px;font-weight:500}.drag-area .support{font-size:12px;color:#e1e1e1;margin:10px 0 15px}.drag-area .button{font-size:20px;font-weight:500;color:var(--bs-primary);cursor:pointer}.active{border:2px solid var(--bs-primary)}\n"] }]
|
|
482
|
+
}], ctorParameters: function () { return [{ type: i1$2.HttpClient }]; }, propDecorators: { id: [{
|
|
483
|
+
type: Input
|
|
484
|
+
}], name: [{
|
|
485
|
+
type: Input
|
|
486
|
+
}], label: [{
|
|
487
|
+
type: Input
|
|
488
|
+
}], supportText: [{
|
|
489
|
+
type: Input
|
|
490
|
+
}], required: [{
|
|
491
|
+
type: Input
|
|
492
|
+
}], dragText: [{
|
|
493
|
+
type: Input
|
|
494
|
+
}], validExtensions: [{
|
|
495
|
+
type: Input
|
|
496
|
+
}], control: [{
|
|
497
|
+
type: Input
|
|
498
|
+
}], url: [{
|
|
499
|
+
type: Input
|
|
500
|
+
}], uploadPath: [{
|
|
501
|
+
type: Input
|
|
502
|
+
}], deletePath: [{
|
|
503
|
+
type: Input
|
|
504
|
+
}], path: [{
|
|
505
|
+
type: Input
|
|
506
|
+
}] } });
|
|
507
|
+
|
|
508
|
+
class RefenceInputComponent {
|
|
509
|
+
constructor(graphQLService) {
|
|
510
|
+
this.graphQLService = graphQLService;
|
|
511
|
+
this.placeholder = '';
|
|
512
|
+
this.required = false;
|
|
513
|
+
this.method = 'find';
|
|
514
|
+
this.fields = ['id', 'name'];
|
|
515
|
+
this.valueField = 'id';
|
|
516
|
+
this.nameField = 'name';
|
|
517
|
+
this.objects = [];
|
|
518
|
+
}
|
|
519
|
+
ngOnInit() {
|
|
520
|
+
this.graphQLService
|
|
521
|
+
.graphQl(this.method, {
|
|
522
|
+
fields: this.fields,
|
|
523
|
+
type: GraphQLRequestType.QUERY,
|
|
524
|
+
})
|
|
525
|
+
.subscribe((result) => {
|
|
526
|
+
if (result) {
|
|
527
|
+
this.objects = result;
|
|
528
|
+
}
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
RefenceInputComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: RefenceInputComponent, deps: [{ token: i1$1.GraphQLService }], target: i0.ɵɵFactoryTarget.Component });
|
|
533
|
+
RefenceInputComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.3", type: RefenceInputComponent, selector: "base-refence-input", inputs: { id: "id", name: "name", label: "label", placeholder: "placeholder", autocomplete: "autocomplete", tabIndex: "tabIndex", control: "control", required: "required", method: "method", fields: "fields", valueField: "valueField", nameField: "nameField" }, ngImport: i0, template: "<div class=\"form-group mb-3\">\n <label [for]=\"id\" class=\"form-label\" [ngClass]=\"{ required: required }\" *ngIf=\"label\">{{ label }}</label>\n <input\n [id]=\"id\"\n [name]=\"name\"\n class=\"form-control\"\n [formControl]=\"control\"\n [required]=\"required\"\n [placeholder]=\"placeholder\"\n [autocomplete]=\"autocomplete ?? null\"\n [tabIndex]=\"tabIndex ?? null\"\n [ngClass]=\"{ 'is-invalid': control?.invalid && control?.touched }\"\n [attr.list]=\"id + '-datalistOptions'\"\n />\n <datalist [id]=\"id + '-datalistOptions'\">\n <option *ngFor=\"let object of objects\" [value]=\"object[valueField]\">{{ object[nameField] }}</option>\n </datalist>\n\n <div class=\"invalid-feedback m-2\" *ngIf=\"control?.invalid && (control?.dirty || control?.touched)\">\n <div *ngIf=\"control?.errors?.['required']\">Dieses Feld ist ein Pflichtfeld.</div>\n <div *ngIf=\"control?.errors?.['minlength']\">\n Die Mindestl\u00E4nge f\u00FCr dieses Feld betr\u00E4gt\n {{control.errors?.['minlength']?.requiredLength}} Zeichen.\n </div>\n <div *ngIf=\"control?.errors?.['maxlength']\">\n Die maximale L\u00E4nge f\u00FCr dieses Feld betr\u00E4gt\n {{control.errors?.['maxlength']?.requiredLength}} Zeichen.\n </div>\n <div *ngIf=\"control?.errors?.['email']\">Bitte eine g\u00FCltige E-Mail Adresse angeben.</div>\n <div *ngIf=\"control?.errors?.['matching']\">Die Passw\u00F6rter m\u00FCssen \u00FCberein stimmen.</div>\n </div>\n</div>\n", styles: [""], directives: [{ type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i2.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: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { type: i2.RequiredValidator, selector: ":not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]", inputs: ["required"] }, { type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.NgSelectOption, selector: "option", inputs: ["ngValue", "value"] }, { type: i2.ɵNgSelectMultipleOption, selector: "option", inputs: ["ngValue", "value"] }] });
|
|
534
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: RefenceInputComponent, decorators: [{
|
|
535
|
+
type: Component,
|
|
536
|
+
args: [{ selector: 'base-refence-input', template: "<div class=\"form-group mb-3\">\n <label [for]=\"id\" class=\"form-label\" [ngClass]=\"{ required: required }\" *ngIf=\"label\">{{ label }}</label>\n <input\n [id]=\"id\"\n [name]=\"name\"\n class=\"form-control\"\n [formControl]=\"control\"\n [required]=\"required\"\n [placeholder]=\"placeholder\"\n [autocomplete]=\"autocomplete ?? null\"\n [tabIndex]=\"tabIndex ?? null\"\n [ngClass]=\"{ 'is-invalid': control?.invalid && control?.touched }\"\n [attr.list]=\"id + '-datalistOptions'\"\n />\n <datalist [id]=\"id + '-datalistOptions'\">\n <option *ngFor=\"let object of objects\" [value]=\"object[valueField]\">{{ object[nameField] }}</option>\n </datalist>\n\n <div class=\"invalid-feedback m-2\" *ngIf=\"control?.invalid && (control?.dirty || control?.touched)\">\n <div *ngIf=\"control?.errors?.['required']\">Dieses Feld ist ein Pflichtfeld.</div>\n <div *ngIf=\"control?.errors?.['minlength']\">\n Die Mindestl\u00E4nge f\u00FCr dieses Feld betr\u00E4gt\n {{control.errors?.['minlength']?.requiredLength}} Zeichen.\n </div>\n <div *ngIf=\"control?.errors?.['maxlength']\">\n Die maximale L\u00E4nge f\u00FCr dieses Feld betr\u00E4gt\n {{control.errors?.['maxlength']?.requiredLength}} Zeichen.\n </div>\n <div *ngIf=\"control?.errors?.['email']\">Bitte eine g\u00FCltige E-Mail Adresse angeben.</div>\n <div *ngIf=\"control?.errors?.['matching']\">Die Passw\u00F6rter m\u00FCssen \u00FCberein stimmen.</div>\n </div>\n</div>\n", styles: [""] }]
|
|
537
|
+
}], ctorParameters: function () { return [{ type: i1$1.GraphQLService }]; }, propDecorators: { id: [{
|
|
538
|
+
type: Input
|
|
539
|
+
}], name: [{
|
|
540
|
+
type: Input
|
|
541
|
+
}], label: [{
|
|
542
|
+
type: Input
|
|
543
|
+
}], placeholder: [{
|
|
544
|
+
type: Input
|
|
545
|
+
}], autocomplete: [{
|
|
546
|
+
type: Input
|
|
547
|
+
}], tabIndex: [{
|
|
548
|
+
type: Input
|
|
549
|
+
}], control: [{
|
|
550
|
+
type: Input
|
|
551
|
+
}], required: [{
|
|
552
|
+
type: Input
|
|
553
|
+
}], method: [{
|
|
554
|
+
type: Input
|
|
555
|
+
}], fields: [{
|
|
556
|
+
type: Input
|
|
557
|
+
}], valueField: [{
|
|
558
|
+
type: Input
|
|
559
|
+
}], nameField: [{
|
|
560
|
+
type: Input
|
|
561
|
+
}] } });
|
|
562
|
+
|
|
563
|
+
class ModelFormSubComponent {
|
|
564
|
+
constructor() {
|
|
565
|
+
this.config = {};
|
|
566
|
+
this.keys = [];
|
|
567
|
+
}
|
|
568
|
+
ngOnInit() {
|
|
569
|
+
this.keys = Object.keys(this.fields);
|
|
570
|
+
}
|
|
571
|
+
/**
|
|
572
|
+
* It takes a string, capitalizes the first letter, and returns the new string
|
|
573
|
+
*
|
|
574
|
+
* @param value - The string that you want to capitalize the first letter of.
|
|
575
|
+
* @returns The first letter of the string is being capitalized and the rest of the string is being returned.
|
|
576
|
+
*/
|
|
577
|
+
capitalizeFirstLetter(value) {
|
|
578
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* It takes an AbstractControl and returns a FormControl
|
|
582
|
+
*
|
|
583
|
+
* @param control - AbstractControl | null | undefined
|
|
584
|
+
* @returns A FormControl
|
|
585
|
+
*/
|
|
586
|
+
transformToControl(control) {
|
|
587
|
+
return control;
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
ModelFormSubComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ModelFormSubComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
591
|
+
ModelFormSubComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.3", type: ModelFormSubComponent, selector: "base-model-form-sub", inputs: { fields: "fields", form: "form", config: "config" }, ngImport: i0, template: "<div class=\"mt-3\" *ngFor=\"let key of keys\">\n <ng-container *ngIf=\"!fields[key]?.type\">\n <fieldset class=\"border rounded-3 p-3\">\n <legend class=\"float-none w-auto px-3\">\n {{ config[key]?.label ? config[key].label : capitalizeFirstLetter(key) }}\n </legend>\n <base-model-form-sub\n [fields]=\"fields[key]\"\n [config]=\"config[key]?.fields || {}\"\n [form]=\"form.get(key)\"\n ></base-model-form-sub>\n </fieldset>\n </ng-container>\n\n <ng-container *ngIf=\"fields[key]?.type\">\n <ng-container [ngSwitch]=\"config[key]?.type ? config[key]?.type : fields[key]?.type\">\n <ng-container *ngSwitchCase=\"'String'\">\n <ng-container *ngIf=\"fields[key]?.isList && !config[key]?.exclude\">\n <base-tags\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"config[key]?.label ? config[key].label : capitalizeFirstLetter(key)\"\n [placeholder]=\"config[key]?.placeholder || ''\"\n [control]=\"transformToControl(form?.get(key))\"\n [required]=\"fields[key].isRequired\"\n ></base-tags>\n </ng-container>\n\n <ng-container *ngIf=\"!fields[key]?.isList && !config[key]?.exclude\">\n <base-input\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"config[key]?.label ? config[key].label : capitalizeFirstLetter(key)\"\n [placeholder]=\"config[key]?.placeholder || ''\"\n [type]=\"'text'\"\n [control]=\"transformToControl(form?.get(key))\"\n [required]=\"fields[key].isRequired\"\n ></base-input>\n </ng-container>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'Image'\">\n <base-upload-image\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"config[key]?.label ? config[key].label : capitalizeFirstLetter(key)\"\n [control]=\"transformToControl(form?.get(key))\"\n [url]=\"config[key]?.url\"\n [path]=\"config[key]?.path || '/files/'\"\n [uploadPath]=\"config[key]?.uploadPath || '/files/upload'\"\n [deletePath]=\"config[key]?.deletePath || '/files/'\"\n [supportText]=\"config[key]?.supportText || 'Unterst\u00FCtzte Formate: JPEG, JPG, PNG'\"\n [dragText]=\"config[key]?.dragText || 'Drag & Drop'\"\n [validExtensions]=\"config[key]?.validExtensions || ['image/jpeg', 'image/jpg', 'image/png']\"\n [required]=\"fields[key].isRequired\"\n ></base-upload-image>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'Reference'\">\n <base-refence-input\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"config[key]?.label ? config[key].label : capitalizeFirstLetter(key)\"\n [control]=\"transformToControl(form?.get(key))\"\n [method]=\"config[key]?.method || 'find'\"\n [fields]=\"config[key]?.fields || ['id', 'name']\"\n [valueField]=\"config[key]?.valueField || 'id'\"\n [nameField]=\"config[key]?.nameField || 'name'\"\n [required]=\"fields[key].isRequired\"\n ></base-refence-input>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'Boolean'\">\n <base-checkbox\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"config[key]?.label ? config[key].label : capitalizeFirstLetter(key)\"\n [control]=\"transformToControl(form?.get(key))\"\n [required]=\"fields[key].isRequired\"\n ></base-checkbox>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'Float'\">\n <base-input\n [id]=\"key\"\n [name]=\"key\"\n [type]=\"'number'\"\n [label]=\"config[key]?.label ? config[key].label : capitalizeFirstLetter(key)\"\n [placeholder]=\"config[key]?.placeholder || ''\"\n [control]=\"transformToControl(form?.get(key))\"\n [required]=\"fields[key].isRequired\"\n ></base-input>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'DateTime'\">\n <base-input\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"config[key]?.label ? config[key].label : capitalizeFirstLetter(key)\"\n [placeholder]=\"config[key]?.placeholder || ''\"\n [type]=\"'datetime-local'\"\n [control]=\"transformToControl(form?.get(key))\"\n [required]=\"fields[key].isRequired\"\n ></base-input>\n </ng-container>\n </ng-container>\n </ng-container>\n</div>\n", styles: [""], components: [{ type: ModelFormSubComponent, selector: "base-model-form-sub", inputs: ["fields", "form", "config"] }, { type: TagsComponent, selector: "base-tags", inputs: ["id", "name", "label", "placeholder", "autocomplete", "tabIndex", "control", "options", "custom", "removeByKey", "required"] }, { type: InputComponent, selector: "base-input", inputs: ["id", "name", "label", "placeholder", "autocomplete", "tabIndex", "control", "type", "required"] }, { type: UploadImageComponent, selector: "base-upload-image", inputs: ["id", "name", "label", "supportText", "required", "dragText", "validExtensions", "control", "url", "uploadPath", "deletePath", "path"] }, { type: RefenceInputComponent, selector: "base-refence-input", inputs: ["id", "name", "label", "placeholder", "autocomplete", "tabIndex", "control", "required", "method", "fields", "valueField", "nameField"] }, { type: CheckboxComponent, selector: "base-checkbox", inputs: ["id", "name", "label", "value", "control", "required"] }], directives: [{ type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }] });
|
|
592
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ModelFormSubComponent, decorators: [{
|
|
593
|
+
type: Component,
|
|
594
|
+
args: [{ selector: 'base-model-form-sub', template: "<div class=\"mt-3\" *ngFor=\"let key of keys\">\n <ng-container *ngIf=\"!fields[key]?.type\">\n <fieldset class=\"border rounded-3 p-3\">\n <legend class=\"float-none w-auto px-3\">\n {{ config[key]?.label ? config[key].label : capitalizeFirstLetter(key) }}\n </legend>\n <base-model-form-sub\n [fields]=\"fields[key]\"\n [config]=\"config[key]?.fields || {}\"\n [form]=\"form.get(key)\"\n ></base-model-form-sub>\n </fieldset>\n </ng-container>\n\n <ng-container *ngIf=\"fields[key]?.type\">\n <ng-container [ngSwitch]=\"config[key]?.type ? config[key]?.type : fields[key]?.type\">\n <ng-container *ngSwitchCase=\"'String'\">\n <ng-container *ngIf=\"fields[key]?.isList && !config[key]?.exclude\">\n <base-tags\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"config[key]?.label ? config[key].label : capitalizeFirstLetter(key)\"\n [placeholder]=\"config[key]?.placeholder || ''\"\n [control]=\"transformToControl(form?.get(key))\"\n [required]=\"fields[key].isRequired\"\n ></base-tags>\n </ng-container>\n\n <ng-container *ngIf=\"!fields[key]?.isList && !config[key]?.exclude\">\n <base-input\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"config[key]?.label ? config[key].label : capitalizeFirstLetter(key)\"\n [placeholder]=\"config[key]?.placeholder || ''\"\n [type]=\"'text'\"\n [control]=\"transformToControl(form?.get(key))\"\n [required]=\"fields[key].isRequired\"\n ></base-input>\n </ng-container>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'Image'\">\n <base-upload-image\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"config[key]?.label ? config[key].label : capitalizeFirstLetter(key)\"\n [control]=\"transformToControl(form?.get(key))\"\n [url]=\"config[key]?.url\"\n [path]=\"config[key]?.path || '/files/'\"\n [uploadPath]=\"config[key]?.uploadPath || '/files/upload'\"\n [deletePath]=\"config[key]?.deletePath || '/files/'\"\n [supportText]=\"config[key]?.supportText || 'Unterst\u00FCtzte Formate: JPEG, JPG, PNG'\"\n [dragText]=\"config[key]?.dragText || 'Drag & Drop'\"\n [validExtensions]=\"config[key]?.validExtensions || ['image/jpeg', 'image/jpg', 'image/png']\"\n [required]=\"fields[key].isRequired\"\n ></base-upload-image>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'Reference'\">\n <base-refence-input\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"config[key]?.label ? config[key].label : capitalizeFirstLetter(key)\"\n [control]=\"transformToControl(form?.get(key))\"\n [method]=\"config[key]?.method || 'find'\"\n [fields]=\"config[key]?.fields || ['id', 'name']\"\n [valueField]=\"config[key]?.valueField || 'id'\"\n [nameField]=\"config[key]?.nameField || 'name'\"\n [required]=\"fields[key].isRequired\"\n ></base-refence-input>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'Boolean'\">\n <base-checkbox\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"config[key]?.label ? config[key].label : capitalizeFirstLetter(key)\"\n [control]=\"transformToControl(form?.get(key))\"\n [required]=\"fields[key].isRequired\"\n ></base-checkbox>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'Float'\">\n <base-input\n [id]=\"key\"\n [name]=\"key\"\n [type]=\"'number'\"\n [label]=\"config[key]?.label ? config[key].label : capitalizeFirstLetter(key)\"\n [placeholder]=\"config[key]?.placeholder || ''\"\n [control]=\"transformToControl(form?.get(key))\"\n [required]=\"fields[key].isRequired\"\n ></base-input>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'DateTime'\">\n <base-input\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"config[key]?.label ? config[key].label : capitalizeFirstLetter(key)\"\n [placeholder]=\"config[key]?.placeholder || ''\"\n [type]=\"'datetime-local'\"\n [control]=\"transformToControl(form?.get(key))\"\n [required]=\"fields[key].isRequired\"\n ></base-input>\n </ng-container>\n </ng-container>\n </ng-container>\n</div>\n", styles: [""] }]
|
|
595
|
+
}], propDecorators: { fields: [{
|
|
596
|
+
type: Input
|
|
597
|
+
}], form: [{
|
|
598
|
+
type: Input
|
|
599
|
+
}], config: [{
|
|
600
|
+
type: Input
|
|
601
|
+
}] } });
|
|
602
|
+
|
|
373
603
|
class ModelFormComponent {
|
|
374
604
|
constructor(graphQLMetaService, graphQLService, formsService) {
|
|
375
605
|
this.graphQLMetaService = graphQLMetaService;
|
|
@@ -377,6 +607,7 @@ class ModelFormComponent {
|
|
|
377
607
|
this.formsService = formsService;
|
|
378
608
|
this.delete = true;
|
|
379
609
|
this.logging = false;
|
|
610
|
+
this.config = {};
|
|
380
611
|
this.finished = new EventEmitter();
|
|
381
612
|
this.loading = false;
|
|
382
613
|
this.keys = [];
|
|
@@ -410,12 +641,15 @@ class ModelFormComponent {
|
|
|
410
641
|
console.log('ModelFormComponent::init->fields', this.fields);
|
|
411
642
|
console.log('ModelFormComponent::init->keys', this.keys);
|
|
412
643
|
}
|
|
413
|
-
this.createForm(this.fields);
|
|
644
|
+
this.form = this.createForm(this.fields);
|
|
414
645
|
if (this.id) {
|
|
415
646
|
this.getObjectById(this.id);
|
|
416
647
|
}
|
|
417
648
|
}
|
|
418
649
|
}
|
|
650
|
+
getKeysFromSubObject(key) {
|
|
651
|
+
return Object.keys(this.fields[key]);
|
|
652
|
+
}
|
|
419
653
|
/**
|
|
420
654
|
* It takes an id, and then calls the graphQLService to get the object from the database
|
|
421
655
|
*
|
|
@@ -424,11 +658,12 @@ class ModelFormComponent {
|
|
|
424
658
|
getObjectById(id) {
|
|
425
659
|
if (this.logging) {
|
|
426
660
|
console.log('ModelFormComponent::getObjectById->id', id);
|
|
661
|
+
console.log('ModelFormComponent::getObjectById->requestFields', this.createRequestObject(this.fields));
|
|
427
662
|
}
|
|
428
663
|
this.graphQLService
|
|
429
664
|
.graphQl('get' + this.capitalizeFirstLetter(this.modelName), {
|
|
430
665
|
arguments: { id },
|
|
431
|
-
fields: this.
|
|
666
|
+
fields: this.createRequestObject(this.fields),
|
|
432
667
|
type: GraphQLRequestType.QUERY,
|
|
433
668
|
})
|
|
434
669
|
.subscribe({
|
|
@@ -444,20 +679,46 @@ class ModelFormComponent {
|
|
|
444
679
|
},
|
|
445
680
|
});
|
|
446
681
|
}
|
|
682
|
+
/**
|
|
683
|
+
* It takes a GraphQL type collection and returns an array of strings and objects
|
|
684
|
+
*
|
|
685
|
+
* @param fields - IGraphQLTypeCollection - This is the object that is returned from the
|
|
686
|
+
* introspection query.
|
|
687
|
+
* @returns An array of strings and objects.
|
|
688
|
+
*/
|
|
689
|
+
createRequestObject(fields) {
|
|
690
|
+
var _a;
|
|
691
|
+
const requestFields = [];
|
|
692
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
693
|
+
if ((_a = fields[key]) === null || _a === void 0 ? void 0 : _a.type) {
|
|
694
|
+
requestFields.push(key);
|
|
695
|
+
}
|
|
696
|
+
else {
|
|
697
|
+
const subkeys = this.createRequestObject(fields[key]);
|
|
698
|
+
const resultObject = {};
|
|
699
|
+
resultObject[key] = subkeys;
|
|
700
|
+
requestFields.push(resultObject);
|
|
701
|
+
}
|
|
702
|
+
}
|
|
703
|
+
return requestFields;
|
|
704
|
+
}
|
|
447
705
|
/**
|
|
448
706
|
* It takes a collection of GraphQL types and creates a form group with a form control for each type
|
|
449
707
|
*
|
|
450
708
|
* @param fields - IGraphQLTypeCollection
|
|
451
709
|
*/
|
|
452
710
|
createForm(fields) {
|
|
453
|
-
var _a;
|
|
711
|
+
var _a, _b;
|
|
454
712
|
const group = {};
|
|
455
713
|
for (const [key, value] of Object.entries(fields)) {
|
|
456
714
|
if ((_a = fields[key]) === null || _a === void 0 ? void 0 : _a.type) {
|
|
457
|
-
group[key] = new FormControl('', value.isRequired ? Validators.required : []);
|
|
715
|
+
group[key] = new FormControl(((_b = fields[key]) === null || _b === void 0 ? void 0 : _b.type) === 'Float' ? 0 : '', value.isRequired ? Validators.required : []);
|
|
716
|
+
}
|
|
717
|
+
else {
|
|
718
|
+
group[key] = this.createForm(fields[key]);
|
|
458
719
|
}
|
|
459
720
|
}
|
|
460
|
-
|
|
721
|
+
return new FormGroup(group);
|
|
461
722
|
}
|
|
462
723
|
/**
|
|
463
724
|
* It calls the graphQLService to delete the object with the id of the object that is currently being edited
|
|
@@ -515,6 +776,9 @@ class ModelFormComponent {
|
|
|
515
776
|
this.loading = false;
|
|
516
777
|
return;
|
|
517
778
|
}
|
|
779
|
+
if (this.logging) {
|
|
780
|
+
console.log('ModelFormComponent::submit->formValue', this.form.value);
|
|
781
|
+
}
|
|
518
782
|
this.graphQLService
|
|
519
783
|
.graphQl(this.operation + this.capitalizeFirstLetter(this.modelName), {
|
|
520
784
|
arguments: this.operation === 'update' ? { id: this.id, input: this.form.value } : { input: this.form.value },
|
|
@@ -534,18 +798,22 @@ class ModelFormComponent {
|
|
|
534
798
|
}
|
|
535
799
|
}
|
|
536
800
|
ModelFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ModelFormComponent, deps: [{ token: i1$1.GraphQLMetaService }, { token: i1$1.GraphQLService }, { token: i1$1.FormsService }], target: i0.ɵɵFactoryTarget.Component });
|
|
537
|
-
ModelFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.3", type: ModelFormComponent, selector: "base-model-form", inputs: { modelName: "modelName", id: "id", delete: "delete", logging: "logging" }, outputs: { finished: "finished" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"w-100\" *ngIf=\"form\">\n <
|
|
801
|
+
ModelFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.3", type: ModelFormComponent, selector: "base-model-form", inputs: { modelName: "modelName", label: "label", id: "id", delete: "delete", logging: "logging", config: "config" }, outputs: { finished: "finished" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"w-100\" *ngIf=\"form\">\n <h2>\n {{ label ? label : capitalizeFirstLetter(modelName) }} {{ operation === 'update' ? 'bearbeiten' : 'erstellen' }}\n </h2>\n\n <form [formGroup]=\"form\">\n <base-model-form-sub [fields]=\"fields\" [config]=\"config\" [form]=\"form\"></base-model-form-sub>\n\n <div class=\"d-flex mt-4\" [ngClass]=\"id && delete ? 'justify-content-between' : 'justify-content-end'\">\n <div *ngIf=\"id && delete\">\n <button class=\"btn btn-danger\" type=\"button\" (click)=\"deleteObject()\">L\u00F6schen</button>\n </div>\n <div>\n <button class=\"btn btn-primary\" type=\"button\" (click)=\"submit()\" *ngIf=\"!loading\">\n {{ operation === 'create' ? 'Erstellen' : 'Speichern' }}\n </button>\n <button class=\"btn btn-primary\" type=\"button\" disabled *ngIf=\"loading\">\n <span class=\"spinner-border spinner-border-sm\" role=\"status\" aria-hidden=\"true\"></span>\n {{ operation === 'create' ? 'Erstellen' : 'Speichern' }}...\n </button>\n </div>\n </div>\n </form>\n</div>\n", styles: [""], components: [{ type: ModelFormSubComponent, selector: "base-model-form-sub", inputs: ["fields", "form", "config"] }], directives: [{ type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i2.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { type: i2.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { type: i2.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
|
|
538
802
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ModelFormComponent, decorators: [{
|
|
539
803
|
type: Component,
|
|
540
|
-
args: [{ selector: 'base-model-form', template: "<div class=\"w-100\" *ngIf=\"form\">\n <
|
|
804
|
+
args: [{ selector: 'base-model-form', template: "<div class=\"w-100\" *ngIf=\"form\">\n <h2>\n {{ label ? label : capitalizeFirstLetter(modelName) }} {{ operation === 'update' ? 'bearbeiten' : 'erstellen' }}\n </h2>\n\n <form [formGroup]=\"form\">\n <base-model-form-sub [fields]=\"fields\" [config]=\"config\" [form]=\"form\"></base-model-form-sub>\n\n <div class=\"d-flex mt-4\" [ngClass]=\"id && delete ? 'justify-content-between' : 'justify-content-end'\">\n <div *ngIf=\"id && delete\">\n <button class=\"btn btn-danger\" type=\"button\" (click)=\"deleteObject()\">L\u00F6schen</button>\n </div>\n <div>\n <button class=\"btn btn-primary\" type=\"button\" (click)=\"submit()\" *ngIf=\"!loading\">\n {{ operation === 'create' ? 'Erstellen' : 'Speichern' }}\n </button>\n <button class=\"btn btn-primary\" type=\"button\" disabled *ngIf=\"loading\">\n <span class=\"spinner-border spinner-border-sm\" role=\"status\" aria-hidden=\"true\"></span>\n {{ operation === 'create' ? 'Erstellen' : 'Speichern' }}...\n </button>\n </div>\n </div>\n </form>\n</div>\n", styles: [""] }]
|
|
541
805
|
}], ctorParameters: function () { return [{ type: i1$1.GraphQLMetaService }, { type: i1$1.GraphQLService }, { type: i1$1.FormsService }]; }, propDecorators: { modelName: [{
|
|
542
806
|
type: Input
|
|
807
|
+
}], label: [{
|
|
808
|
+
type: Input
|
|
543
809
|
}], id: [{
|
|
544
810
|
type: Input
|
|
545
811
|
}], delete: [{
|
|
546
812
|
type: Input
|
|
547
813
|
}], logging: [{
|
|
548
814
|
type: Input
|
|
815
|
+
}], config: [{
|
|
816
|
+
type: Input
|
|
549
817
|
}], finished: [{
|
|
550
818
|
type: Output
|
|
551
819
|
}] } });
|
|
@@ -558,10 +826,11 @@ class ModelTableComponent {
|
|
|
558
826
|
this.create = true;
|
|
559
827
|
this.update = true;
|
|
560
828
|
this.delete = true;
|
|
561
|
-
this.
|
|
562
|
-
this.
|
|
829
|
+
this.config = {};
|
|
830
|
+
this.fieldConfig = {};
|
|
563
831
|
this.idSelected = new EventEmitter();
|
|
564
832
|
this.createModeChanged = new EventEmitter();
|
|
833
|
+
this.tableFields = ['id', 'name', 'title', 'description', 'email', 'createdAt', 'updatedAt'];
|
|
565
834
|
this.objects = [];
|
|
566
835
|
this.availableFields = [];
|
|
567
836
|
this.selectedId = '';
|
|
@@ -578,12 +847,13 @@ class ModelTableComponent {
|
|
|
578
847
|
});
|
|
579
848
|
}
|
|
580
849
|
ngOnChanges(changes) {
|
|
850
|
+
var _a;
|
|
581
851
|
if (changes['modelName'] && this.meta) {
|
|
582
852
|
this.init();
|
|
583
853
|
}
|
|
584
854
|
if (changes['objectId'] && this.meta) {
|
|
585
855
|
if (this.selectedId !== this.objectId) {
|
|
586
|
-
if (this.logging) {
|
|
856
|
+
if ((_a = this.config) === null || _a === void 0 ? void 0 : _a.logging) {
|
|
587
857
|
console.log('ModelTableComponent::ngOnChanges->selectedId', this.selectedId);
|
|
588
858
|
}
|
|
589
859
|
this.selectedId = this.objectId;
|
|
@@ -595,16 +865,19 @@ class ModelTableComponent {
|
|
|
595
865
|
* with. We're then using that information to populate the `availableFields` array
|
|
596
866
|
*/
|
|
597
867
|
init() {
|
|
598
|
-
var _a;
|
|
868
|
+
var _a, _b, _c;
|
|
599
869
|
this.availableFields = [];
|
|
870
|
+
if ((_a = this.config) === null || _a === void 0 ? void 0 : _a.tableFields) {
|
|
871
|
+
this.tableFields = this.config.tableFields;
|
|
872
|
+
}
|
|
600
873
|
const possibleFields = this.meta.getFields('find' + this.capitalizeFirstLetter(this.modelName) + 's');
|
|
601
874
|
const keys = Object.keys(possibleFields);
|
|
602
|
-
(
|
|
875
|
+
(_b = this.tableFields) === null || _b === void 0 ? void 0 : _b.forEach((field) => {
|
|
603
876
|
if (keys.includes(field)) {
|
|
604
877
|
this.availableFields.push(field);
|
|
605
878
|
}
|
|
606
879
|
});
|
|
607
|
-
if (this.logging) {
|
|
880
|
+
if ((_c = this.config) === null || _c === void 0 ? void 0 : _c.logging) {
|
|
608
881
|
console.log('ModelTableComponent::init->possibleFields', possibleFields);
|
|
609
882
|
console.log('ModelTableComponent::init->keys', keys);
|
|
610
883
|
console.log('ModelTableComponent::init->availableFields', this.availableFields);
|
|
@@ -633,7 +906,8 @@ class ModelTableComponent {
|
|
|
633
906
|
})
|
|
634
907
|
.subscribe({
|
|
635
908
|
next: (value) => {
|
|
636
|
-
|
|
909
|
+
var _a;
|
|
910
|
+
if ((_a = this.config) === null || _a === void 0 ? void 0 : _a.logging) {
|
|
637
911
|
console.log('ModelTableComponent::loadObjects->value', value);
|
|
638
912
|
}
|
|
639
913
|
this.objects = value;
|
|
@@ -670,10 +944,10 @@ class ModelTableComponent {
|
|
|
670
944
|
}
|
|
671
945
|
}
|
|
672
946
|
ModelTableComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ModelTableComponent, deps: [{ token: i1$1.GraphQLMetaService }, { token: i1$1.GraphQLService }], target: i0.ɵɵFactoryTarget.Component });
|
|
673
|
-
ModelTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.3", type: ModelTableComponent, selector: "base-model-table", inputs: { modelName: "modelName", objectId: "objectId", createMode: "createMode", create: "create", update: "update", delete: "delete",
|
|
947
|
+
ModelTableComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.3", type: ModelTableComponent, selector: "base-model-table", inputs: { modelName: "modelName", objectId: "objectId", createMode: "createMode", create: "create", update: "update", delete: "delete", config: "config", fieldConfig: "fieldConfig" }, outputs: { idSelected: "idSelected", createModeChanged: "createModeChanged" }, usesOnChanges: true, ngImport: i0, template: "<div *ngIf=\"!selectedId && !createMode\">\n <div class=\"w-100 d-flex flex-row justify-content-between mb-4\">\n <h2 *ngIf=\"modelName\">\n {{ config?.plural ? config?.plural : config?.label ? config?.label : capitalizeFirstLetter(modelName) + 's' }}\n </h2>\n <div class=\"d-flex align-items-center\">\n <button class=\"btn btn-primary\" (click)=\"createNewObject()\" *ngIf=\"create\">Erstellen</button>\n </div>\n </div>\n <table class=\"table table-hover table-responsive bg-white\">\n <thead>\n <tr>\n <th scope=\"col\" *ngFor=\"let field of availableFields\">{{ capitalizeFirstLetter(field) }}</th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let object of objects\">\n <td class=\"cursor-pointer\" *ngFor=\"let field of availableFields\" (click)=\"selectId(object)\">\n {{ object[field] }}\n </td>\n </tr>\n </tbody>\n </table>\n</div>\n\n<div class=\"w-100\" *ngIf=\"selectedId || createMode\">\n <button class=\"btn btn-outline-primary mb-3\" (click)=\"selectId('')\">Zur\u00FCck</button>\n <base-model-form\n [modelName]=\"modelName\"\n [label]=\"config?.label\"\n [config]=\"fieldConfig\"\n [logging]=\"config?.logging\"\n [id]=\"selectedId\"\n (finished)=\"selectId('')\"\n [delete]=\"delete\"\n ></base-model-form>\n</div>\n", styles: [".cursor-pointer{cursor:pointer}.table>:not(:first-child){border-top:0}table{border-radius:.25rem;border-color:#e2e8f0!important}table thead{text-transform:uppercase;font-size:12px}table thead th{padding:12px 24px}table tbody tr td{font-weight:400!important;font-size:16px;padding:16px 24px}\n"], components: [{ type: ModelFormComponent, selector: "base-model-form", inputs: ["modelName", "label", "id", "delete", "logging", "config"], outputs: ["finished"] }], directives: [{ type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }] });
|
|
674
948
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ModelTableComponent, decorators: [{
|
|
675
949
|
type: Component,
|
|
676
|
-
args: [{ selector: 'base-model-table', template: "<div *ngIf=\"!selectedId && !createMode\">\n <div class=\"w-100 d-flex flex-row justify-content-between mb-4\">\n <
|
|
950
|
+
args: [{ selector: 'base-model-table', template: "<div *ngIf=\"!selectedId && !createMode\">\n <div class=\"w-100 d-flex flex-row justify-content-between mb-4\">\n <h2 *ngIf=\"modelName\">\n {{ config?.plural ? config?.plural : config?.label ? config?.label : capitalizeFirstLetter(modelName) + 's' }}\n </h2>\n <div class=\"d-flex align-items-center\">\n <button class=\"btn btn-primary\" (click)=\"createNewObject()\" *ngIf=\"create\">Erstellen</button>\n </div>\n </div>\n <table class=\"table table-hover table-responsive bg-white\">\n <thead>\n <tr>\n <th scope=\"col\" *ngFor=\"let field of availableFields\">{{ capitalizeFirstLetter(field) }}</th>\n </tr>\n </thead>\n <tbody>\n <tr *ngFor=\"let object of objects\">\n <td class=\"cursor-pointer\" *ngFor=\"let field of availableFields\" (click)=\"selectId(object)\">\n {{ object[field] }}\n </td>\n </tr>\n </tbody>\n </table>\n</div>\n\n<div class=\"w-100\" *ngIf=\"selectedId || createMode\">\n <button class=\"btn btn-outline-primary mb-3\" (click)=\"selectId('')\">Zur\u00FCck</button>\n <base-model-form\n [modelName]=\"modelName\"\n [label]=\"config?.label\"\n [config]=\"fieldConfig\"\n [logging]=\"config?.logging\"\n [id]=\"selectedId\"\n (finished)=\"selectId('')\"\n [delete]=\"delete\"\n ></base-model-form>\n</div>\n", styles: [".cursor-pointer{cursor:pointer}.table>:not(:first-child){border-top:0}table{border-radius:.25rem;border-color:#e2e8f0!important}table thead{text-transform:uppercase;font-size:12px}table thead th{padding:12px 24px}table tbody tr td{font-weight:400!important;font-size:16px;padding:16px 24px}\n"] }]
|
|
677
951
|
}], ctorParameters: function () { return [{ type: i1$1.GraphQLMetaService }, { type: i1$1.GraphQLService }]; }, propDecorators: { modelName: [{
|
|
678
952
|
type: Input
|
|
679
953
|
}], objectId: [{
|
|
@@ -686,9 +960,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImpor
|
|
|
686
960
|
type: Input
|
|
687
961
|
}], delete: [{
|
|
688
962
|
type: Input
|
|
689
|
-
}],
|
|
963
|
+
}], config: [{
|
|
690
964
|
type: Input
|
|
691
|
-
}],
|
|
965
|
+
}], fieldConfig: [{
|
|
692
966
|
type: Input
|
|
693
967
|
}], idSelected: [{
|
|
694
968
|
type: Output
|
|
@@ -712,6 +986,9 @@ const elements = [
|
|
|
712
986
|
BreadcrumbComponent,
|
|
713
987
|
ModelFormComponent,
|
|
714
988
|
ModelTableComponent,
|
|
989
|
+
ModelFormSubComponent,
|
|
990
|
+
UploadImageComponent,
|
|
991
|
+
RefenceInputComponent,
|
|
715
992
|
];
|
|
716
993
|
class BaseComponentsModule {
|
|
717
994
|
}
|
|
@@ -728,7 +1005,10 @@ BaseComponentsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", ve
|
|
|
728
1005
|
SkeletonLoaderComponent,
|
|
729
1006
|
BreadcrumbComponent,
|
|
730
1007
|
ModelFormComponent,
|
|
731
|
-
ModelTableComponent
|
|
1008
|
+
ModelTableComponent,
|
|
1009
|
+
ModelFormSubComponent,
|
|
1010
|
+
UploadImageComponent,
|
|
1011
|
+
RefenceInputComponent
|
|
732
1012
|
], imports: [FormsModule, ReactiveFormsModule, CommonModule], exports: [
|
|
733
1013
|
// Components
|
|
734
1014
|
InputComponent,
|
|
@@ -741,7 +1021,10 @@ BaseComponentsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", ve
|
|
|
741
1021
|
SkeletonLoaderComponent,
|
|
742
1022
|
BreadcrumbComponent,
|
|
743
1023
|
ModelFormComponent,
|
|
744
|
-
ModelTableComponent
|
|
1024
|
+
ModelTableComponent,
|
|
1025
|
+
ModelFormSubComponent,
|
|
1026
|
+
UploadImageComponent,
|
|
1027
|
+
RefenceInputComponent
|
|
745
1028
|
] });
|
|
746
1029
|
BaseComponentsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: BaseComponentsModule, imports: [imports] });
|
|
747
1030
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: BaseComponentsModule, decorators: [{
|
|
@@ -761,5 +1044,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImpor
|
|
|
761
1044
|
* Generated bundle index. Do not edit.
|
|
762
1045
|
*/
|
|
763
1046
|
|
|
764
|
-
export { BaseComponentsModule, BreadcrumbComponent, CheckboxComponent, InputComponent, LoadingBarComponent, ModelFormComponent, ModelTableComponent, SelectComponent, SkeletonLoaderComponent, TagsComponent, TextareaComponent, ToastComponent };
|
|
1047
|
+
export { BaseComponentsModule, BreadcrumbComponent, CheckboxComponent, InputComponent, LoadingBarComponent, ModelFormComponent, ModelFormSubComponent, ModelTableComponent, RefenceInputComponent, SelectComponent, SkeletonLoaderComponent, TagsComponent, TextareaComponent, ToastComponent, UploadImageComponent };
|
|
765
1048
|
//# sourceMappingURL=lenne.tech-ng-base-base-components.mjs.map
|