@lenne.tech/ng-base 14.18.0 → 14.19.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/components/model-form/model-form.component.d.ts +1 -0
- package/esm2020/base-components/components/model-form/model-form.component.mjs +17 -2
- package/esm2020/shared/services/graphql.service.mjs +6 -6
- package/fesm2015/lenne.tech-ng-base-base-components.mjs +27 -12
- 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/fesm2020/lenne.tech-ng-base-base-components.mjs +16 -1
- 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/package.json +1 -1
|
@@ -1325,28 +1325,31 @@ class ModelFormComponent {
|
|
|
1325
1325
|
})
|
|
1326
1326
|
.subscribe({
|
|
1327
1327
|
next: (response) => {
|
|
1328
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1328
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
1329
1329
|
if (this.logging) {
|
|
1330
1330
|
console.log('ModelFormComponent::get->value', response);
|
|
1331
1331
|
}
|
|
1332
1332
|
this.object = response;
|
|
1333
1333
|
this.form.patchValue(Object.assign({}, response));
|
|
1334
1334
|
// Process patchFields for reference input
|
|
1335
|
-
for (const [key, value] of Object.entries(this.
|
|
1335
|
+
for (const [key, value] of Object.entries(this.fields)) {
|
|
1336
|
+
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') {
|
|
1337
|
+
this.form.get(key).patchValue(this.formatDate(response[key]));
|
|
1338
|
+
}
|
|
1336
1339
|
// If it not an array
|
|
1337
|
-
if (((
|
|
1340
|
+
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
1341
|
if (this.form.get(key)) {
|
|
1339
1342
|
this.form
|
|
1340
1343
|
.get(key)
|
|
1341
|
-
.patchValue((
|
|
1344
|
+
.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
1345
|
}
|
|
1343
1346
|
}
|
|
1344
1347
|
// If value is an array
|
|
1345
|
-
if (((
|
|
1348
|
+
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
1349
|
if (this.form.get(key)) {
|
|
1347
1350
|
this.form
|
|
1348
1351
|
.get(key)
|
|
1349
|
-
.patchValue((
|
|
1352
|
+
.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
1353
|
}
|
|
1351
1354
|
}
|
|
1352
1355
|
}
|
|
@@ -1627,19 +1630,24 @@ class ModelFormComponent {
|
|
|
1627
1630
|
* Prepare data for server
|
|
1628
1631
|
*/
|
|
1629
1632
|
prepareDataForRequest(config, fieldsConfig, data) {
|
|
1630
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1633
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
1631
1634
|
if (!data) {
|
|
1632
1635
|
return data;
|
|
1633
1636
|
}
|
|
1634
1637
|
for (const [key, value] of Object.entries(data)) {
|
|
1635
|
-
if ((((_a =
|
|
1638
|
+
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 === '') {
|
|
1639
|
+
data[key] = null;
|
|
1640
|
+
continue;
|
|
1641
|
+
}
|
|
1642
|
+
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
1643
|
delete data[key];
|
|
1644
|
+
continue;
|
|
1637
1645
|
}
|
|
1638
1646
|
if (value && typeof value === 'object' && !Array.isArray(value)) {
|
|
1639
1647
|
data[key] = Object.keys(data[key])
|
|
1640
1648
|
.filter((k) => data[key][k] != null)
|
|
1641
1649
|
.reduce((a, k) => (Object.assign(Object.assign({}, a), { [k]: data[key][k] })), {});
|
|
1642
|
-
if (((
|
|
1650
|
+
if (((_f = Object.keys(data[key])) === null || _f === void 0 ? void 0 : _f.length) === 0) {
|
|
1643
1651
|
if (this.logging) {
|
|
1644
1652
|
console.log('Object is empty from result');
|
|
1645
1653
|
}
|
|
@@ -1647,7 +1655,7 @@ class ModelFormComponent {
|
|
|
1647
1655
|
}
|
|
1648
1656
|
}
|
|
1649
1657
|
// Set type for graphql method
|
|
1650
|
-
if (((
|
|
1658
|
+
if (((_g = fieldsConfig[key]) === null || _g === void 0 ? void 0 : _g.type) === 'Float') {
|
|
1651
1659
|
if (value) {
|
|
1652
1660
|
data[key] = Number(value);
|
|
1653
1661
|
}
|
|
@@ -1655,8 +1663,8 @@ class ModelFormComponent {
|
|
|
1655
1663
|
data[key] = null;
|
|
1656
1664
|
}
|
|
1657
1665
|
}
|
|
1658
|
-
if (((
|
|
1659
|
-
data[key] = this.prepareDataForRequest((
|
|
1666
|
+
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) {
|
|
1667
|
+
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
1668
|
}
|
|
1661
1669
|
}
|
|
1662
1670
|
return data;
|
|
@@ -1695,6 +1703,13 @@ class ModelFormComponent {
|
|
|
1695
1703
|
this.fileChanges = [event];
|
|
1696
1704
|
}
|
|
1697
1705
|
}
|
|
1706
|
+
formatDate(date) {
|
|
1707
|
+
if (!date) {
|
|
1708
|
+
return null;
|
|
1709
|
+
}
|
|
1710
|
+
const newDate = new Date(date);
|
|
1711
|
+
return newDate.toISOString().substring(0, 16);
|
|
1712
|
+
}
|
|
1698
1713
|
}
|
|
1699
1714
|
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
1715
|
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"] }] });
|