@lenne.tech/ng-base 14.18.1 → 14.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-components/base-components.module.d.ts +23 -22
- package/base-components/components/model-form/model-form.component.d.ts +1 -0
- package/base-components/components/upload-image/upload-image.component.d.ts +5 -0
- package/base-components/directives/stop-propagation.directive.d.ts +10 -0
- package/base-components/public-api.d.ts +1 -0
- package/esm2020/base-components/base-components.module.mjs +5 -1
- package/esm2020/base-components/components/model-form/model-form.component.mjs +17 -2
- package/esm2020/base-components/components/upload-image/upload-image.component.mjs +34 -13
- package/esm2020/base-components/directives/stop-propagation.directive.mjs +23 -0
- package/esm2020/base-components/public-api.mjs +2 -1
- package/esm2020/public-api.mjs +3 -1
- package/esm2020/shared/services/graphql.service.mjs +6 -6
- package/esm2020/src/decorators/auto-unsubscribe.decorator.mjs +23 -0
- package/fesm2015/lenne.tech-ng-base-base-components.mjs +84 -25
- package/fesm2015/lenne.tech-ng-base-base-components.mjs.map +1 -1
- package/fesm2015/lenne.tech-ng-base-shared.mjs +5 -5
- package/fesm2015/lenne.tech-ng-base-shared.mjs.map +1 -1
- package/fesm2015/lenne.tech-ng-base.mjs +24 -1
- package/fesm2015/lenne.tech-ng-base.mjs.map +1 -1
- package/fesm2020/lenne.tech-ng-base-base-components.mjs +73 -14
- package/fesm2020/lenne.tech-ng-base-base-components.mjs.map +1 -1
- package/fesm2020/lenne.tech-ng-base-shared.mjs +5 -5
- package/fesm2020/lenne.tech-ng-base-shared.mjs.map +1 -1
- package/fesm2020/lenne.tech-ng-base.mjs +24 -1
- package/fesm2020/lenne.tech-ng-base.mjs.map +1 -1
- package/package.json +1 -1
- package/public-api.d.ts +1 -0
- package/src/decorators/auto-unsubscribe.decorator.d.ts +5 -0
|
@@ -665,6 +665,27 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImpor
|
|
|
665
665
|
type: Output
|
|
666
666
|
}] } });
|
|
667
667
|
|
|
668
|
+
/**
|
|
669
|
+
* Stops propagation of click events
|
|
670
|
+
* Inspired by https://stackoverflow.com/a/41001184
|
|
671
|
+
*/
|
|
672
|
+
class StopPropagationDirective {
|
|
673
|
+
onClick(event) {
|
|
674
|
+
event.stopPropagation();
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
StopPropagationDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: StopPropagationDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
|
|
678
|
+
StopPropagationDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0", type: StopPropagationDirective, selector: "[baseStopPropagation]", host: { listeners: { "click": "onClick($event)" } }, ngImport: i0 });
|
|
679
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: StopPropagationDirective, decorators: [{
|
|
680
|
+
type: Directive,
|
|
681
|
+
args: [{
|
|
682
|
+
selector: '[baseStopPropagation]',
|
|
683
|
+
}]
|
|
684
|
+
}], propDecorators: { onClick: [{
|
|
685
|
+
type: HostListener,
|
|
686
|
+
args: ['click', ['$event']]
|
|
687
|
+
}] } });
|
|
688
|
+
|
|
668
689
|
class UploadImageComponent {
|
|
669
690
|
constructor(httpClient, authService, fileService, toastService) {
|
|
670
691
|
this.httpClient = httpClient;
|
|
@@ -743,7 +764,7 @@ class UploadImageComponent {
|
|
|
743
764
|
}, 3500);
|
|
744
765
|
return;
|
|
745
766
|
}
|
|
746
|
-
if (this.validExtensions.includes(file.type)) {
|
|
767
|
+
if (this.validExtensions.includes(file === null || file === void 0 ? void 0 : file.type)) {
|
|
747
768
|
const fileReader = new FileReader();
|
|
748
769
|
fileReader.onload = (result) => {
|
|
749
770
|
this.loading = true;
|
|
@@ -777,18 +798,17 @@ class UploadImageComponent {
|
|
|
777
798
|
upload() {
|
|
778
799
|
return __awaiter(this, void 0, void 0, function* () {
|
|
779
800
|
let result;
|
|
801
|
+
const fileData = { field: this.id, file: this.selectedFile, base64: yield this.getBase64(this.selectedFile) };
|
|
802
|
+
this.fileChanged.emit(fileData);
|
|
780
803
|
if (this.uploadDirectly) {
|
|
781
804
|
result = yield this.fileService.upload(this.url, this.uploadPath, this.selectedFile, this.compressOptions);
|
|
805
|
+
if (result === null || result === void 0 ? void 0 : result.id) {
|
|
806
|
+
this.control.setValue(result.id);
|
|
807
|
+
this.imageUploaded.emit(result.id);
|
|
808
|
+
}
|
|
782
809
|
}
|
|
783
810
|
else {
|
|
784
|
-
this.control.
|
|
785
|
-
this.fileChanged.emit({ field: this.id, file: this.selectedFile });
|
|
786
|
-
this.loading = false;
|
|
787
|
-
return;
|
|
788
|
-
}
|
|
789
|
-
if (result === null || result === void 0 ? void 0 : result.id) {
|
|
790
|
-
this.control.setValue(result.id);
|
|
791
|
-
this.imageUploaded.emit(result.id);
|
|
811
|
+
this.control.setValue(fileData.base64);
|
|
792
812
|
}
|
|
793
813
|
this.control.markAsTouched();
|
|
794
814
|
this.loading = false;
|
|
@@ -806,7 +826,7 @@ class UploadImageComponent {
|
|
|
806
826
|
this.fileUrl = null;
|
|
807
827
|
this.control.setValue('');
|
|
808
828
|
this.control.markAsTouched();
|
|
809
|
-
this.fileChanged.emit({ field: this.id, file: null });
|
|
829
|
+
this.fileChanged.emit({ field: this.id, file: null, base64: null });
|
|
810
830
|
return;
|
|
811
831
|
}
|
|
812
832
|
this.loading = true;
|
|
@@ -824,12 +844,33 @@ class UploadImageComponent {
|
|
|
824
844
|
}
|
|
825
845
|
});
|
|
826
846
|
}
|
|
847
|
+
/**
|
|
848
|
+
* Convert a file into a BASE64 encoded string
|
|
849
|
+
*/
|
|
850
|
+
getBase64(file) {
|
|
851
|
+
return new Promise((resolve, reject) => {
|
|
852
|
+
if (!file) {
|
|
853
|
+
return resolve(null);
|
|
854
|
+
}
|
|
855
|
+
const reader = new FileReader();
|
|
856
|
+
reader.readAsDataURL(file);
|
|
857
|
+
reader.onload = () => {
|
|
858
|
+
if (!reader.result) {
|
|
859
|
+
return reject(new Error('Conversion failed'));
|
|
860
|
+
}
|
|
861
|
+
resolve(reader.result.toString());
|
|
862
|
+
};
|
|
863
|
+
reader.onerror = (error) => {
|
|
864
|
+
reject(error);
|
|
865
|
+
};
|
|
866
|
+
});
|
|
867
|
+
}
|
|
827
868
|
}
|
|
828
869
|
UploadImageComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: UploadImageComponent, deps: [{ token: i1$2.HttpClient }, { token: i1$1.AuthService }, { token: i1$1.FileService }, { token: i1$1.ToastService }], target: i0.ɵɵFactoryTarget.Component });
|
|
829
|
-
UploadImageComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.0", type: UploadImageComponent, selector: "base-upload-image", inputs: { id: "id", name: "name", label: "label", supportText: "supportText", required: "required", defaultDragText: "defaultDragText", defaultReleaseText: "defaultReleaseText", preButtonText: "preButtonText", buttonText: "buttonText", validExtensions: "validExtensions", control: "control", url: "url", uploadPath: "uploadPath", deletePath: "deletePath", path: "path", compressOptions: "compressOptions", maxSize: "maxSize", uploadDirectly: "uploadDirectly" }, outputs: { imageUploaded: "imageUploaded", imageDeleted: "imageDeleted", fileChanged: "fileChanged" }, ngImport: i0, template: "<div class=\"form-group 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 <div class=\"d-flex justify-content-center\" *ngIf=\"loading\">\n <div class=\"spinner-border text-primary\" role=\"status\">\n <span class=\"visually-hidden\">Loading...</span>\n </div>\n </div>\n\n <ng-container *ngIf=\"selectedFile && !loading\">\n <img [src]=\"fileUrl\" *ngIf=\"selectedFile\" />\n <button class=\"btn btn-danger\" type=\"button\" (click)=\"deleteFile()\">L\u00F6schen</button>\n </ng-container>\n\n <ng-container *ngIf=\"control?.value && !selectedFile && !loading\">\n <img [src]=\"url + path + control?.value\" />\n <button class=\"btn btn-danger\" type=\"button\" (click)=\"deleteFile(control?.value)\"
|
|
870
|
+
UploadImageComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.0", type: UploadImageComponent, selector: "base-upload-image", inputs: { id: "id", name: "name", label: "label", supportText: "supportText", required: "required", defaultDragText: "defaultDragText", defaultReleaseText: "defaultReleaseText", preButtonText: "preButtonText", buttonText: "buttonText", validExtensions: "validExtensions", control: "control", url: "url", uploadPath: "uploadPath", deletePath: "deletePath", path: "path", compressOptions: "compressOptions", maxSize: "maxSize", uploadDirectly: "uploadDirectly" }, outputs: { imageUploaded: "imageUploaded", imageDeleted: "imageDeleted", fileChanged: "fileChanged" }, ngImport: i0, template: "<div class=\"form-group 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, pointer: !loading }\"\n (click)=\"!loading && fileInput.click()\"\n >\n <div class=\"d-flex justify-content-center\" *ngIf=\"loading\">\n <div class=\"spinner-border text-primary\" role=\"status\">\n <span class=\"visually-hidden\">Loading...</span>\n </div>\n </div>\n\n <ng-container *ngIf=\"selectedFile && !loading\">\n <img [src]=\"fileUrl\" *ngIf=\"selectedFile\" />\n <button class=\"btn btn-danger\" type=\"button\" (click)=\"deleteFile()\" baseStopPropagation>L\u00F6schen</button>\n </ng-container>\n\n <ng-container *ngIf=\"control?.value && !selectedFile && !loading\">\n <img [src]=\"control?.value.startsWith('data:') ? control?.value : url + path + control?.value\" />\n <button class=\"btn btn-danger\" type=\"button\" (click)=\"deleteFile(control?.value)\" baseStopPropagation>\n L\u00F6schen\n </button>\n </ng-container>\n\n <ng-container *ngIf=\"!selectedFile && !control?.value && !loading\">\n <div class=\"icon\">\n <i class=\"bi bi-images\"></i>\n </div>\n\n <span class=\"header\">{{ dragText }}</span>\n <span class=\"header\"\n >{{ preButtonText }}\n <span class=\"button\" (click)=\"fileInput.click()\" baseStopPropagation>{{ buttonText }}</span></span\n >\n <span class=\"support\" [innerText]=\"supportText\"></span>\n </ng-container>\n\n <input type=\"file\" (change)=\"selectFile($event)\" [attr.accept]=\"validExtensions?.join(',')\" hidden #fileInput />\n </div>\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>\n</div>\n", styles: [":host{--base-upload-image-area-bg: #ffffff;--base-upload-image-area-border-color: #e1e1e1;--base-upload-image-area-height: 400px}.required:after{content:\" *\"}.drag-area{height:var(--base-upload-image-area-height);border:2px dashed var(--base-upload-image-area-border-color);background-color:var(--base-upload-image-area-bg);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%;object-fit:scale-down}.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)}.pointer{cursor:pointer}\n"], dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: StopPropagationDirective, selector: "[baseStopPropagation]" }] });
|
|
830
871
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: UploadImageComponent, decorators: [{
|
|
831
872
|
type: Component,
|
|
832
|
-
args: [{ selector: 'base-upload-image', template: "<div class=\"form-group 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 <div class=\"d-flex justify-content-center\" *ngIf=\"loading\">\n <div class=\"spinner-border text-primary\" role=\"status\">\n <span class=\"visually-hidden\">Loading...</span>\n </div>\n </div>\n\n <ng-container *ngIf=\"selectedFile && !loading\">\n <img [src]=\"fileUrl\" *ngIf=\"selectedFile\" />\n <button class=\"btn btn-danger\" type=\"button\" (click)=\"deleteFile()\">L\u00F6schen</button>\n </ng-container>\n\n <ng-container *ngIf=\"control?.value && !selectedFile && !loading\">\n <img [src]=\"url + path + control?.value\" />\n <button class=\"btn btn-danger\" type=\"button\" (click)=\"deleteFile(control?.value)\"
|
|
873
|
+
args: [{ selector: 'base-upload-image', template: "<div class=\"form-group 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, pointer: !loading }\"\n (click)=\"!loading && fileInput.click()\"\n >\n <div class=\"d-flex justify-content-center\" *ngIf=\"loading\">\n <div class=\"spinner-border text-primary\" role=\"status\">\n <span class=\"visually-hidden\">Loading...</span>\n </div>\n </div>\n\n <ng-container *ngIf=\"selectedFile && !loading\">\n <img [src]=\"fileUrl\" *ngIf=\"selectedFile\" />\n <button class=\"btn btn-danger\" type=\"button\" (click)=\"deleteFile()\" baseStopPropagation>L\u00F6schen</button>\n </ng-container>\n\n <ng-container *ngIf=\"control?.value && !selectedFile && !loading\">\n <img [src]=\"control?.value.startsWith('data:') ? control?.value : url + path + control?.value\" />\n <button class=\"btn btn-danger\" type=\"button\" (click)=\"deleteFile(control?.value)\" baseStopPropagation>\n L\u00F6schen\n </button>\n </ng-container>\n\n <ng-container *ngIf=\"!selectedFile && !control?.value && !loading\">\n <div class=\"icon\">\n <i class=\"bi bi-images\"></i>\n </div>\n\n <span class=\"header\">{{ dragText }}</span>\n <span class=\"header\"\n >{{ preButtonText }}\n <span class=\"button\" (click)=\"fileInput.click()\" baseStopPropagation>{{ buttonText }}</span></span\n >\n <span class=\"support\" [innerText]=\"supportText\"></span>\n </ng-container>\n\n <input type=\"file\" (change)=\"selectFile($event)\" [attr.accept]=\"validExtensions?.join(',')\" hidden #fileInput />\n </div>\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>\n</div>\n", styles: [":host{--base-upload-image-area-bg: #ffffff;--base-upload-image-area-border-color: #e1e1e1;--base-upload-image-area-height: 400px}.required:after{content:\" *\"}.drag-area{height:var(--base-upload-image-area-height);border:2px dashed var(--base-upload-image-area-border-color);background-color:var(--base-upload-image-area-bg);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%;object-fit:scale-down}.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)}.pointer{cursor:pointer}\n"] }]
|
|
833
874
|
}], ctorParameters: function () { return [{ type: i1$2.HttpClient }, { type: i1$1.AuthService }, { type: i1$1.FileService }, { type: i1$1.ToastService }]; }, propDecorators: { id: [{
|
|
834
875
|
type: Input
|
|
835
876
|
}], name: [{
|
|
@@ -1325,28 +1366,31 @@ class ModelFormComponent {
|
|
|
1325
1366
|
})
|
|
1326
1367
|
.subscribe({
|
|
1327
1368
|
next: (response) => {
|
|
1328
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1369
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1329
1370
|
if (this.logging) {
|
|
1330
1371
|
console.log('ModelFormComponent::get->value', response);
|
|
1331
1372
|
}
|
|
1332
1373
|
this.object = response;
|
|
1333
1374
|
this.form.patchValue(Object.assign({}, response));
|
|
1334
1375
|
// Process patchFields for reference input
|
|
1335
|
-
for (const [key, value] of Object.entries(this.
|
|
1376
|
+
for (const [key, value] of Object.entries(this.fields)) {
|
|
1377
|
+
if (((_a = this.fields[key]) === null || _a === void 0 ? void 0 : _a.type) === 'DateTime' || ((_b = this.config[key]) === null || _b === void 0 ? void 0 : _b.type) === 'DateTime') {
|
|
1378
|
+
this.form.get(key).patchValue(this.formatDate(response[key]));
|
|
1379
|
+
}
|
|
1336
1380
|
// If it not an array
|
|
1337
|
-
if (((
|
|
1381
|
+
if (((_c = this.config[key]) === null || _c === void 0 ? void 0 : _c.type) === 'Reference' && !((_d = this.fields[key]) === null || _d === void 0 ? void 0 : _d.isList)) {
|
|
1338
1382
|
if (this.form.get(key)) {
|
|
1339
1383
|
this.form
|
|
1340
1384
|
.get(key)
|
|
1341
|
-
.patchValue((
|
|
1385
|
+
.patchValue((_g = response[((_e = this.config[key]) === null || _e === void 0 ? void 0 : _e.patchField) ? (_f = this.config[key]) === null || _f === void 0 ? void 0 : _f.patchField : key]) === null || _g === void 0 ? void 0 : _g.id);
|
|
1342
1386
|
}
|
|
1343
1387
|
}
|
|
1344
1388
|
// If value is an array
|
|
1345
|
-
if (((
|
|
1389
|
+
if (((_h = this.config[key]) === null || _h === void 0 ? void 0 : _h.type) === 'Reference' && ((_j = this.fields[key]) === null || _j === void 0 ? void 0 : _j.isList)) {
|
|
1346
1390
|
if (this.form.get(key)) {
|
|
1347
1391
|
this.form
|
|
1348
1392
|
.get(key)
|
|
1349
|
-
.patchValue((
|
|
1393
|
+
.patchValue((_m = response[((_k = this.config[key]) === null || _k === void 0 ? void 0 : _k.patchField) ? (_l = this.config[key]) === null || _l === void 0 ? void 0 : _l.patchField : key]) === null || _m === void 0 ? void 0 : _m.map((e) => e === null || e === void 0 ? void 0 : e.id));
|
|
1350
1394
|
}
|
|
1351
1395
|
}
|
|
1352
1396
|
}
|
|
@@ -1627,19 +1671,24 @@ class ModelFormComponent {
|
|
|
1627
1671
|
* Prepare data for server
|
|
1628
1672
|
*/
|
|
1629
1673
|
prepareDataForRequest(config, fieldsConfig, data) {
|
|
1630
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1674
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1631
1675
|
if (!data) {
|
|
1632
1676
|
return data;
|
|
1633
1677
|
}
|
|
1634
1678
|
for (const [key, value] of Object.entries(data)) {
|
|
1635
|
-
if ((((_a =
|
|
1679
|
+
if ((((_a = this.fields[key]) === null || _a === void 0 ? void 0 : _a.type) === 'DateTime' || ((_b = this.config[key]) === null || _b === void 0 ? void 0 : _b.type) === 'DateTime') && value === '') {
|
|
1680
|
+
data[key] = null;
|
|
1681
|
+
continue;
|
|
1682
|
+
}
|
|
1683
|
+
if ((((_c = config[key]) === null || _c === void 0 ? void 0 : _c.roles) ? !this.user.hasAllRoles((_d = config[key]) === null || _d === void 0 ? void 0 : _d.roles) : false) || ((_e = config[key]) === null || _e === void 0 ? void 0 : _e.exclude)) {
|
|
1636
1684
|
delete data[key];
|
|
1685
|
+
continue;
|
|
1637
1686
|
}
|
|
1638
1687
|
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
1639
1688
|
data[key] = Object.keys(data[key])
|
|
1640
1689
|
.filter((k) => data[key][k] != null)
|
|
1641
1690
|
.reduce((a, k) => (Object.assign(Object.assign({}, a), { [k]: data[key][k] })), {});
|
|
1642
|
-
if (((
|
|
1691
|
+
if (((_f = Object.keys(data[key])) === null || _f === void 0 ? void 0 : _f.length) === 0) {
|
|
1643
1692
|
if (this.logging) {
|
|
1644
1693
|
console.log('Object is empty from result');
|
|
1645
1694
|
}
|
|
@@ -1647,7 +1696,7 @@ class ModelFormComponent {
|
|
|
1647
1696
|
}
|
|
1648
1697
|
}
|
|
1649
1698
|
// Set type for graphql method
|
|
1650
|
-
if (((
|
|
1699
|
+
if (((_g = fieldsConfig[key]) === null || _g === void 0 ? void 0 : _g.type) === 'Float') {
|
|
1651
1700
|
if (value) {
|
|
1652
1701
|
data[key] = Number(value);
|
|
1653
1702
|
}
|
|
@@ -1655,8 +1704,8 @@ class ModelFormComponent {
|
|
|
1655
1704
|
data[key] = null;
|
|
1656
1705
|
}
|
|
1657
1706
|
}
|
|
1658
|
-
if (((
|
|
1659
|
-
data[key] = this.prepareDataForRequest((
|
|
1707
|
+
if (((_h = fieldsConfig[key]) === null || _h === void 0 ? void 0 : _h.fields) && Object.keys((_j = fieldsConfig[key]) === null || _j === void 0 ? void 0 : _j.fields).length > 0) {
|
|
1708
|
+
data[key] = this.prepareDataForRequest((_k = config[key]) === null || _k === void 0 ? void 0 : _k.fields, (_l = fieldsConfig[key]) === null || _l === void 0 ? void 0 : _l.fields, data[key]);
|
|
1660
1709
|
}
|
|
1661
1710
|
}
|
|
1662
1711
|
return data;
|
|
@@ -1695,6 +1744,13 @@ class ModelFormComponent {
|
|
|
1695
1744
|
this.fileChanges = [event];
|
|
1696
1745
|
}
|
|
1697
1746
|
}
|
|
1747
|
+
formatDate(date) {
|
|
1748
|
+
if (!date) {
|
|
1749
|
+
return null;
|
|
1750
|
+
}
|
|
1751
|
+
const newDate = new Date(date);
|
|
1752
|
+
return newDate.toISOString().substring(0, 16);
|
|
1753
|
+
}
|
|
1698
1754
|
}
|
|
1699
1755
|
ModelFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: ModelFormComponent, deps: [{ token: i1$1.GraphQLMetaService }, { token: i1$1.GraphQLService }, { token: i1$1.FormsService }, { token: i1$1.AuthService }, { token: i2$1.Router }, { token: i2$1.ActivatedRoute }, { token: i1$1.CmsService }, { token: i1$1.ToastService }, { token: i1$1.FileService }], target: i0.ɵɵFactoryTarget.Component });
|
|
1700
1756
|
ModelFormComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.1.0", type: ModelFormComponent, selector: "base-model-form", inputs: { modelName: "modelName", label: "label", id: "id", delete: "delete", onlyUpdateMode: "onlyUpdateMode", duplicate: "duplicate", logging: "logging", config: "config", showFavButton: "showFavButton" }, outputs: { finished: "finished" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"w-100\" *ngIf=\"form\">\n <div class=\"d-flex flex-row justify-content-between mt-3\">\n <div class=\"responsive-back d-flex d-lg-none\">\n <i class=\"bi bi-arrow-left\" routerLink=\"../\"></i>\n </div>\n <h2 class=\"mb-0\">\n {{ label ? label : capitalizeFirstLetter(modelName) }} {{ operation === 'update' ? 'bearbeiten' : 'erstellen' }}\n </h2>\n\n <div class=\"d-none d-lg-flex flex-row align-items-center justify-content-end\">\n <button class=\"btn btn-outline-primary me-2\" *ngIf=\"id && duplicate && !_loading\" (click)=\"duplicateObject()\">\n Duplizieren\n </button>\n <button\n class=\"btn btn-primary\"\n type=\"button\"\n [disabled]=\"!form.touched && !form.dirty\"\n (click)=\"submit(false)\"\n *ngIf=\"!_loading\"\n >\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\n <form [formGroup]=\"form\">\n <base-model-form-sub\n [id]=\"id\"\n [fields]=\"fields\"\n [config]=\"config\"\n [form]=\"form\"\n (imageChanged)=\"imageChanged($event)\"\n (fileChanged)=\"processFileChanges($event)\"\n ></base-model-form-sub>\n\n <div class=\"d-none d-lg-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\n class=\"btn btn-primary\"\n type=\"button\"\n [disabled]=\"!form.touched && !form.dirty\"\n (click)=\"submit(false)\"\n *ngIf=\"!_loading\"\n >\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\n<div class=\"d-block d-lg-none responsive-action-button\" *ngIf=\"showFavButton\">\n <base-fab-button [buttons]=\"fabButtons\"></base-fab-button>\n</div>\n", styles: [".responsive-back{display:flex;align-items:center;margin-right:6px}.responsive-back .bi-arrow-left{font-size:28px}h2{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.responsive-action-button{position:fixed;bottom:15px;right:15px;z-index:100}\n"], dependencies: [{ kind: "directive", type: i1.ɵNgNoValidate, selector: "form:not([ngNoForm]):not([ngNativeValidate])" }, { kind: "directive", type: i1.NgControlStatusGroup, selector: "[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]" }, { kind: "directive", type: i1.FormGroupDirective, selector: "[formGroup]", inputs: ["formGroup"], outputs: ["ngSubmit"], exportAs: ["ngForm"] }, { kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2$1.RouterLink, selector: ":not(a):not(area)[routerLink]", inputs: ["queryParams", "fragment", "queryParamsHandling", "preserveFragment", "skipLocationChange", "replaceUrl", "state", "relativeTo", "routerLink"] }, { kind: "component", type: ModelFormSubComponent, selector: "base-model-form-sub", inputs: ["id", "fields", "form", "config"], outputs: ["imageChanged", "fileChanged"] }, { kind: "component", type: FabButtonComponent, selector: "base-fab-button", inputs: ["fabIcon", "buttons"] }] });
|
|
@@ -2257,6 +2313,7 @@ const elements = [
|
|
|
2257
2313
|
SortDirective,
|
|
2258
2314
|
BackButtonDirective,
|
|
2259
2315
|
ContextMenuDirective,
|
|
2316
|
+
StopPropagationDirective,
|
|
2260
2317
|
// Components
|
|
2261
2318
|
InputComponent,
|
|
2262
2319
|
SelectComponent,
|
|
@@ -2286,6 +2343,7 @@ BaseComponentsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", ve
|
|
|
2286
2343
|
SortDirective,
|
|
2287
2344
|
BackButtonDirective,
|
|
2288
2345
|
ContextMenuDirective,
|
|
2346
|
+
StopPropagationDirective,
|
|
2289
2347
|
// Components
|
|
2290
2348
|
InputComponent,
|
|
2291
2349
|
SelectComponent,
|
|
@@ -2311,6 +2369,7 @@ BaseComponentsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", ve
|
|
|
2311
2369
|
SortDirective,
|
|
2312
2370
|
BackButtonDirective,
|
|
2313
2371
|
ContextMenuDirective,
|
|
2372
|
+
StopPropagationDirective,
|
|
2314
2373
|
// Components
|
|
2315
2374
|
InputComponent,
|
|
2316
2375
|
SelectComponent,
|
|
@@ -2350,5 +2409,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImpor
|
|
|
2350
2409
|
* Generated bundle index. Do not edit.
|
|
2351
2410
|
*/
|
|
2352
2411
|
|
|
2353
|
-
export { BackButtonDirective, BaseComponentsModule, BreadcrumbComponent, ChangePasswordComponent, CheckboxComponent, ContextMenuDirective, DeleteAccountComponent, EllipsesPipe, FabButtonComponent, InputComponent, LoadingBarComponent, ModelFormComponent, ModelFormSubComponent, ModelTableComponent, RefenceInputComponent, SelectComponent, SkeletonLoaderComponent, SortDirective, TagsComponent, TextareaComponent, ToastComponent, UploadImageComponent };
|
|
2412
|
+
export { BackButtonDirective, BaseComponentsModule, BreadcrumbComponent, ChangePasswordComponent, CheckboxComponent, ContextMenuDirective, DeleteAccountComponent, EllipsesPipe, FabButtonComponent, InputComponent, LoadingBarComponent, ModelFormComponent, ModelFormSubComponent, ModelTableComponent, RefenceInputComponent, SelectComponent, SkeletonLoaderComponent, SortDirective, StopPropagationDirective, TagsComponent, TextareaComponent, ToastComponent, UploadImageComponent };
|
|
2354
2413
|
//# sourceMappingURL=lenne.tech-ng-base-base-components.mjs.map
|