@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() {
|
|
@@ -369,6 +370,235 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImpor
|
|
|
369
370
|
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"] }]
|
|
370
371
|
}], ctorParameters: function () { return [{ type: i1$1.BreadcrumbService }]; } });
|
|
371
372
|
|
|
373
|
+
class UploadImageComponent {
|
|
374
|
+
constructor(httpClient) {
|
|
375
|
+
this.httpClient = httpClient;
|
|
376
|
+
this.supportText = 'Supports: JPEG, JPG, PNG';
|
|
377
|
+
this.required = false;
|
|
378
|
+
this.dragText = 'Drag & Drop';
|
|
379
|
+
this.validExtensions = ['image/jpeg', 'image/jpg', 'image/png'];
|
|
380
|
+
this.url = 'http://localhost:3000';
|
|
381
|
+
this.uploadPath = '/files/upload';
|
|
382
|
+
this.deletePath = '/files/';
|
|
383
|
+
this.path = '/files/';
|
|
384
|
+
this.dragActive = false;
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* The dragOver function is called when the user drags a file over the dropzone. It prevents the default action of the
|
|
388
|
+
* event, and sets the dragText to 'Release to Upload' and the dragActive to true
|
|
389
|
+
*
|
|
390
|
+
* @param event - any - This is the event that is triggered when the user drags a file over the dropzone.
|
|
391
|
+
*/
|
|
392
|
+
dragOver(event) {
|
|
393
|
+
event.preventDefault();
|
|
394
|
+
this.dragText = 'Release to Upload';
|
|
395
|
+
this.dragActive = true;
|
|
396
|
+
}
|
|
397
|
+
/**
|
|
398
|
+
* When the user drags a file over the drop zone, the dragActive variable is set to true, which will change the color of
|
|
399
|
+
* the drop zone to green
|
|
400
|
+
*
|
|
401
|
+
* @param event - The event object that is passed to the dragLeave event.
|
|
402
|
+
*/
|
|
403
|
+
dragLeave(event) {
|
|
404
|
+
this.dragText = 'Drag & Drop';
|
|
405
|
+
this.dragActive = false;
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* The function takes an event as a parameter, prevents the default action of the event, sets the URL of the image to the
|
|
409
|
+
* file that was dragged and dropped, sets the text of the drag and drop area to the default text, and sets the
|
|
410
|
+
* dragActive variable to false
|
|
411
|
+
*
|
|
412
|
+
* @param event - any - This is the event that is triggered when the user drags and drops a file.
|
|
413
|
+
*/
|
|
414
|
+
drop(event) {
|
|
415
|
+
event.preventDefault();
|
|
416
|
+
this.setUrl(event.dataTransfer.files[0]);
|
|
417
|
+
this.dragText = 'Drag & Drop';
|
|
418
|
+
this.dragActive = false;
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* It takes a file as an argument, checks if the file type is valid, and if it is, it creates a new FileReader object,
|
|
422
|
+
* sets the onload function to set the fileUrl to the result of the fileReader, sets the selectedFile to the file, and
|
|
423
|
+
* calls the upload function
|
|
424
|
+
*
|
|
425
|
+
* @param file - any - this is the file that is selected by the user.
|
|
426
|
+
*/
|
|
427
|
+
setUrl(file) {
|
|
428
|
+
if (this.validExtensions.includes(file.type)) {
|
|
429
|
+
const fileReader = new FileReader();
|
|
430
|
+
fileReader.onload = () => {
|
|
431
|
+
this.fileUrl = fileReader.result;
|
|
432
|
+
this.selectedFile = file;
|
|
433
|
+
this.upload();
|
|
434
|
+
};
|
|
435
|
+
fileReader.readAsDataURL(file);
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* The function takes an event as an argument, and then sets the url of the file to the first file in the event's
|
|
440
|
+
* target's files array
|
|
441
|
+
*
|
|
442
|
+
* @param event - any - The event that is triggered when the user selects a file.
|
|
443
|
+
*/
|
|
444
|
+
selectFile(event) {
|
|
445
|
+
this.setUrl(event.target.files[0]);
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* We create a new FormData object, append the selected file to it, and then send it to the server
|
|
449
|
+
*/
|
|
450
|
+
upload() {
|
|
451
|
+
const data = new FormData();
|
|
452
|
+
data.append('file', this.selectedFile);
|
|
453
|
+
this.httpClient.post(this.url + this.uploadPath, data).subscribe((result) => {
|
|
454
|
+
if (result?.id) {
|
|
455
|
+
this.control.setValue(result.id);
|
|
456
|
+
}
|
|
457
|
+
});
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* It deletes the file from the server and sets the selectedFile and fileUrl to null
|
|
461
|
+
*
|
|
462
|
+
* @param [id] - The id of the file to delete.
|
|
463
|
+
*/
|
|
464
|
+
deleteFile(id) {
|
|
465
|
+
this.selectedFile = null;
|
|
466
|
+
this.fileUrl = null;
|
|
467
|
+
if (id) {
|
|
468
|
+
this.httpClient.delete(this.url + this.deletePath + id).subscribe((result) => {
|
|
469
|
+
this.selectedFile = null;
|
|
470
|
+
this.fileUrl = null;
|
|
471
|
+
this.control.setValue('');
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
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 });
|
|
477
|
+
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"] }] });
|
|
478
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: UploadImageComponent, decorators: [{
|
|
479
|
+
type: Component,
|
|
480
|
+
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"] }]
|
|
481
|
+
}], ctorParameters: function () { return [{ type: i1$2.HttpClient }]; }, propDecorators: { id: [{
|
|
482
|
+
type: Input
|
|
483
|
+
}], name: [{
|
|
484
|
+
type: Input
|
|
485
|
+
}], label: [{
|
|
486
|
+
type: Input
|
|
487
|
+
}], supportText: [{
|
|
488
|
+
type: Input
|
|
489
|
+
}], required: [{
|
|
490
|
+
type: Input
|
|
491
|
+
}], dragText: [{
|
|
492
|
+
type: Input
|
|
493
|
+
}], validExtensions: [{
|
|
494
|
+
type: Input
|
|
495
|
+
}], control: [{
|
|
496
|
+
type: Input
|
|
497
|
+
}], url: [{
|
|
498
|
+
type: Input
|
|
499
|
+
}], uploadPath: [{
|
|
500
|
+
type: Input
|
|
501
|
+
}], deletePath: [{
|
|
502
|
+
type: Input
|
|
503
|
+
}], path: [{
|
|
504
|
+
type: Input
|
|
505
|
+
}] } });
|
|
506
|
+
|
|
507
|
+
class RefenceInputComponent {
|
|
508
|
+
constructor(graphQLService) {
|
|
509
|
+
this.graphQLService = graphQLService;
|
|
510
|
+
this.placeholder = '';
|
|
511
|
+
this.required = false;
|
|
512
|
+
this.method = 'find';
|
|
513
|
+
this.fields = ['id', 'name'];
|
|
514
|
+
this.valueField = 'id';
|
|
515
|
+
this.nameField = 'name';
|
|
516
|
+
this.objects = [];
|
|
517
|
+
}
|
|
518
|
+
ngOnInit() {
|
|
519
|
+
this.graphQLService
|
|
520
|
+
.graphQl(this.method, {
|
|
521
|
+
fields: this.fields,
|
|
522
|
+
type: GraphQLRequestType.QUERY,
|
|
523
|
+
})
|
|
524
|
+
.subscribe((result) => {
|
|
525
|
+
if (result) {
|
|
526
|
+
this.objects = result;
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
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 });
|
|
532
|
+
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"] }] });
|
|
533
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: RefenceInputComponent, decorators: [{
|
|
534
|
+
type: Component,
|
|
535
|
+
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: [""] }]
|
|
536
|
+
}], ctorParameters: function () { return [{ type: i1$1.GraphQLService }]; }, propDecorators: { id: [{
|
|
537
|
+
type: Input
|
|
538
|
+
}], name: [{
|
|
539
|
+
type: Input
|
|
540
|
+
}], label: [{
|
|
541
|
+
type: Input
|
|
542
|
+
}], placeholder: [{
|
|
543
|
+
type: Input
|
|
544
|
+
}], autocomplete: [{
|
|
545
|
+
type: Input
|
|
546
|
+
}], tabIndex: [{
|
|
547
|
+
type: Input
|
|
548
|
+
}], control: [{
|
|
549
|
+
type: Input
|
|
550
|
+
}], required: [{
|
|
551
|
+
type: Input
|
|
552
|
+
}], method: [{
|
|
553
|
+
type: Input
|
|
554
|
+
}], fields: [{
|
|
555
|
+
type: Input
|
|
556
|
+
}], valueField: [{
|
|
557
|
+
type: Input
|
|
558
|
+
}], nameField: [{
|
|
559
|
+
type: Input
|
|
560
|
+
}] } });
|
|
561
|
+
|
|
562
|
+
class ModelFormSubComponent {
|
|
563
|
+
constructor() {
|
|
564
|
+
this.config = {};
|
|
565
|
+
this.keys = [];
|
|
566
|
+
}
|
|
567
|
+
ngOnInit() {
|
|
568
|
+
this.keys = Object.keys(this.fields);
|
|
569
|
+
}
|
|
570
|
+
/**
|
|
571
|
+
* It takes a string, capitalizes the first letter, and returns the new string
|
|
572
|
+
*
|
|
573
|
+
* @param value - The string that you want to capitalize the first letter of.
|
|
574
|
+
* @returns The first letter of the string is being capitalized and the rest of the string is being returned.
|
|
575
|
+
*/
|
|
576
|
+
capitalizeFirstLetter(value) {
|
|
577
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
578
|
+
}
|
|
579
|
+
/**
|
|
580
|
+
* It takes an AbstractControl and returns a FormControl
|
|
581
|
+
*
|
|
582
|
+
* @param control - AbstractControl | null | undefined
|
|
583
|
+
* @returns A FormControl
|
|
584
|
+
*/
|
|
585
|
+
transformToControl(control) {
|
|
586
|
+
return control;
|
|
587
|
+
}
|
|
588
|
+
}
|
|
589
|
+
ModelFormSubComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ModelFormSubComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
590
|
+
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"] }] });
|
|
591
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ModelFormSubComponent, decorators: [{
|
|
592
|
+
type: Component,
|
|
593
|
+
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: [""] }]
|
|
594
|
+
}], propDecorators: { fields: [{
|
|
595
|
+
type: Input
|
|
596
|
+
}], form: [{
|
|
597
|
+
type: Input
|
|
598
|
+
}], config: [{
|
|
599
|
+
type: Input
|
|
600
|
+
}] } });
|
|
601
|
+
|
|
372
602
|
class ModelFormComponent {
|
|
373
603
|
constructor(graphQLMetaService, graphQLService, formsService) {
|
|
374
604
|
this.graphQLMetaService = graphQLMetaService;
|
|
@@ -376,6 +606,7 @@ class ModelFormComponent {
|
|
|
376
606
|
this.formsService = formsService;
|
|
377
607
|
this.delete = true;
|
|
378
608
|
this.logging = false;
|
|
609
|
+
this.config = {};
|
|
379
610
|
this.finished = new EventEmitter();
|
|
380
611
|
this.loading = false;
|
|
381
612
|
this.keys = [];
|
|
@@ -409,12 +640,15 @@ class ModelFormComponent {
|
|
|
409
640
|
console.log('ModelFormComponent::init->fields', this.fields);
|
|
410
641
|
console.log('ModelFormComponent::init->keys', this.keys);
|
|
411
642
|
}
|
|
412
|
-
this.createForm(this.fields);
|
|
643
|
+
this.form = this.createForm(this.fields);
|
|
413
644
|
if (this.id) {
|
|
414
645
|
this.getObjectById(this.id);
|
|
415
646
|
}
|
|
416
647
|
}
|
|
417
648
|
}
|
|
649
|
+
getKeysFromSubObject(key) {
|
|
650
|
+
return Object.keys(this.fields[key]);
|
|
651
|
+
}
|
|
418
652
|
/**
|
|
419
653
|
* It takes an id, and then calls the graphQLService to get the object from the database
|
|
420
654
|
*
|
|
@@ -423,11 +657,12 @@ class ModelFormComponent {
|
|
|
423
657
|
getObjectById(id) {
|
|
424
658
|
if (this.logging) {
|
|
425
659
|
console.log('ModelFormComponent::getObjectById->id', id);
|
|
660
|
+
console.log('ModelFormComponent::getObjectById->requestFields', this.createRequestObject(this.fields));
|
|
426
661
|
}
|
|
427
662
|
this.graphQLService
|
|
428
663
|
.graphQl('get' + this.capitalizeFirstLetter(this.modelName), {
|
|
429
664
|
arguments: { id },
|
|
430
|
-
fields: this.
|
|
665
|
+
fields: this.createRequestObject(this.fields),
|
|
431
666
|
type: GraphQLRequestType.QUERY,
|
|
432
667
|
})
|
|
433
668
|
.subscribe({
|
|
@@ -443,6 +678,28 @@ class ModelFormComponent {
|
|
|
443
678
|
},
|
|
444
679
|
});
|
|
445
680
|
}
|
|
681
|
+
/**
|
|
682
|
+
* It takes a GraphQL type collection and returns an array of strings and objects
|
|
683
|
+
*
|
|
684
|
+
* @param fields - IGraphQLTypeCollection - This is the object that is returned from the
|
|
685
|
+
* introspection query.
|
|
686
|
+
* @returns An array of strings and objects.
|
|
687
|
+
*/
|
|
688
|
+
createRequestObject(fields) {
|
|
689
|
+
const requestFields = [];
|
|
690
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
691
|
+
if (fields[key]?.type) {
|
|
692
|
+
requestFields.push(key);
|
|
693
|
+
}
|
|
694
|
+
else {
|
|
695
|
+
const subkeys = this.createRequestObject(fields[key]);
|
|
696
|
+
const resultObject = {};
|
|
697
|
+
resultObject[key] = subkeys;
|
|
698
|
+
requestFields.push(resultObject);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
return requestFields;
|
|
702
|
+
}
|
|
446
703
|
/**
|
|
447
704
|
* It takes a collection of GraphQL types and creates a form group with a form control for each type
|
|
448
705
|
*
|
|
@@ -452,10 +709,13 @@ class ModelFormComponent {
|
|
|
452
709
|
const group = {};
|
|
453
710
|
for (const [key, value] of Object.entries(fields)) {
|
|
454
711
|
if (fields[key]?.type) {
|
|
455
|
-
group[key] = new FormControl('', value.isRequired ? Validators.required : []);
|
|
712
|
+
group[key] = new FormControl(fields[key]?.type === 'Float' ? 0 : '', value.isRequired ? Validators.required : []);
|
|
713
|
+
}
|
|
714
|
+
else {
|
|
715
|
+
group[key] = this.createForm(fields[key]);
|
|
456
716
|
}
|
|
457
717
|
}
|
|
458
|
-
|
|
718
|
+
return new FormGroup(group);
|
|
459
719
|
}
|
|
460
720
|
/**
|
|
461
721
|
* It calls the graphQLService to delete the object with the id of the object that is currently being edited
|
|
@@ -513,6 +773,9 @@ class ModelFormComponent {
|
|
|
513
773
|
this.loading = false;
|
|
514
774
|
return;
|
|
515
775
|
}
|
|
776
|
+
if (this.logging) {
|
|
777
|
+
console.log('ModelFormComponent::submit->formValue', this.form.value);
|
|
778
|
+
}
|
|
516
779
|
this.graphQLService
|
|
517
780
|
.graphQl(this.operation + this.capitalizeFirstLetter(this.modelName), {
|
|
518
781
|
arguments: this.operation === 'update' ? { id: this.id, input: this.form.value } : { input: this.form.value },
|
|
@@ -532,18 +795,22 @@ class ModelFormComponent {
|
|
|
532
795
|
}
|
|
533
796
|
}
|
|
534
797
|
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 });
|
|
535
|
-
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 <
|
|
798
|
+
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"] }] });
|
|
536
799
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ModelFormComponent, decorators: [{
|
|
537
800
|
type: Component,
|
|
538
|
-
args: [{ selector: 'base-model-form', template: "<div class=\"w-100\" *ngIf=\"form\">\n <
|
|
801
|
+
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: [""] }]
|
|
539
802
|
}], ctorParameters: function () { return [{ type: i1$1.GraphQLMetaService }, { type: i1$1.GraphQLService }, { type: i1$1.FormsService }]; }, propDecorators: { modelName: [{
|
|
540
803
|
type: Input
|
|
804
|
+
}], label: [{
|
|
805
|
+
type: Input
|
|
541
806
|
}], id: [{
|
|
542
807
|
type: Input
|
|
543
808
|
}], delete: [{
|
|
544
809
|
type: Input
|
|
545
810
|
}], logging: [{
|
|
546
811
|
type: Input
|
|
812
|
+
}], config: [{
|
|
813
|
+
type: Input
|
|
547
814
|
}], finished: [{
|
|
548
815
|
type: Output
|
|
549
816
|
}] } });
|
|
@@ -556,10 +823,11 @@ class ModelTableComponent {
|
|
|
556
823
|
this.create = true;
|
|
557
824
|
this.update = true;
|
|
558
825
|
this.delete = true;
|
|
559
|
-
this.
|
|
560
|
-
this.
|
|
826
|
+
this.config = {};
|
|
827
|
+
this.fieldConfig = {};
|
|
561
828
|
this.idSelected = new EventEmitter();
|
|
562
829
|
this.createModeChanged = new EventEmitter();
|
|
830
|
+
this.tableFields = ['id', 'name', 'title', 'description', 'email', 'createdAt', 'updatedAt'];
|
|
563
831
|
this.objects = [];
|
|
564
832
|
this.availableFields = [];
|
|
565
833
|
this.selectedId = '';
|
|
@@ -581,7 +849,7 @@ class ModelTableComponent {
|
|
|
581
849
|
}
|
|
582
850
|
if (changes['objectId'] && this.meta) {
|
|
583
851
|
if (this.selectedId !== this.objectId) {
|
|
584
|
-
if (this.logging) {
|
|
852
|
+
if (this.config?.logging) {
|
|
585
853
|
console.log('ModelTableComponent::ngOnChanges->selectedId', this.selectedId);
|
|
586
854
|
}
|
|
587
855
|
this.selectedId = this.objectId;
|
|
@@ -594,6 +862,9 @@ class ModelTableComponent {
|
|
|
594
862
|
*/
|
|
595
863
|
init() {
|
|
596
864
|
this.availableFields = [];
|
|
865
|
+
if (this.config?.tableFields) {
|
|
866
|
+
this.tableFields = this.config.tableFields;
|
|
867
|
+
}
|
|
597
868
|
const possibleFields = this.meta.getFields('find' + this.capitalizeFirstLetter(this.modelName) + 's');
|
|
598
869
|
const keys = Object.keys(possibleFields);
|
|
599
870
|
this.tableFields?.forEach((field) => {
|
|
@@ -601,7 +872,7 @@ class ModelTableComponent {
|
|
|
601
872
|
this.availableFields.push(field);
|
|
602
873
|
}
|
|
603
874
|
});
|
|
604
|
-
if (this.logging) {
|
|
875
|
+
if (this.config?.logging) {
|
|
605
876
|
console.log('ModelTableComponent::init->possibleFields', possibleFields);
|
|
606
877
|
console.log('ModelTableComponent::init->keys', keys);
|
|
607
878
|
console.log('ModelTableComponent::init->availableFields', this.availableFields);
|
|
@@ -630,7 +901,7 @@ class ModelTableComponent {
|
|
|
630
901
|
})
|
|
631
902
|
.subscribe({
|
|
632
903
|
next: (value) => {
|
|
633
|
-
if (this.logging) {
|
|
904
|
+
if (this.config?.logging) {
|
|
634
905
|
console.log('ModelTableComponent::loadObjects->value', value);
|
|
635
906
|
}
|
|
636
907
|
this.objects = value;
|
|
@@ -667,10 +938,10 @@ class ModelTableComponent {
|
|
|
667
938
|
}
|
|
668
939
|
}
|
|
669
940
|
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 });
|
|
670
|
-
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",
|
|
941
|
+
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"] }] });
|
|
671
942
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ModelTableComponent, decorators: [{
|
|
672
943
|
type: Component,
|
|
673
|
-
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 <
|
|
944
|
+
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"] }]
|
|
674
945
|
}], ctorParameters: function () { return [{ type: i1$1.GraphQLMetaService }, { type: i1$1.GraphQLService }]; }, propDecorators: { modelName: [{
|
|
675
946
|
type: Input
|
|
676
947
|
}], objectId: [{
|
|
@@ -683,9 +954,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImpor
|
|
|
683
954
|
type: Input
|
|
684
955
|
}], delete: [{
|
|
685
956
|
type: Input
|
|
686
|
-
}],
|
|
957
|
+
}], config: [{
|
|
687
958
|
type: Input
|
|
688
|
-
}],
|
|
959
|
+
}], fieldConfig: [{
|
|
689
960
|
type: Input
|
|
690
961
|
}], idSelected: [{
|
|
691
962
|
type: Output
|
|
@@ -709,6 +980,9 @@ const elements = [
|
|
|
709
980
|
BreadcrumbComponent,
|
|
710
981
|
ModelFormComponent,
|
|
711
982
|
ModelTableComponent,
|
|
983
|
+
ModelFormSubComponent,
|
|
984
|
+
UploadImageComponent,
|
|
985
|
+
RefenceInputComponent,
|
|
712
986
|
];
|
|
713
987
|
class BaseComponentsModule {
|
|
714
988
|
}
|
|
@@ -725,7 +999,10 @@ BaseComponentsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", ve
|
|
|
725
999
|
SkeletonLoaderComponent,
|
|
726
1000
|
BreadcrumbComponent,
|
|
727
1001
|
ModelFormComponent,
|
|
728
|
-
ModelTableComponent
|
|
1002
|
+
ModelTableComponent,
|
|
1003
|
+
ModelFormSubComponent,
|
|
1004
|
+
UploadImageComponent,
|
|
1005
|
+
RefenceInputComponent], imports: [FormsModule, ReactiveFormsModule, CommonModule], exports: [
|
|
729
1006
|
// Components
|
|
730
1007
|
InputComponent,
|
|
731
1008
|
SelectComponent,
|
|
@@ -737,7 +1014,10 @@ BaseComponentsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", ve
|
|
|
737
1014
|
SkeletonLoaderComponent,
|
|
738
1015
|
BreadcrumbComponent,
|
|
739
1016
|
ModelFormComponent,
|
|
740
|
-
ModelTableComponent
|
|
1017
|
+
ModelTableComponent,
|
|
1018
|
+
ModelFormSubComponent,
|
|
1019
|
+
UploadImageComponent,
|
|
1020
|
+
RefenceInputComponent] });
|
|
741
1021
|
BaseComponentsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: BaseComponentsModule, imports: [imports] });
|
|
742
1022
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: BaseComponentsModule, decorators: [{
|
|
743
1023
|
type: NgModule,
|
|
@@ -756,5 +1036,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImpor
|
|
|
756
1036
|
* Generated bundle index. Do not edit.
|
|
757
1037
|
*/
|
|
758
1038
|
|
|
759
|
-
export { BaseComponentsModule, BreadcrumbComponent, CheckboxComponent, InputComponent, LoadingBarComponent, ModelFormComponent, ModelTableComponent, SelectComponent, SkeletonLoaderComponent, TagsComponent, TextareaComponent, ToastComponent };
|
|
1039
|
+
export { BaseComponentsModule, BreadcrumbComponent, CheckboxComponent, InputComponent, LoadingBarComponent, ModelFormComponent, ModelFormSubComponent, ModelTableComponent, RefenceInputComponent, SelectComponent, SkeletonLoaderComponent, TagsComponent, TextareaComponent, ToastComponent, UploadImageComponent };
|
|
760
1040
|
//# sourceMappingURL=lenne.tech-ng-base-base-components.mjs.map
|