@lenne.tech/ng-base 13.15.0 → 13.18.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 +4 -3
- package/base-components/components/model-form/model-form.component.d.ts +14 -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 -2
- package/base-components/public-api.d.ts +1 -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 +17 -25
- package/esm2020/base-components/base-components.module.mjs +7 -3
- package/esm2020/base-components/components/model-form/model-form.component.mjs +60 -12
- package/esm2020/base-components/components/model-form-sub/model-form-sub.component.mjs +46 -0
- package/esm2020/base-components/components/model-table/model-table.component.mjs +23 -5
- package/esm2020/base-components/public-api.mjs +2 -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 +6 -1
- package/esm2020/shared/services/user.service.mjs +2 -1
- package/fesm2015/lenne.tech-ng-base-base-cms.mjs +19 -27
- package/fesm2015/lenne.tech-ng-base-base-cms.mjs.map +1 -1
- package/fesm2015/lenne.tech-ng-base-base-components.mjs +130 -16
- 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 +122 -3
- package/fesm2015/lenne.tech-ng-base-shared.mjs.map +1 -1
- package/fesm2020/lenne.tech-ng-base-base-cms.mjs +18 -27
- package/fesm2020/lenne.tech-ng-base-base-cms.mjs.map +1 -1
- package/fesm2020/lenne.tech-ng-base-base-components.mjs +124 -13
- 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 +119 -3
- package/fesm2020/lenne.tech-ng-base-shared.mjs.map +1 -1
- package/package.json +3 -2
- 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
|
@@ -4,6 +4,7 @@ import * as i4 from '@angular/common';
|
|
|
4
4
|
import { CommonModule } from '@angular/common';
|
|
5
5
|
import { ReactiveFormsModule } from '@angular/forms';
|
|
6
6
|
import * as i1 from '@lenne.tech/ng-base/shared';
|
|
7
|
+
import { BasicUser } from '@lenne.tech/ng-base/shared';
|
|
7
8
|
import * as i2 from '@angular/router';
|
|
8
9
|
import { RouterModule } from '@angular/router';
|
|
9
10
|
import * as i3 from '@lenne.tech/ng-base/base-components';
|
|
@@ -21,7 +22,9 @@ class BaseCmsComponent {
|
|
|
21
22
|
this.types = [];
|
|
22
23
|
this.route.params.subscribe((value) => {
|
|
23
24
|
if (value['modelName']) {
|
|
24
|
-
|
|
25
|
+
const restricted = this.moduleConfig.modelConfig[value['modelName']]?.restricted;
|
|
26
|
+
const excluded = this.moduleConfig.modelConfig[value['modelName']]?.excluded;
|
|
27
|
+
if ((restricted !== null && !restricted) || (excluded !== null && !excluded)) {
|
|
25
28
|
this.modelName = value['modelName'];
|
|
26
29
|
}
|
|
27
30
|
else {
|
|
@@ -53,23 +56,26 @@ class BaseCmsComponent {
|
|
|
53
56
|
if (this.route.snapshot?.params?.['id']) {
|
|
54
57
|
this.id = this.route.snapshot?.params?.['id'];
|
|
55
58
|
}
|
|
56
|
-
const excludedModels = this.moduleConfig.excludedModels?.map((e) => e.toLowerCase());
|
|
57
59
|
const types = meta.getTypes();
|
|
58
60
|
// Check for excluded types
|
|
59
|
-
const filteredTypes = types.filter((e) => !
|
|
61
|
+
const filteredTypes = types.filter((e) => !this.moduleConfig?.modelConfig[e.name.toLowerCase()]?.excluded);
|
|
60
62
|
// Check for restricted types
|
|
61
63
|
this.types = filteredTypes.filter((e) => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (!this.authService.currentUser) {
|
|
64
|
+
if (this.moduleConfig?.modelConfig[e.name.toLowerCase()]?.restricted) {
|
|
65
|
+
if (!this.authService?.currentUser) {
|
|
65
66
|
return false;
|
|
66
67
|
}
|
|
67
|
-
|
|
68
|
+
const user = this.authService?.currentUser;
|
|
69
|
+
const mappedUser = BasicUser.map(user);
|
|
70
|
+
return mappedUser?.hasAllRoles(this.moduleConfig?.modelConfig[e.name.toLowerCase()]?.roles);
|
|
68
71
|
}
|
|
69
72
|
else {
|
|
70
73
|
return true;
|
|
71
74
|
}
|
|
72
75
|
});
|
|
76
|
+
if (this.moduleConfig?.logging) {
|
|
77
|
+
console.log('BaseCmsComponent::init->types', this.types);
|
|
78
|
+
}
|
|
73
79
|
resolve(this.types);
|
|
74
80
|
if (!this.modelName && this.types) {
|
|
75
81
|
this.router.navigate(['./' + this.types[0].name.toLowerCase()], { relativeTo: this.route });
|
|
@@ -77,20 +83,6 @@ class BaseCmsComponent {
|
|
|
77
83
|
});
|
|
78
84
|
});
|
|
79
85
|
}
|
|
80
|
-
/**
|
|
81
|
-
* It checks if the model is excluded or restricted
|
|
82
|
-
*
|
|
83
|
-
* @param model - The name of the model you want to check.
|
|
84
|
-
* @returns A boolean value.
|
|
85
|
-
*/
|
|
86
|
-
checkModelIsExcludedOrRestrcited(model) {
|
|
87
|
-
if (!model) {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
const excludedModels = this.moduleConfig.excludedModels?.map((e) => e.toLowerCase());
|
|
91
|
-
return !!(excludedModels?.includes(model?.toLowerCase()) ||
|
|
92
|
-
this.moduleConfig.restrictedModels?.find((e) => e.model.toLowerCase() === model.toLowerCase()));
|
|
93
|
-
}
|
|
94
86
|
/**
|
|
95
87
|
* If the model name is set and the types are set, then return the type that matches the model name
|
|
96
88
|
*
|
|
@@ -112,7 +104,7 @@ class BaseCmsComponent {
|
|
|
112
104
|
*/
|
|
113
105
|
onCreateModeChanged(createMode) {
|
|
114
106
|
if (createMode) {
|
|
115
|
-
this.router.navigate(['./' + '
|
|
107
|
+
this.router.navigate(['./' + 'neu'], { relativeTo: this.route });
|
|
116
108
|
}
|
|
117
109
|
}
|
|
118
110
|
/**
|
|
@@ -157,10 +149,10 @@ class BaseCmsComponent {
|
|
|
157
149
|
}
|
|
158
150
|
}
|
|
159
151
|
BaseCmsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: BaseCmsComponent, deps: [{ token: BASE_CMS_MODULE_CONFIG }, { token: i1.GraphQLMetaService }, { token: i2.ActivatedRoute }, { token: i2.Router }, { token: i1.AuthService }], target: i0.ɵɵFactoryTarget.Component });
|
|
160
|
-
BaseCmsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.3", type: BaseCmsComponent, selector: "app-base-cms", ngImport: i0, template: "<div class=\"main\">\n <div class=\"sidebar\">\n <div class=\"d-flex flex-column flex-shrink-0 p-3 h-100\">\n <ng-container *ngIf=\"moduleConfig.branding\">\n <a href=\"/\" class=\"d-flex flex-column align-items-start mb-3 mt-3 me-md-auto link-dark text-decoration-none\">\n <span class=\"d-block fs-4\"><b class=\"text-primary\">Base</b>CMS</span>\n <small class=\"fw-lighter\">The auto generated GraphQL CMS</small>\n </a>\n <hr />\n </ng-container>\n <ul class=\"nav nav-pills flex-column mb-auto\" *ngIf=\"types\">\n <li class=\"nav-item\" *ngFor=\"let type of types\">\n <a\n class=\"nav-link\"\n aria-current=\"page\"\n [routerLink]=\"(id ? '../../' : '../') + type?.name?.toLowerCase()\"\n [ngClass]=\"{ active: type?.name?.toLowerCase() === this.modelName?.toLowerCase() }\"\n >\n {{ type.name + 's'
|
|
152
|
+
BaseCmsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "13.3.3", type: BaseCmsComponent, selector: "app-base-cms", ngImport: i0, template: "<div class=\"main\">\n <div class=\"sidebar\">\n <div class=\"d-flex flex-column flex-shrink-0 p-3 h-100\">\n <ng-container *ngIf=\"moduleConfig.branding\">\n <a href=\"/\" class=\"d-flex flex-column align-items-start mb-3 mt-3 me-md-auto link-dark text-decoration-none\">\n <span class=\"d-block fs-4\"><b class=\"text-primary\">Base</b>CMS</span>\n <small class=\"fw-lighter\">The auto generated GraphQL CMS</small>\n </a>\n <hr />\n </ng-container>\n <ul class=\"nav nav-pills flex-column mb-auto\" *ngIf=\"types\">\n <li class=\"nav-item\" *ngFor=\"let type of types\">\n <a\n class=\"nav-link\"\n aria-current=\"page\"\n [routerLink]=\"(id ? '../../' : '../') + type?.name?.toLowerCase()\"\n [ngClass]=\"{ active: type?.name?.toLowerCase() === this.modelName?.toLowerCase() }\"\n >\n {{\n moduleConfig?.modelConfig[type?.name?.toLowerCase()]?.plural\n ? moduleConfig?.modelConfig[type?.name?.toLowerCase()]?.plural\n : moduleConfig?.modelConfig[type?.name?.toLowerCase()]?.label\n ? moduleConfig?.modelConfig[type?.name?.toLowerCase()]?.label\n : type.name + 's'\n }}\n </a>\n </li>\n </ul>\n </div>\n </div>\n\n <div class=\"sidebar-content\">\n <div class=\"p-5\">\n <base-model-table\n [config]=\"moduleConfig?.modelConfig[modelName?.toLowerCase()]\"\n [fieldConfig]=\"moduleConfig?.fieldConfig[modelName?.toLowerCase()] || {}\"\n [modelName]=\"modelName\"\n [objectId]=\"id !== 'neu' ? id : ''\"\n [createMode]=\"id === 'neu'\"\n (createModeChanged)=\"onCreateModeChanged($event)\"\n (idSelected)=\"idSelected($event)\"\n [create]=\"isCreatePossible()\"\n [update]=\"isUpdatePossible()\"\n [delete]=\"isDeletePossible()\"\n ></base-model-table>\n </div>\n </div>\n</div>\n", styles: [".active{color:var(--bs-primary)!important;background-color:rgba(var(--bs-primary-rgb),.2)!important;font-weight:700}.nav-link{color:var(--bs-body-color)}.sidebar{box-shadow:#7090b014 14px 17px 40px 4px;transition:all .2s linear 0s;z-index:99}.main{display:flex;flex-direction:row;overflow:hidden;height:100%}.main .sidebar{flex:1 0 22%;max-width:300px}.main .sidebar-content{flex-grow:999;overflow-y:auto;background-color:#f5f7fe}.nav-flush .nav-link{border-radius:0}\n"], components: [{ type: i3.ModelTableComponent, selector: "base-model-table", inputs: ["modelName", "objectId", "createMode", "create", "update", "delete", "config", "fieldConfig"], outputs: ["idSelected", "createModeChanged"] }], directives: [{ type: i4.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i4.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i2.RouterLinkWithHref, selector: "a[routerLink],area[routerLink]", inputs: ["target", "queryParams", "fragment", "queryParamsHandling", "preserveFragment", "skipLocationChange", "replaceUrl", "state", "relativeTo", "routerLink"] }, { type: i4.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
|
|
161
153
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: BaseCmsComponent, decorators: [{
|
|
162
154
|
type: Component,
|
|
163
|
-
args: [{ selector: 'app-base-cms', template: "<div class=\"main\">\n <div class=\"sidebar\">\n <div class=\"d-flex flex-column flex-shrink-0 p-3 h-100\">\n <ng-container *ngIf=\"moduleConfig.branding\">\n <a href=\"/\" class=\"d-flex flex-column align-items-start mb-3 mt-3 me-md-auto link-dark text-decoration-none\">\n <span class=\"d-block fs-4\"><b class=\"text-primary\">Base</b>CMS</span>\n <small class=\"fw-lighter\">The auto generated GraphQL CMS</small>\n </a>\n <hr />\n </ng-container>\n <ul class=\"nav nav-pills flex-column mb-auto\" *ngIf=\"types\">\n <li class=\"nav-item\" *ngFor=\"let type of types\">\n <a\n class=\"nav-link\"\n aria-current=\"page\"\n [routerLink]=\"(id ? '../../' : '../') + type?.name?.toLowerCase()\"\n [ngClass]=\"{ active: type?.name?.toLowerCase() === this.modelName?.toLowerCase() }\"\n >\n {{ type.name + 's'
|
|
155
|
+
args: [{ selector: 'app-base-cms', template: "<div class=\"main\">\n <div class=\"sidebar\">\n <div class=\"d-flex flex-column flex-shrink-0 p-3 h-100\">\n <ng-container *ngIf=\"moduleConfig.branding\">\n <a href=\"/\" class=\"d-flex flex-column align-items-start mb-3 mt-3 me-md-auto link-dark text-decoration-none\">\n <span class=\"d-block fs-4\"><b class=\"text-primary\">Base</b>CMS</span>\n <small class=\"fw-lighter\">The auto generated GraphQL CMS</small>\n </a>\n <hr />\n </ng-container>\n <ul class=\"nav nav-pills flex-column mb-auto\" *ngIf=\"types\">\n <li class=\"nav-item\" *ngFor=\"let type of types\">\n <a\n class=\"nav-link\"\n aria-current=\"page\"\n [routerLink]=\"(id ? '../../' : '../') + type?.name?.toLowerCase()\"\n [ngClass]=\"{ active: type?.name?.toLowerCase() === this.modelName?.toLowerCase() }\"\n >\n {{\n moduleConfig?.modelConfig[type?.name?.toLowerCase()]?.plural\n ? moduleConfig?.modelConfig[type?.name?.toLowerCase()]?.plural\n : moduleConfig?.modelConfig[type?.name?.toLowerCase()]?.label\n ? moduleConfig?.modelConfig[type?.name?.toLowerCase()]?.label\n : type.name + 's'\n }}\n </a>\n </li>\n </ul>\n </div>\n </div>\n\n <div class=\"sidebar-content\">\n <div class=\"p-5\">\n <base-model-table\n [config]=\"moduleConfig?.modelConfig[modelName?.toLowerCase()]\"\n [fieldConfig]=\"moduleConfig?.fieldConfig[modelName?.toLowerCase()] || {}\"\n [modelName]=\"modelName\"\n [objectId]=\"id !== 'neu' ? id : ''\"\n [createMode]=\"id === 'neu'\"\n (createModeChanged)=\"onCreateModeChanged($event)\"\n (idSelected)=\"idSelected($event)\"\n [create]=\"isCreatePossible()\"\n [update]=\"isUpdatePossible()\"\n [delete]=\"isDeletePossible()\"\n ></base-model-table>\n </div>\n </div>\n</div>\n", styles: [".active{color:var(--bs-primary)!important;background-color:rgba(var(--bs-primary-rgb),.2)!important;font-weight:700}.nav-link{color:var(--bs-body-color)}.sidebar{box-shadow:#7090b014 14px 17px 40px 4px;transition:all .2s linear 0s;z-index:99}.main{display:flex;flex-direction:row;overflow:hidden;height:100%}.main .sidebar{flex:1 0 22%;max-width:300px}.main .sidebar-content{flex-grow:999;overflow-y:auto;background-color:#f5f7fe}.nav-flush .nav-link{border-radius:0}\n"] }]
|
|
164
156
|
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
165
157
|
type: Inject,
|
|
166
158
|
args: [BASE_CMS_MODULE_CONFIG]
|
|
@@ -195,9 +187,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImpor
|
|
|
195
187
|
|
|
196
188
|
function CMSConfigFactory() {
|
|
197
189
|
return {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
restrictedModels: [],
|
|
190
|
+
modelConfig: {},
|
|
191
|
+
fieldConfig: {},
|
|
201
192
|
branding: true,
|
|
202
193
|
logging: false,
|
|
203
194
|
...BaseCMSModule.config,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lenne.tech-ng-base-base-cms.mjs","sources":["../../../projects/ng-base/base-cms/interfaces/base-cms-module-config.interface.ts","../../../projects/ng-base/base-cms/pages/base-cms/base-cms.component.ts","../../../projects/ng-base/base-cms/pages/base-cms/base-cms.component.html","../../../projects/ng-base/base-cms/base-cms-routing.module.ts","../../../projects/ng-base/base-cms/base-cms.module.ts","../../../projects/ng-base/base-cms/public-api.ts","../../../projects/ng-base/base-cms/lenne.tech-ng-base-base-cms.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport interface BaseCMSModuleConfig {\n tableFields?: string[];\n excludedModels?: string[];\n restrictedModels?: [{ model: string; roles: string[] }];\n logging?: boolean;\n branding?: boolean;\n}\n\nexport const BASE_CMS_MODULE_CONFIG = new InjectionToken('BASE_CMS_MODULE_CONFIG');\n","import { Component, Inject, OnInit } from '@angular/core';\nimport { AuthService, GraphqlCrudType, GraphQLMeta, GraphQLMetaService } from '@lenne.tech/ng-base/shared';\nimport { ActivatedRoute, Router } from '@angular/router';\nimport { BASE_CMS_MODULE_CONFIG, BaseCMSModuleConfig } from '../../interfaces/base-cms-module-config.interface';\n\n@Component({\n selector: 'app-base-cms',\n templateUrl: './base-cms.component.html',\n styleUrls: ['./base-cms.component.scss'],\n})\nexport class BaseCmsComponent implements OnInit {\n meta: GraphQLMeta;\n modelName: string;\n id: string;\n types: GraphqlCrudType[] = [];\n\n constructor(\n @Inject(BASE_CMS_MODULE_CONFIG) public moduleConfig: BaseCMSModuleConfig,\n private graphQLMetaService: GraphQLMetaService,\n private route: ActivatedRoute,\n private router: Router,\n private authService: AuthService\n ) {\n this.route.params.subscribe((value) => {\n if (value['modelName']) {\n if (!this.checkModelIsExcludedOrRestrcited(value['modelName'])) {\n this.modelName = value['modelName'];\n } else {\n this.init().then((types: GraphqlCrudType[]) => {\n this.router.navigate(['../' + types[0].name.toLowerCase()], { relativeTo: this.route });\n });\n }\n }\n\n if (value['id']) {\n this.id = value['id'];\n }\n });\n }\n\n async ngOnInit() {\n await this.init();\n }\n\n /**\n * It returns a promise that resolves to an array of GraphqlCrudType objects\n *\n * @returns The types that are available to the user.\n */\n init(): Promise<GraphqlCrudType[]> {\n return new Promise((resolve, reject) => {\n this.graphQLMetaService.getMeta().subscribe((meta) => {\n this.meta = meta;\n\n if (this.route.snapshot?.params?.['modelName']) {\n this.modelName = this.route.snapshot?.params?.['modelName'];\n }\n\n if (this.route.snapshot?.params?.['id']) {\n this.id = this.route.snapshot?.params?.['id'];\n }\n\n const excludedModels = this.moduleConfig.excludedModels?.map((e) => e.toLowerCase());\n const types = meta.getTypes();\n\n // Check for excluded types\n const filteredTypes = types.filter((e) => !excludedModels?.includes(e.name.toLowerCase()));\n\n // Check for restricted types\n this.types = filteredTypes.filter((e) => {\n const foundRestrict = this.moduleConfig.restrictedModels?.find(\n (v) => v.model.toLowerCase() === e.name.toLowerCase()\n );\n\n if (foundRestrict) {\n if (!this.authService.currentUser) {\n return false;\n }\n\n return this.authService.currentUser.hasAllRoles(foundRestrict.roles);\n } else {\n return true;\n }\n });\n\n resolve(this.types);\n\n if (!this.modelName && this.types) {\n this.router.navigate(['./' + this.types[0].name.toLowerCase()], { relativeTo: this.route });\n }\n });\n });\n }\n\n /**\n * It checks if the model is excluded or restricted\n *\n * @param model - The name of the model you want to check.\n * @returns A boolean value.\n */\n checkModelIsExcludedOrRestrcited(model: string): boolean {\n if (!model) {\n return false;\n }\n const excludedModels = this.moduleConfig.excludedModels?.map((e) => e.toLowerCase());\n return !!(\n excludedModels?.includes(model?.toLowerCase()) ||\n this.moduleConfig.restrictedModels?.find((e) => e.model.toLowerCase() === model.toLowerCase())\n );\n }\n\n /**\n * If the model name is set and the types are set, then return the type that matches the model name\n *\n * @returns The type object that matches the model name.\n */\n getTypeByModelName() {\n if (this.modelName && this.types) {\n return this.types.find((e) => e.name.toLowerCase() === this.modelName.toLowerCase());\n } else {\n return null;\n }\n }\n\n /**\n * When the createModeChanged event is emitted, if the createMode is true, navigate to the new route\n *\n * @param createMode - boolean - This is a boolean value that indicates whether the user is in create mode or\n * not.\n */\n onCreateModeChanged(createMode: boolean) {\n if (createMode) {\n this.router.navigate(['./' + 'new'], { relativeTo: this.route });\n }\n }\n\n /**\n * If the type exists, return the create property of the type, otherwise return false.\n *\n * @returns A boolean value.\n */\n isCreatePossible(): boolean {\n const type = this.getTypeByModelName();\n return type ? type.create : false;\n }\n\n /**\n * If the model name is found in the type map, return the update property of the type object\n *\n * @returns A boolean value.\n */\n isUpdatePossible(): boolean {\n const type = this.getTypeByModelName();\n return type ? type.update : false;\n }\n\n /**\n * If the type is defined, return the delete property of the type, otherwise return false\n *\n * @returns A boolean value.\n */\n isDeletePossible(): boolean {\n const type = this.getTypeByModelName();\n return type ? type.delete : false;\n }\n\n /**\n * If the id is truthy, navigate to the id, otherwise navigate to the parent route\n *\n * @param id - The id of the selected item.\n */\n idSelected(id: string) {\n if (id) {\n this.router.navigate(['./' + id], { relativeTo: this.route });\n } else {\n this.router.navigate(['..'], { relativeTo: this.route });\n }\n }\n}\n","<div class=\"main\">\n <div class=\"sidebar\">\n <div class=\"d-flex flex-column flex-shrink-0 p-3 h-100\">\n <ng-container *ngIf=\"moduleConfig.branding\">\n <a href=\"/\" class=\"d-flex flex-column align-items-start mb-3 mt-3 me-md-auto link-dark text-decoration-none\">\n <span class=\"d-block fs-4\"><b class=\"text-primary\">Base</b>CMS</span>\n <small class=\"fw-lighter\">The auto generated GraphQL CMS</small>\n </a>\n <hr />\n </ng-container>\n <ul class=\"nav nav-pills flex-column mb-auto\" *ngIf=\"types\">\n <li class=\"nav-item\" *ngFor=\"let type of types\">\n <a\n class=\"nav-link\"\n aria-current=\"page\"\n [routerLink]=\"(id ? '../../' : '../') + type?.name?.toLowerCase()\"\n [ngClass]=\"{ active: type?.name?.toLowerCase() === this.modelName?.toLowerCase() }\"\n >\n {{ type.name + 's' }}\n </a>\n </li>\n </ul>\n </div>\n </div>\n\n <div class=\"sidebar-content\">\n <div class=\"p-5\">\n <base-model-table\n [tableFields]=\"moduleConfig?.tableFields ?? ['name']\"\n [modelName]=\"modelName\"\n [objectId]=\"id !== 'new' ? id : ''\"\n [createMode]=\"id === 'new'\"\n (createModeChanged)=\"onCreateModeChanged($event)\"\n (idSelected)=\"idSelected($event)\"\n [create]=\"isCreatePossible()\"\n [update]=\"isUpdatePossible()\"\n [delete]=\"isDeletePossible()\"\n ></base-model-table>\n </div>\n </div>\n</div>\n","import { RouterModule, Routes } from '@angular/router';\nimport { NgModule } from '@angular/core';\nimport { BaseCmsComponent } from './pages/base-cms/base-cms.component';\n\nconst routes: Routes = [\n {\n path: '',\n component: BaseCmsComponent,\n },\n {\n path: ':modelName',\n component: BaseCmsComponent,\n },\n {\n path: ':modelName/:id',\n component: BaseCmsComponent,\n },\n];\n\n@NgModule({\n imports: [RouterModule.forChild(routes)],\n exports: [RouterModule],\n})\nexport class BaseCMSRoutingModule {}\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { BaseCmsComponent } from './pages/base-cms/base-cms.component';\nimport { BaseCMSRoutingModule } from './base-cms-routing.module';\nimport { BaseComponentsModule } from '@lenne.tech/ng-base/base-components';\nimport { BASE_CMS_MODULE_CONFIG, BaseCMSModuleConfig } from './interfaces/base-cms-module-config.interface';\n\nexport function CMSConfigFactory() {\n return {\n tableFields: ['id', 'name', 'title', 'description', 'email', 'createdAt', 'updatedAt'],\n excludedModels: [],\n restrictedModels: [],\n branding: true,\n logging: false,\n ...BaseCMSModule.config,\n };\n}\n\n@NgModule({\n imports: [\n // Modules\n CommonModule,\n ReactiveFormsModule,\n BaseCMSRoutingModule,\n BaseComponentsModule,\n ],\n declarations: [BaseCmsComponent],\n exports: [],\n providers: [\n {\n provide: BASE_CMS_MODULE_CONFIG,\n useFactory: CMSConfigFactory,\n },\n ],\n})\nexport class BaseCMSModule {\n static config: BaseCMSModuleConfig;\n}\n","/**\n * Exports for public API\n */\n\n// Module\nexport * from './base-cms.module';\n\n// Pages\nexport * from './pages/base-cms/base-cms.component';\n\n// Interface\nexport * from './interfaces/base-cms-module-config.interface';\n","/**\n * Generated bundle index. Do not edit.\n */\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AA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,aAAa,EAPb,SAAA,EAAA;AACT,QAAA;AACE,YAAA,OAAO,EAAE,sBAAsB;AAC/B,YAAA,UAAU,EAAE,gBAAgB;AAC7B,SAAA;KACF,EAdQ,OAAA,EAAA,CAAA;;YAEP,YAAY;YACZ,mBAAmB;YACnB,oBAAoB;YACpB,oBAAoB;AACrB,SAAA,CAAA,EAAA,CAAA,CAAA;2FAUU,aAAa,EAAA,UAAA,EAAA,CAAA;kBAjBzB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,OAAO,EAAE;;wBAEP,YAAY;wBACZ,mBAAmB;wBACnB,oBAAoB;wBACpB,oBAAoB;AACrB,qBAAA;oBACD,YAAY,EAAE,CAAC,gBAAgB,CAAC;AAChC,oBAAA,OAAO,EAAE,EAAE;AACX,oBAAA,SAAS,EAAE;AACT,wBAAA;AACE,4BAAA,OAAO,EAAE,sBAAsB;AAC/B,4BAAA,UAAU,EAAE,gBAAgB;AAC7B,yBAAA;AACF,qBAAA;AACF,iBAAA,CAAA;;;ACnCD;;AAEG;;ACFH;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"lenne.tech-ng-base-base-cms.mjs","sources":["../../../projects/ng-base/base-cms/interfaces/base-cms-module-config.interface.ts","../../../projects/ng-base/base-cms/pages/base-cms/base-cms.component.ts","../../../projects/ng-base/base-cms/pages/base-cms/base-cms.component.html","../../../projects/ng-base/base-cms/base-cms-routing.module.ts","../../../projects/ng-base/base-cms/base-cms.module.ts","../../../projects/ng-base/base-cms/public-api.ts","../../../projects/ng-base/base-cms/lenne.tech-ng-base-base-cms.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nexport interface BaseCMSModuleConfig {\n modelConfig?: { [key: string]: any };\n fieldConfig?: { [key: string]: any };\n logging?: boolean;\n branding?: boolean;\n}\n\nexport const BASE_CMS_MODULE_CONFIG = new InjectionToken('BASE_CMS_MODULE_CONFIG');\n","import { Component, Inject, OnInit } from '@angular/core';\nimport { AuthService, BasicUser, GraphqlCrudType, GraphQLMeta, GraphQLMetaService } from '@lenne.tech/ng-base/shared';\nimport { ActivatedRoute, Router } from '@angular/router';\nimport { BASE_CMS_MODULE_CONFIG, BaseCMSModuleConfig } from '../../interfaces/base-cms-module-config.interface';\n\n@Component({\n selector: 'app-base-cms',\n templateUrl: './base-cms.component.html',\n styleUrls: ['./base-cms.component.scss'],\n})\nexport class BaseCmsComponent implements OnInit {\n meta: GraphQLMeta;\n modelName: string;\n id: string;\n types: GraphqlCrudType[] = [];\n\n constructor(\n @Inject(BASE_CMS_MODULE_CONFIG) public moduleConfig: BaseCMSModuleConfig,\n private graphQLMetaService: GraphQLMetaService,\n private route: ActivatedRoute,\n private router: Router,\n private authService: AuthService\n ) {\n this.route.params.subscribe((value) => {\n if (value['modelName']) {\n const restricted = this.moduleConfig.modelConfig[value['modelName']]?.restricted;\n const excluded = this.moduleConfig.modelConfig[value['modelName']]?.excluded;\n if ((restricted !== null && !restricted) || (excluded !== null && !excluded)) {\n this.modelName = value['modelName'];\n } else {\n this.init().then((types: GraphqlCrudType[]) => {\n this.router.navigate(['../' + types[0].name.toLowerCase()], { relativeTo: this.route });\n });\n }\n }\n\n if (value['id']) {\n this.id = value['id'];\n }\n });\n }\n\n async ngOnInit() {\n await this.init();\n }\n\n /**\n * It returns a promise that resolves to an array of GraphqlCrudType objects\n *\n * @returns The types that are available to the user.\n */\n init(): Promise<GraphqlCrudType[]> {\n return new Promise((resolve, reject) => {\n this.graphQLMetaService.getMeta().subscribe((meta) => {\n this.meta = meta;\n\n if (this.route.snapshot?.params?.['modelName']) {\n this.modelName = this.route.snapshot?.params?.['modelName'];\n }\n\n if (this.route.snapshot?.params?.['id']) {\n this.id = this.route.snapshot?.params?.['id'];\n }\n\n const types = meta.getTypes();\n\n // Check for excluded types\n const filteredTypes = types.filter((e) => !this.moduleConfig?.modelConfig[e.name.toLowerCase()]?.excluded);\n\n // Check for restricted types\n this.types = filteredTypes.filter((e) => {\n if (this.moduleConfig?.modelConfig[e.name.toLowerCase()]?.restricted) {\n if (!this.authService?.currentUser) {\n return false;\n }\n const user = this.authService?.currentUser;\n const mappedUser = BasicUser.map(user);\n\n return mappedUser?.hasAllRoles(this.moduleConfig?.modelConfig[e.name.toLowerCase()]?.roles);\n } else {\n return true;\n }\n });\n\n if (this.moduleConfig?.logging) {\n console.log('BaseCmsComponent::init->types', this.types);\n }\n\n resolve(this.types);\n\n if (!this.modelName && this.types) {\n this.router.navigate(['./' + this.types[0].name.toLowerCase()], { relativeTo: this.route });\n }\n });\n });\n }\n\n /**\n * If the model name is set and the types are set, then return the type that matches the model name\n *\n * @returns The type object that matches the model name.\n */\n getTypeByModelName() {\n if (this.modelName && this.types) {\n return this.types.find((e) => e.name.toLowerCase() === this.modelName.toLowerCase());\n } else {\n return null;\n }\n }\n\n /**\n * When the createModeChanged event is emitted, if the createMode is true, navigate to the new route\n *\n * @param createMode - boolean - This is a boolean value that indicates whether the user is in create mode or\n * not.\n */\n onCreateModeChanged(createMode: boolean) {\n if (createMode) {\n this.router.navigate(['./' + 'neu'], { relativeTo: this.route });\n }\n }\n\n /**\n * If the type exists, return the create property of the type, otherwise return false.\n *\n * @returns A boolean value.\n */\n isCreatePossible(): boolean {\n const type = this.getTypeByModelName();\n return type ? type.create : false;\n }\n\n /**\n * If the model name is found in the type map, return the update property of the type object\n *\n * @returns A boolean value.\n */\n isUpdatePossible(): boolean {\n const type = this.getTypeByModelName();\n return type ? type.update : false;\n }\n\n /**\n * If the type is defined, return the delete property of the type, otherwise return false\n *\n * @returns A boolean value.\n */\n isDeletePossible(): boolean {\n const type = this.getTypeByModelName();\n return type ? type.delete : false;\n }\n\n /**\n * If the id is truthy, navigate to the id, otherwise navigate to the parent route\n *\n * @param id - The id of the selected item.\n */\n idSelected(id: string) {\n if (id) {\n this.router.navigate(['./' + id], { relativeTo: this.route });\n } else {\n this.router.navigate(['..'], { relativeTo: this.route });\n }\n }\n}\n","<div class=\"main\">\n <div class=\"sidebar\">\n <div class=\"d-flex flex-column flex-shrink-0 p-3 h-100\">\n <ng-container *ngIf=\"moduleConfig.branding\">\n <a href=\"/\" class=\"d-flex flex-column align-items-start mb-3 mt-3 me-md-auto link-dark text-decoration-none\">\n <span class=\"d-block fs-4\"><b class=\"text-primary\">Base</b>CMS</span>\n <small class=\"fw-lighter\">The auto generated GraphQL CMS</small>\n </a>\n <hr />\n </ng-container>\n <ul class=\"nav nav-pills flex-column mb-auto\" *ngIf=\"types\">\n <li class=\"nav-item\" *ngFor=\"let type of types\">\n <a\n class=\"nav-link\"\n aria-current=\"page\"\n [routerLink]=\"(id ? '../../' : '../') + type?.name?.toLowerCase()\"\n [ngClass]=\"{ active: type?.name?.toLowerCase() === this.modelName?.toLowerCase() }\"\n >\n {{\n moduleConfig?.modelConfig[type?.name?.toLowerCase()]?.plural\n ? moduleConfig?.modelConfig[type?.name?.toLowerCase()]?.plural\n : moduleConfig?.modelConfig[type?.name?.toLowerCase()]?.label\n ? moduleConfig?.modelConfig[type?.name?.toLowerCase()]?.label\n : type.name + 's'\n }}\n </a>\n </li>\n </ul>\n </div>\n </div>\n\n <div class=\"sidebar-content\">\n <div class=\"p-5\">\n <base-model-table\n [config]=\"moduleConfig?.modelConfig[modelName?.toLowerCase()]\"\n [fieldConfig]=\"moduleConfig?.fieldConfig[modelName?.toLowerCase()] || {}\"\n [modelName]=\"modelName\"\n [objectId]=\"id !== 'neu' ? id : ''\"\n [createMode]=\"id === 'neu'\"\n (createModeChanged)=\"onCreateModeChanged($event)\"\n (idSelected)=\"idSelected($event)\"\n [create]=\"isCreatePossible()\"\n [update]=\"isUpdatePossible()\"\n [delete]=\"isDeletePossible()\"\n ></base-model-table>\n </div>\n </div>\n</div>\n","import { RouterModule, Routes } from '@angular/router';\nimport { NgModule } from '@angular/core';\nimport { BaseCmsComponent } from './pages/base-cms/base-cms.component';\n\nconst routes: Routes = [\n {\n path: '',\n component: BaseCmsComponent,\n },\n {\n path: ':modelName',\n component: BaseCmsComponent,\n },\n {\n path: ':modelName/:id',\n component: BaseCmsComponent,\n },\n];\n\n@NgModule({\n imports: [RouterModule.forChild(routes)],\n exports: [RouterModule],\n})\nexport class BaseCMSRoutingModule {}\n","import { NgModule } from '@angular/core';\nimport { CommonModule } from '@angular/common';\nimport { ReactiveFormsModule } from '@angular/forms';\nimport { BaseCmsComponent } from './pages/base-cms/base-cms.component';\nimport { BaseCMSRoutingModule } from './base-cms-routing.module';\nimport { BaseComponentsModule } from '@lenne.tech/ng-base/base-components';\nimport { BASE_CMS_MODULE_CONFIG, BaseCMSModuleConfig } from './interfaces/base-cms-module-config.interface';\n\nexport function CMSConfigFactory() {\n return {\n modelConfig: {},\n fieldConfig: {},\n branding: true,\n logging: false,\n ...BaseCMSModule.config,\n };\n}\n\n@NgModule({\n imports: [\n // Modules\n CommonModule,\n ReactiveFormsModule,\n BaseCMSRoutingModule,\n BaseComponentsModule,\n ],\n declarations: [BaseCmsComponent],\n exports: [],\n providers: [\n {\n provide: BASE_CMS_MODULE_CONFIG,\n useFactory: CMSConfigFactory,\n },\n ],\n})\nexport class BaseCMSModule {\n static config: BaseCMSModuleConfig;\n}\n","/**\n * Exports for public API\n */\n\n// Module\nexport * from './base-cms.module';\n\n// Pages\nexport * from './pages/base-cms/base-cms.component';\n\n// Interface\nexport * from './interfaces/base-cms-module-config.interface';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;;MASa,sBAAsB,GAAG,IAAI,cAAc,CAAC,wBAAwB;;MCCpE,gBAAgB,CAAA;IAM3B,WACyC,CAAA,YAAiC,EAChE,kBAAsC,EACtC,KAAqB,EACrB,MAAc,EACd,WAAwB,EAAA;QAJO,IAAY,CAAA,YAAA,GAAZ,YAAY,CAAqB;QAChE,IAAkB,CAAA,kBAAA,GAAlB,kBAAkB,CAAoB;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ACrB,qBAAA;oBACD,YAAY,EAAE,CAAC,gBAAgB,CAAC;AAChC,oBAAA,OAAO,EAAE,EAAE;AACX,oBAAA,SAAS,EAAE;AACT,wBAAA;AACE,4BAAA,OAAO,EAAE,sBAAsB;AAC/B,4BAAA,UAAU,EAAE,gBAAgB;AAC7B,yBAAA;AACF,qBAAA;AACF,iBAAA,CAAA;;;AClCD;;AAEG;;ACFH;;AAEG;;;;"}
|
|
@@ -369,12 +369,54 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImpor
|
|
|
369
369
|
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
370
|
}], ctorParameters: function () { return [{ type: i1$1.BreadcrumbService }]; } });
|
|
371
371
|
|
|
372
|
+
class ModelFormSubComponent {
|
|
373
|
+
constructor() {
|
|
374
|
+
this.config = {};
|
|
375
|
+
this.keys = [];
|
|
376
|
+
}
|
|
377
|
+
ngOnInit() {
|
|
378
|
+
this.keys = Object.keys(this.fields);
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* It takes a string, capitalizes the first letter, and returns the new string
|
|
382
|
+
*
|
|
383
|
+
* @param value - The string that you want to capitalize the first letter of.
|
|
384
|
+
* @returns The first letter of the string is being capitalized and the rest of the string is being returned.
|
|
385
|
+
*/
|
|
386
|
+
capitalizeFirstLetter(value) {
|
|
387
|
+
return value.charAt(0).toUpperCase() + value.slice(1);
|
|
388
|
+
}
|
|
389
|
+
/**
|
|
390
|
+
* It takes an AbstractControl and returns a FormControl
|
|
391
|
+
*
|
|
392
|
+
* @param control - AbstractControl | null | undefined
|
|
393
|
+
* @returns A FormControl
|
|
394
|
+
*/
|
|
395
|
+
transformToControl(control) {
|
|
396
|
+
return control;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
ModelFormSubComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ModelFormSubComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
|
|
400
|
+
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]=\"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=\"'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: 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"] }] });
|
|
401
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ModelFormSubComponent, decorators: [{
|
|
402
|
+
type: Component,
|
|
403
|
+
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]=\"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=\"'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: [""] }]
|
|
404
|
+
}], propDecorators: { fields: [{
|
|
405
|
+
type: Input
|
|
406
|
+
}], form: [{
|
|
407
|
+
type: Input
|
|
408
|
+
}], config: [{
|
|
409
|
+
type: Input
|
|
410
|
+
}] } });
|
|
411
|
+
|
|
372
412
|
class ModelFormComponent {
|
|
373
413
|
constructor(graphQLMetaService, graphQLService, formsService) {
|
|
374
414
|
this.graphQLMetaService = graphQLMetaService;
|
|
375
415
|
this.graphQLService = graphQLService;
|
|
376
416
|
this.formsService = formsService;
|
|
377
417
|
this.delete = true;
|
|
418
|
+
this.logging = false;
|
|
419
|
+
this.config = {};
|
|
378
420
|
this.finished = new EventEmitter();
|
|
379
421
|
this.loading = false;
|
|
380
422
|
this.keys = [];
|
|
@@ -404,26 +446,40 @@ class ModelFormComponent {
|
|
|
404
446
|
});
|
|
405
447
|
this.fields = this.fields['input'];
|
|
406
448
|
this.keys = Object.keys(this.fields);
|
|
407
|
-
|
|
449
|
+
if (this.logging) {
|
|
450
|
+
console.log('ModelFormComponent::init->fields', this.fields);
|
|
451
|
+
console.log('ModelFormComponent::init->keys', this.keys);
|
|
452
|
+
}
|
|
453
|
+
this.form = this.createForm(this.fields);
|
|
408
454
|
if (this.id) {
|
|
409
455
|
this.getObjectById(this.id);
|
|
410
456
|
}
|
|
411
457
|
}
|
|
412
458
|
}
|
|
459
|
+
getKeysFromSubObject(key) {
|
|
460
|
+
return Object.keys(this.fields[key]);
|
|
461
|
+
}
|
|
413
462
|
/**
|
|
414
463
|
* It takes an id, and then calls the graphQLService to get the object from the database
|
|
415
464
|
*
|
|
416
465
|
* @param id - The id of the object to be loaded
|
|
417
466
|
*/
|
|
418
467
|
getObjectById(id) {
|
|
468
|
+
if (this.logging) {
|
|
469
|
+
console.log('ModelFormComponent::getObjectById->id', id);
|
|
470
|
+
console.log('ModelFormComponent::getObjectById->requestFields', this.createRequestObject(this.fields));
|
|
471
|
+
}
|
|
419
472
|
this.graphQLService
|
|
420
473
|
.graphQl('get' + this.capitalizeFirstLetter(this.modelName), {
|
|
421
474
|
arguments: { id },
|
|
422
|
-
fields: this.
|
|
475
|
+
fields: this.createRequestObject(this.fields),
|
|
423
476
|
type: GraphQLRequestType.QUERY,
|
|
424
477
|
})
|
|
425
478
|
.subscribe({
|
|
426
479
|
next: (value) => {
|
|
480
|
+
if (this.logging) {
|
|
481
|
+
console.log('ModelFormComponent::get->value', value);
|
|
482
|
+
}
|
|
427
483
|
this.form.patchValue({ ...{}, ...value });
|
|
428
484
|
},
|
|
429
485
|
error: (err) => {
|
|
@@ -432,6 +488,28 @@ class ModelFormComponent {
|
|
|
432
488
|
},
|
|
433
489
|
});
|
|
434
490
|
}
|
|
491
|
+
/**
|
|
492
|
+
* It takes a GraphQL type collection and returns an array of strings and objects
|
|
493
|
+
*
|
|
494
|
+
* @param fields - IGraphQLTypeCollection - This is the object that is returned from the
|
|
495
|
+
* introspection query.
|
|
496
|
+
* @returns An array of strings and objects.
|
|
497
|
+
*/
|
|
498
|
+
createRequestObject(fields) {
|
|
499
|
+
const requestFields = [];
|
|
500
|
+
for (const [key, value] of Object.entries(fields)) {
|
|
501
|
+
if (fields[key]?.type) {
|
|
502
|
+
requestFields.push(key);
|
|
503
|
+
}
|
|
504
|
+
else {
|
|
505
|
+
const subkeys = this.createRequestObject(fields[key]);
|
|
506
|
+
const resultObject = {};
|
|
507
|
+
resultObject[key] = subkeys;
|
|
508
|
+
requestFields.push(resultObject);
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
return requestFields;
|
|
512
|
+
}
|
|
435
513
|
/**
|
|
436
514
|
* It takes a collection of GraphQL types and creates a form group with a form control for each type
|
|
437
515
|
*
|
|
@@ -441,10 +519,13 @@ class ModelFormComponent {
|
|
|
441
519
|
const group = {};
|
|
442
520
|
for (const [key, value] of Object.entries(fields)) {
|
|
443
521
|
if (fields[key]?.type) {
|
|
444
|
-
group[key] = new FormControl('', value.isRequired ? Validators.required : []);
|
|
522
|
+
group[key] = new FormControl(fields[key]?.type === 'Float' ? 0 : '', value.isRequired ? Validators.required : []);
|
|
523
|
+
}
|
|
524
|
+
else {
|
|
525
|
+
group[key] = this.createForm(fields[key]);
|
|
445
526
|
}
|
|
446
527
|
}
|
|
447
|
-
|
|
528
|
+
return new FormGroup(group);
|
|
448
529
|
}
|
|
449
530
|
/**
|
|
450
531
|
* It calls the graphQLService to delete the object with the id of the object that is currently being edited
|
|
@@ -502,6 +583,9 @@ class ModelFormComponent {
|
|
|
502
583
|
this.loading = false;
|
|
503
584
|
return;
|
|
504
585
|
}
|
|
586
|
+
if (this.logging) {
|
|
587
|
+
console.log('ModelFormComponent::submit->formValue', this.form.value);
|
|
588
|
+
}
|
|
505
589
|
this.graphQLService
|
|
506
590
|
.graphQl(this.operation + this.capitalizeFirstLetter(this.modelName), {
|
|
507
591
|
arguments: this.operation === 'update' ? { id: this.id, input: this.form.value } : { input: this.form.value },
|
|
@@ -521,16 +605,22 @@ class ModelFormComponent {
|
|
|
521
605
|
}
|
|
522
606
|
}
|
|
523
607
|
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 });
|
|
524
|
-
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" }, outputs: { finished: "finished" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"w-100\" *ngIf=\"form\">\n <
|
|
608
|
+
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"] }] });
|
|
525
609
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ModelFormComponent, decorators: [{
|
|
526
610
|
type: Component,
|
|
527
|
-
args: [{ selector: 'base-model-form', template: "<div class=\"w-100\" *ngIf=\"form\">\n <
|
|
611
|
+
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: [""] }]
|
|
528
612
|
}], ctorParameters: function () { return [{ type: i1$1.GraphQLMetaService }, { type: i1$1.GraphQLService }, { type: i1$1.FormsService }]; }, propDecorators: { modelName: [{
|
|
529
613
|
type: Input
|
|
614
|
+
}], label: [{
|
|
615
|
+
type: Input
|
|
530
616
|
}], id: [{
|
|
531
617
|
type: Input
|
|
532
618
|
}], delete: [{
|
|
533
619
|
type: Input
|
|
620
|
+
}], logging: [{
|
|
621
|
+
type: Input
|
|
622
|
+
}], config: [{
|
|
623
|
+
type: Input
|
|
534
624
|
}], finished: [{
|
|
535
625
|
type: Output
|
|
536
626
|
}] } });
|
|
@@ -543,9 +633,11 @@ class ModelTableComponent {
|
|
|
543
633
|
this.create = true;
|
|
544
634
|
this.update = true;
|
|
545
635
|
this.delete = true;
|
|
546
|
-
this.
|
|
636
|
+
this.config = {};
|
|
637
|
+
this.fieldConfig = {};
|
|
547
638
|
this.idSelected = new EventEmitter();
|
|
548
639
|
this.createModeChanged = new EventEmitter();
|
|
640
|
+
this.tableFields = ['id', 'name', 'title', 'description', 'email', 'createdAt', 'updatedAt'];
|
|
549
641
|
this.objects = [];
|
|
550
642
|
this.availableFields = [];
|
|
551
643
|
this.selectedId = '';
|
|
@@ -567,6 +659,9 @@ class ModelTableComponent {
|
|
|
567
659
|
}
|
|
568
660
|
if (changes['objectId'] && this.meta) {
|
|
569
661
|
if (this.selectedId !== this.objectId) {
|
|
662
|
+
if (this.config?.logging) {
|
|
663
|
+
console.log('ModelTableComponent::ngOnChanges->selectedId', this.selectedId);
|
|
664
|
+
}
|
|
570
665
|
this.selectedId = this.objectId;
|
|
571
666
|
}
|
|
572
667
|
}
|
|
@@ -577,6 +672,9 @@ class ModelTableComponent {
|
|
|
577
672
|
*/
|
|
578
673
|
init() {
|
|
579
674
|
this.availableFields = [];
|
|
675
|
+
if (this.config?.tableFields) {
|
|
676
|
+
this.tableFields = this.config.tableFields;
|
|
677
|
+
}
|
|
580
678
|
const possibleFields = this.meta.getFields('find' + this.capitalizeFirstLetter(this.modelName) + 's');
|
|
581
679
|
const keys = Object.keys(possibleFields);
|
|
582
680
|
this.tableFields?.forEach((field) => {
|
|
@@ -584,6 +682,11 @@ class ModelTableComponent {
|
|
|
584
682
|
this.availableFields.push(field);
|
|
585
683
|
}
|
|
586
684
|
});
|
|
685
|
+
if (this.config?.logging) {
|
|
686
|
+
console.log('ModelTableComponent::init->possibleFields', possibleFields);
|
|
687
|
+
console.log('ModelTableComponent::init->keys', keys);
|
|
688
|
+
console.log('ModelTableComponent::init->availableFields', this.availableFields);
|
|
689
|
+
}
|
|
587
690
|
this.loadObjects(this.availableFields);
|
|
588
691
|
}
|
|
589
692
|
/**
|
|
@@ -608,6 +711,9 @@ class ModelTableComponent {
|
|
|
608
711
|
})
|
|
609
712
|
.subscribe({
|
|
610
713
|
next: (value) => {
|
|
714
|
+
if (this.config?.logging) {
|
|
715
|
+
console.log('ModelTableComponent::loadObjects->value', value);
|
|
716
|
+
}
|
|
611
717
|
this.objects = value;
|
|
612
718
|
},
|
|
613
719
|
error: (err) => {
|
|
@@ -642,10 +748,10 @@ class ModelTableComponent {
|
|
|
642
748
|
}
|
|
643
749
|
}
|
|
644
750
|
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 });
|
|
645
|
-
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",
|
|
751
|
+
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"] }] });
|
|
646
752
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ModelTableComponent, decorators: [{
|
|
647
753
|
type: Component,
|
|
648
|
-
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 <
|
|
754
|
+
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"] }]
|
|
649
755
|
}], ctorParameters: function () { return [{ type: i1$1.GraphQLMetaService }, { type: i1$1.GraphQLService }]; }, propDecorators: { modelName: [{
|
|
650
756
|
type: Input
|
|
651
757
|
}], objectId: [{
|
|
@@ -658,7 +764,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImpor
|
|
|
658
764
|
type: Input
|
|
659
765
|
}], delete: [{
|
|
660
766
|
type: Input
|
|
661
|
-
}],
|
|
767
|
+
}], config: [{
|
|
768
|
+
type: Input
|
|
769
|
+
}], fieldConfig: [{
|
|
662
770
|
type: Input
|
|
663
771
|
}], idSelected: [{
|
|
664
772
|
type: Output
|
|
@@ -682,6 +790,7 @@ const elements = [
|
|
|
682
790
|
BreadcrumbComponent,
|
|
683
791
|
ModelFormComponent,
|
|
684
792
|
ModelTableComponent,
|
|
793
|
+
ModelFormSubComponent,
|
|
685
794
|
];
|
|
686
795
|
class BaseComponentsModule {
|
|
687
796
|
}
|
|
@@ -698,7 +807,8 @@ BaseComponentsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", ve
|
|
|
698
807
|
SkeletonLoaderComponent,
|
|
699
808
|
BreadcrumbComponent,
|
|
700
809
|
ModelFormComponent,
|
|
701
|
-
ModelTableComponent
|
|
810
|
+
ModelTableComponent,
|
|
811
|
+
ModelFormSubComponent], imports: [FormsModule, ReactiveFormsModule, CommonModule], exports: [
|
|
702
812
|
// Components
|
|
703
813
|
InputComponent,
|
|
704
814
|
SelectComponent,
|
|
@@ -710,7 +820,8 @@ BaseComponentsModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", ve
|
|
|
710
820
|
SkeletonLoaderComponent,
|
|
711
821
|
BreadcrumbComponent,
|
|
712
822
|
ModelFormComponent,
|
|
713
|
-
ModelTableComponent
|
|
823
|
+
ModelTableComponent,
|
|
824
|
+
ModelFormSubComponent] });
|
|
714
825
|
BaseComponentsModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: BaseComponentsModule, imports: [imports] });
|
|
715
826
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: BaseComponentsModule, decorators: [{
|
|
716
827
|
type: NgModule,
|
|
@@ -729,5 +840,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImpor
|
|
|
729
840
|
* Generated bundle index. Do not edit.
|
|
730
841
|
*/
|
|
731
842
|
|
|
732
|
-
export { BaseComponentsModule, BreadcrumbComponent, CheckboxComponent, InputComponent, LoadingBarComponent, ModelFormComponent, ModelTableComponent, SelectComponent, SkeletonLoaderComponent, TagsComponent, TextareaComponent, ToastComponent };
|
|
843
|
+
export { BaseComponentsModule, BreadcrumbComponent, CheckboxComponent, InputComponent, LoadingBarComponent, ModelFormComponent, ModelFormSubComponent, ModelTableComponent, SelectComponent, SkeletonLoaderComponent, TagsComponent, TextareaComponent, ToastComponent };
|
|
733
844
|
//# sourceMappingURL=lenne.tech-ng-base-base-components.mjs.map
|