@lenne.tech/ng-base 13.14.0 → 13.15.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-routing.module.d.ts +7 -0
- package/base-cms/base-cms.module.d.ts +23 -0
- package/base-cms/interfaces/base-cms-module-config.interface.d.ts +12 -0
- package/base-cms/lenne.tech-ng-base-base-cms.d.ts +5 -0
- package/base-cms/package.json +10 -0
- package/base-cms/pages/base-cms/base-cms.component.d.ts +70 -0
- package/base-cms/public-api.d.ts +6 -0
- package/esm2020/base-cms/base-cms-routing.module.mjs +32 -0
- package/esm2020/base-cms/base-cms.module.mjs +60 -0
- package/esm2020/base-cms/interfaces/base-cms-module-config.interface.mjs +3 -0
- package/esm2020/base-cms/lenne.tech-ng-base-base-cms.mjs +5 -0
- package/esm2020/base-cms/pages/base-cms/base-cms.component.mjs +162 -0
- package/esm2020/base-cms/public-api.mjs +10 -0
- package/esm2020/base-components/components/model-form/model-form.component.mjs +4 -5
- package/esm2020/base-components/components/model-table/model-table.component.mjs +1 -1
- package/esm2020/base-components/components/tags/tags.component.mjs +2 -2
- package/esm2020/shared/classes/graphql-meta.class.mjs +3 -2
- package/fesm2015/lenne.tech-ng-base-base-cms.mjs +259 -0
- package/fesm2015/lenne.tech-ng-base-base-cms.mjs.map +1 -0
- package/fesm2015/lenne.tech-ng-base-base-components.mjs +4 -5
- package/fesm2015/lenne.tech-ng-base-base-components.mjs.map +1 -1
- package/fesm2015/lenne.tech-ng-base-shared.mjs +2 -1
- package/fesm2015/lenne.tech-ng-base-shared.mjs.map +1 -1
- package/fesm2020/lenne.tech-ng-base-base-cms.mjs +257 -0
- package/fesm2020/lenne.tech-ng-base-base-cms.mjs.map +1 -0
- package/fesm2020/lenne.tech-ng-base-base-components.mjs +4 -5
- package/fesm2020/lenne.tech-ng-base-base-components.mjs.map +1 -1
- package/fesm2020/lenne.tech-ng-base-shared.mjs +2 -1
- package/fesm2020/lenne.tech-ng-base-shared.mjs.map +1 -1
- package/package.json +9 -1
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, Component, Inject, NgModule } from '@angular/core';
|
|
3
|
+
import * as i4 from '@angular/common';
|
|
4
|
+
import { CommonModule } from '@angular/common';
|
|
5
|
+
import { ReactiveFormsModule } from '@angular/forms';
|
|
6
|
+
import * as i1 from '@lenne.tech/ng-base/shared';
|
|
7
|
+
import * as i2 from '@angular/router';
|
|
8
|
+
import { RouterModule } from '@angular/router';
|
|
9
|
+
import * as i3 from '@lenne.tech/ng-base/base-components';
|
|
10
|
+
import { BaseComponentsModule } from '@lenne.tech/ng-base/base-components';
|
|
11
|
+
|
|
12
|
+
const BASE_CMS_MODULE_CONFIG = new InjectionToken('BASE_CMS_MODULE_CONFIG');
|
|
13
|
+
|
|
14
|
+
class BaseCmsComponent {
|
|
15
|
+
constructor(moduleConfig, graphQLMetaService, route, router, authService) {
|
|
16
|
+
this.moduleConfig = moduleConfig;
|
|
17
|
+
this.graphQLMetaService = graphQLMetaService;
|
|
18
|
+
this.route = route;
|
|
19
|
+
this.router = router;
|
|
20
|
+
this.authService = authService;
|
|
21
|
+
this.types = [];
|
|
22
|
+
this.route.params.subscribe((value) => {
|
|
23
|
+
if (value['modelName']) {
|
|
24
|
+
if (!this.checkModelIsExcludedOrRestrcited(value['modelName'])) {
|
|
25
|
+
this.modelName = value['modelName'];
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
this.init().then((types) => {
|
|
29
|
+
this.router.navigate(['../' + types[0].name.toLowerCase()], { relativeTo: this.route });
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (value['id']) {
|
|
34
|
+
this.id = value['id'];
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
async ngOnInit() {
|
|
39
|
+
await this.init();
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* It returns a promise that resolves to an array of GraphqlCrudType objects
|
|
43
|
+
*
|
|
44
|
+
* @returns The types that are available to the user.
|
|
45
|
+
*/
|
|
46
|
+
init() {
|
|
47
|
+
return new Promise((resolve, reject) => {
|
|
48
|
+
this.graphQLMetaService.getMeta().subscribe((meta) => {
|
|
49
|
+
this.meta = meta;
|
|
50
|
+
if (this.route.snapshot?.params?.['modelName']) {
|
|
51
|
+
this.modelName = this.route.snapshot?.params?.['modelName'];
|
|
52
|
+
}
|
|
53
|
+
if (this.route.snapshot?.params?.['id']) {
|
|
54
|
+
this.id = this.route.snapshot?.params?.['id'];
|
|
55
|
+
}
|
|
56
|
+
const excludedModels = this.moduleConfig.excludedModels?.map((e) => e.toLowerCase());
|
|
57
|
+
const types = meta.getTypes();
|
|
58
|
+
// Check for excluded types
|
|
59
|
+
const filteredTypes = types.filter((e) => !excludedModels?.includes(e.name.toLowerCase()));
|
|
60
|
+
// Check for restricted types
|
|
61
|
+
this.types = filteredTypes.filter((e) => {
|
|
62
|
+
const foundRestrict = this.moduleConfig.restrictedModels?.find((v) => v.model.toLowerCase() === e.name.toLowerCase());
|
|
63
|
+
if (foundRestrict) {
|
|
64
|
+
if (!this.authService.currentUser) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
return this.authService.currentUser.hasAllRoles(foundRestrict.roles);
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
resolve(this.types);
|
|
74
|
+
if (!this.modelName && this.types) {
|
|
75
|
+
this.router.navigate(['./' + this.types[0].name.toLowerCase()], { relativeTo: this.route });
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}
|
|
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
|
+
/**
|
|
95
|
+
* If the model name is set and the types are set, then return the type that matches the model name
|
|
96
|
+
*
|
|
97
|
+
* @returns The type object that matches the model name.
|
|
98
|
+
*/
|
|
99
|
+
getTypeByModelName() {
|
|
100
|
+
if (this.modelName && this.types) {
|
|
101
|
+
return this.types.find((e) => e.name.toLowerCase() === this.modelName.toLowerCase());
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* When the createModeChanged event is emitted, if the createMode is true, navigate to the new route
|
|
109
|
+
*
|
|
110
|
+
* @param createMode - boolean - This is a boolean value that indicates whether the user is in create mode or
|
|
111
|
+
* not.
|
|
112
|
+
*/
|
|
113
|
+
onCreateModeChanged(createMode) {
|
|
114
|
+
if (createMode) {
|
|
115
|
+
this.router.navigate(['./' + 'new'], { relativeTo: this.route });
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* If the type exists, return the create property of the type, otherwise return false.
|
|
120
|
+
*
|
|
121
|
+
* @returns A boolean value.
|
|
122
|
+
*/
|
|
123
|
+
isCreatePossible() {
|
|
124
|
+
const type = this.getTypeByModelName();
|
|
125
|
+
return type ? type.create : false;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* If the model name is found in the type map, return the update property of the type object
|
|
129
|
+
*
|
|
130
|
+
* @returns A boolean value.
|
|
131
|
+
*/
|
|
132
|
+
isUpdatePossible() {
|
|
133
|
+
const type = this.getTypeByModelName();
|
|
134
|
+
return type ? type.update : false;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* If the type is defined, return the delete property of the type, otherwise return false
|
|
138
|
+
*
|
|
139
|
+
* @returns A boolean value.
|
|
140
|
+
*/
|
|
141
|
+
isDeletePossible() {
|
|
142
|
+
const type = this.getTypeByModelName();
|
|
143
|
+
return type ? type.delete : false;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* If the id is truthy, navigate to the id, otherwise navigate to the parent route
|
|
147
|
+
*
|
|
148
|
+
* @param id - The id of the selected item.
|
|
149
|
+
*/
|
|
150
|
+
idSelected(id) {
|
|
151
|
+
if (id) {
|
|
152
|
+
this.router.navigate(['./' + id], { relativeTo: this.route });
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
this.router.navigate(['..'], { relativeTo: this.route });
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
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' }}\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", 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", "tableFields"], 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
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: BaseCmsComponent, decorators: [{
|
|
162
|
+
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' }}\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", 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
|
+
}], ctorParameters: function () { return [{ type: undefined, decorators: [{
|
|
165
|
+
type: Inject,
|
|
166
|
+
args: [BASE_CMS_MODULE_CONFIG]
|
|
167
|
+
}] }, { type: i1.GraphQLMetaService }, { type: i2.ActivatedRoute }, { type: i2.Router }, { type: i1.AuthService }]; } });
|
|
168
|
+
|
|
169
|
+
const routes = [
|
|
170
|
+
{
|
|
171
|
+
path: '',
|
|
172
|
+
component: BaseCmsComponent,
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
path: ':modelName',
|
|
176
|
+
component: BaseCmsComponent,
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
path: ':modelName/:id',
|
|
180
|
+
component: BaseCmsComponent,
|
|
181
|
+
},
|
|
182
|
+
];
|
|
183
|
+
class BaseCMSRoutingModule {
|
|
184
|
+
}
|
|
185
|
+
BaseCMSRoutingModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: BaseCMSRoutingModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
186
|
+
BaseCMSRoutingModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: BaseCMSRoutingModule, imports: [i2.RouterModule], exports: [RouterModule] });
|
|
187
|
+
BaseCMSRoutingModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: BaseCMSRoutingModule, imports: [[RouterModule.forChild(routes)], RouterModule] });
|
|
188
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: BaseCMSRoutingModule, decorators: [{
|
|
189
|
+
type: NgModule,
|
|
190
|
+
args: [{
|
|
191
|
+
imports: [RouterModule.forChild(routes)],
|
|
192
|
+
exports: [RouterModule],
|
|
193
|
+
}]
|
|
194
|
+
}] });
|
|
195
|
+
|
|
196
|
+
function CMSConfigFactory() {
|
|
197
|
+
return {
|
|
198
|
+
tableFields: ['id', 'name', 'title', 'description', 'email', 'createdAt', 'updatedAt'],
|
|
199
|
+
excludedModels: [],
|
|
200
|
+
restrictedModels: [],
|
|
201
|
+
branding: true,
|
|
202
|
+
logging: false,
|
|
203
|
+
...BaseCMSModule.config,
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
class BaseCMSModule {
|
|
207
|
+
}
|
|
208
|
+
BaseCMSModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: BaseCMSModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
209
|
+
BaseCMSModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: BaseCMSModule, declarations: [BaseCmsComponent], imports: [
|
|
210
|
+
// Modules
|
|
211
|
+
CommonModule,
|
|
212
|
+
ReactiveFormsModule,
|
|
213
|
+
BaseCMSRoutingModule,
|
|
214
|
+
BaseComponentsModule] });
|
|
215
|
+
BaseCMSModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: BaseCMSModule, providers: [
|
|
216
|
+
{
|
|
217
|
+
provide: BASE_CMS_MODULE_CONFIG,
|
|
218
|
+
useFactory: CMSConfigFactory,
|
|
219
|
+
},
|
|
220
|
+
], imports: [[
|
|
221
|
+
// Modules
|
|
222
|
+
CommonModule,
|
|
223
|
+
ReactiveFormsModule,
|
|
224
|
+
BaseCMSRoutingModule,
|
|
225
|
+
BaseComponentsModule,
|
|
226
|
+
]] });
|
|
227
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: BaseCMSModule, decorators: [{
|
|
228
|
+
type: NgModule,
|
|
229
|
+
args: [{
|
|
230
|
+
imports: [
|
|
231
|
+
// Modules
|
|
232
|
+
CommonModule,
|
|
233
|
+
ReactiveFormsModule,
|
|
234
|
+
BaseCMSRoutingModule,
|
|
235
|
+
BaseComponentsModule,
|
|
236
|
+
],
|
|
237
|
+
declarations: [BaseCmsComponent],
|
|
238
|
+
exports: [],
|
|
239
|
+
providers: [
|
|
240
|
+
{
|
|
241
|
+
provide: BASE_CMS_MODULE_CONFIG,
|
|
242
|
+
useFactory: CMSConfigFactory,
|
|
243
|
+
},
|
|
244
|
+
],
|
|
245
|
+
}]
|
|
246
|
+
}] });
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Exports for public API
|
|
250
|
+
*/
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Generated bundle index. Do not edit.
|
|
254
|
+
*/
|
|
255
|
+
|
|
256
|
+
export { BASE_CMS_MODULE_CONFIG, BaseCMSModule, BaseCmsComponent, CMSConfigFactory };
|
|
257
|
+
//# sourceMappingURL=lenne.tech-ng-base-base-cms.mjs.map
|
|
@@ -0,0 +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 */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;;;;;MAUa,sBAAsB,GAAG,IAAI,cAAc,CAAC,wBAAwB;;MCApE,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;QACtC,IAAK,CAAA,KAAA,GAAL,KAAK,CAAgB;QACrB,IAAM,CAAA,MAAA,GAAN,MAAM,CAAQ;QACd,IAAW,CAAA,WAAA,GAAX,WAAW,CAAa;QAPlC,IAAK,CAAA,KAAA,GAAsB,EAAE,CAAC;Q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mB;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;;;;"}
|
|
@@ -242,7 +242,7 @@ class TagsComponent {
|
|
|
242
242
|
return;
|
|
243
243
|
}
|
|
244
244
|
if (tag.length > 0 && this.control.value && !this.control.value.some((item) => item === tag)) {
|
|
245
|
-
this.control.value
|
|
245
|
+
this.control.setValue([...this.control.value, tag]);
|
|
246
246
|
this.inputValue = '';
|
|
247
247
|
this.control.setErrors(null);
|
|
248
248
|
}
|
|
@@ -400,7 +400,6 @@ class ModelFormComponent {
|
|
|
400
400
|
if (this.modelName && this.meta) {
|
|
401
401
|
this.operation = this.id ? 'update' : 'create';
|
|
402
402
|
this.fields = this.meta.getArgs(this.operation + this.capitalizeFirstLetter(this.modelName), {
|
|
403
|
-
cache: false,
|
|
404
403
|
type: GraphQLRequestType.MUTATION,
|
|
405
404
|
});
|
|
406
405
|
this.fields = this.fields['input'];
|
|
@@ -442,7 +441,7 @@ class ModelFormComponent {
|
|
|
442
441
|
const group = {};
|
|
443
442
|
for (const [key, value] of Object.entries(fields)) {
|
|
444
443
|
if (fields[key]?.type) {
|
|
445
|
-
group[key] = new FormControl('', Validators.required);
|
|
444
|
+
group[key] = new FormControl('', value.isRequired ? Validators.required : []);
|
|
446
445
|
}
|
|
447
446
|
}
|
|
448
447
|
this.form = new FormGroup(group);
|
|
@@ -522,10 +521,10 @@ class ModelFormComponent {
|
|
|
522
521
|
}
|
|
523
522
|
}
|
|
524
523
|
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 });
|
|
525
|
-
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 <h1>{{ capitalizeFirstLetter(modelName) }} {{ operation === 'update' ? 'bearbeiten' : 'erstellen' }}</h1>\n\n <form [formGroup]=\"form\">\n <div class=\"mt-3\" *ngFor=\"let key of keys\">\n <ng-container [ngSwitch]=\"fields[key]?.type\">\n <ng-container *ngSwitchCase=\"'String'\">\n <ng-container *ngIf=\"fields[key]?.isList\">\n <base-tags\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"capitalizeFirstLetter(key)\"\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\">\n <base-input\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"capitalizeFirstLetter(key)\"\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]=\"capitalizeFirstLetter(key)\"\n [control]=\"transformToControl(form?.get(key))\"\n [required]=\"true\"\n ></base-checkbox>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'DateTime'\">\n <base-input\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"capitalizeFirstLetter(key)\"\n [type]=\"'datetime-local'\"\n [control]=\"transformToControl(form?.get(key))\"\n [required]=\"true\"\n ></base-input>\n </ng-container>\n </ng-container>\n </div>\n\n <div class=\"d-flex\" [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: 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.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.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
|
|
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 <h1>{{ capitalizeFirstLetter(modelName) }} {{ operation === 'update' ? 'bearbeiten' : 'erstellen' }}</h1>\n\n <form [formGroup]=\"form\">\n <div class=\"mt-3\" *ngFor=\"let key of keys\">\n <ng-container [ngSwitch]=\"fields[key]?.type\">\n <ng-container *ngSwitchCase=\"'String'\">\n <ng-container *ngIf=\"fields[key]?.isList\">\n <base-tags\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"capitalizeFirstLetter(key)\"\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\">\n <base-input\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"capitalizeFirstLetter(key)\"\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]=\"capitalizeFirstLetter(key)\"\n [control]=\"transformToControl(form?.get(key))\"\n [required]=\"true\"\n ></base-checkbox>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'DateTime'\">\n <base-input\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"capitalizeFirstLetter(key)\"\n [type]=\"'datetime-local'\"\n [control]=\"transformToControl(form?.get(key))\"\n [required]=\"true\"\n ></base-input>\n </ng-container>\n </ng-container>\n </div>\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: 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.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.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { type: i1.NgSwitch, selector: "[ngSwitch]", inputs: ["ngSwitch"] }, { type: i1.NgSwitchCase, selector: "[ngSwitchCase]", inputs: ["ngSwitchCase"] }, { type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }] });
|
|
526
525
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ModelFormComponent, decorators: [{
|
|
527
526
|
type: Component,
|
|
528
|
-
args: [{ selector: 'base-model-form', template: "<div class=\"w-100\" *ngIf=\"form\">\n <h1>{{ capitalizeFirstLetter(modelName) }} {{ operation === 'update' ? 'bearbeiten' : 'erstellen' }}</h1>\n\n <form [formGroup]=\"form\">\n <div class=\"mt-3\" *ngFor=\"let key of keys\">\n <ng-container [ngSwitch]=\"fields[key]?.type\">\n <ng-container *ngSwitchCase=\"'String'\">\n <ng-container *ngIf=\"fields[key]?.isList\">\n <base-tags\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"capitalizeFirstLetter(key)\"\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\">\n <base-input\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"capitalizeFirstLetter(key)\"\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]=\"capitalizeFirstLetter(key)\"\n [control]=\"transformToControl(form?.get(key))\"\n [required]=\"true\"\n ></base-checkbox>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'DateTime'\">\n <base-input\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"capitalizeFirstLetter(key)\"\n [type]=\"'datetime-local'\"\n [control]=\"transformToControl(form?.get(key))\"\n [required]=\"true\"\n ></base-input>\n </ng-container>\n </ng-container>\n </div>\n\n <div class=\"d-flex\" [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: [""] }]
|
|
527
|
+
args: [{ selector: 'base-model-form', template: "<div class=\"w-100\" *ngIf=\"form\">\n <h1>{{ capitalizeFirstLetter(modelName) }} {{ operation === 'update' ? 'bearbeiten' : 'erstellen' }}</h1>\n\n <form [formGroup]=\"form\">\n <div class=\"mt-3\" *ngFor=\"let key of keys\">\n <ng-container [ngSwitch]=\"fields[key]?.type\">\n <ng-container *ngSwitchCase=\"'String'\">\n <ng-container *ngIf=\"fields[key]?.isList\">\n <base-tags\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"capitalizeFirstLetter(key)\"\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\">\n <base-input\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"capitalizeFirstLetter(key)\"\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]=\"capitalizeFirstLetter(key)\"\n [control]=\"transformToControl(form?.get(key))\"\n [required]=\"true\"\n ></base-checkbox>\n </ng-container>\n\n <ng-container *ngSwitchCase=\"'DateTime'\">\n <base-input\n [id]=\"key\"\n [name]=\"key\"\n [label]=\"capitalizeFirstLetter(key)\"\n [type]=\"'datetime-local'\"\n [control]=\"transformToControl(form?.get(key))\"\n [required]=\"true\"\n ></base-input>\n </ng-container>\n </ng-container>\n </div>\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: [""] }]
|
|
529
528
|
}], ctorParameters: function () { return [{ type: i1$1.GraphQLMetaService }, { type: i1$1.GraphQLService }, { type: i1$1.FormsService }]; }, propDecorators: { modelName: [{
|
|
530
529
|
type: Input
|
|
531
530
|
}], id: [{
|