@lenne.tech/ng-base 13.29.0 → 13.30.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.
Files changed (27) hide show
  1. package/base-cms/pages/base-cms/base-cms.component.d.ts +11 -4
  2. package/base-components/components/model-form/model-form.component.d.ts +11 -3
  3. package/base-components/components/model-table/model-table.component.d.ts +2 -3
  4. package/esm2020/base-cms/pages/base-cms/base-cms.component.mjs +22 -11
  5. package/esm2020/base-components/components/model-form/model-form.component.mjs +95 -56
  6. package/esm2020/base-components/components/model-table/model-table.component.mjs +9 -6
  7. package/esm2020/base-prototype/pages/profile/profile.component.mjs +1 -1
  8. package/esm2020/shared/classes/graphql-meta.class.mjs +8 -1
  9. package/esm2020/shared/interfaces/graphql-crud-type.interface.mjs +1 -1
  10. package/fesm2015/lenne.tech-ng-base-base-cms.mjs +22 -11
  11. package/fesm2015/lenne.tech-ng-base-base-cms.mjs.map +1 -1
  12. package/fesm2015/lenne.tech-ng-base-base-components.mjs +106 -59
  13. package/fesm2015/lenne.tech-ng-base-base-components.mjs.map +1 -1
  14. package/fesm2015/lenne.tech-ng-base-base-prototype.mjs +1 -1
  15. package/fesm2015/lenne.tech-ng-base-base-prototype.mjs.map +1 -1
  16. package/fesm2015/lenne.tech-ng-base-shared.mjs +7 -0
  17. package/fesm2015/lenne.tech-ng-base-shared.mjs.map +1 -1
  18. package/fesm2020/lenne.tech-ng-base-base-cms.mjs +21 -10
  19. package/fesm2020/lenne.tech-ng-base-base-cms.mjs.map +1 -1
  20. package/fesm2020/lenne.tech-ng-base-base-components.mjs +99 -57
  21. package/fesm2020/lenne.tech-ng-base-base-components.mjs.map +1 -1
  22. package/fesm2020/lenne.tech-ng-base-base-prototype.mjs +1 -1
  23. package/fesm2020/lenne.tech-ng-base-base-prototype.mjs.map +1 -1
  24. package/fesm2020/lenne.tech-ng-base-shared.mjs +7 -0
  25. package/fesm2020/lenne.tech-ng-base-shared.mjs.map +1 -1
  26. package/package.json +1 -1
  27. package/shared/interfaces/graphql-crud-type.interface.d.ts +1 -0
@@ -5,6 +5,7 @@ import { CommonModule } from '@angular/common';
5
5
  import { ReactiveFormsModule } from '@angular/forms';
6
6
  import * as i1 from '@lenne.tech/ng-base/shared';
7
7
  import { BasicUser } from '@lenne.tech/ng-base/shared';
8
+ import { Subscription } from 'rxjs';
8
9
  import * as i2 from '@angular/router';
9
10
  import { RouterModule } from '@angular/router';
10
11
  import * as i3 from '@lenne.tech/ng-base/base-components';
@@ -20,11 +21,11 @@ class BaseCmsComponent {
20
21
  this.router = router;
21
22
  this.authService = authService;
22
23
  this.types = [];
23
- this.route.params.subscribe((value) => {
24
+ this.subscription = new Subscription();
25
+ this.subscription.add(this.route.params.subscribe((value) => {
24
26
  if (value['modelName']) {
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)) {
27
+ const exclude = this.moduleConfig.modelConfig[value['modelName']]?.exclude;
28
+ if (exclude !== null && !exclude) {
28
29
  this.modelName = value['modelName'];
29
30
  }
30
31
  else {
@@ -36,11 +37,14 @@ class BaseCmsComponent {
36
37
  if (value['id']) {
37
38
  this.id = value['id'];
38
39
  }
39
- });
40
+ }));
40
41
  }
41
42
  async ngOnInit() {
42
43
  await this.init();
43
44
  }
45
+ ngOnDestroy() {
46
+ this.subscription.unsubscribe();
47
+ }
44
48
  /**
45
49
  * It returns a promise that resolves to an array of GraphqlCrudType objects
46
50
  *
@@ -58,7 +62,7 @@ class BaseCmsComponent {
58
62
  }
59
63
  const types = meta.getTypes();
60
64
  // Check for excluded types
61
- const filteredTypes = types.filter((e) => !this.moduleConfig?.modelConfig[e.name.toLowerCase()]?.excluded);
65
+ const filteredTypes = types.filter((e) => !this.moduleConfig?.modelConfig[e.name.toLowerCase()]?.exclude);
62
66
  // Check for restricted types
63
67
  this.types = filteredTypes.filter((e) => {
64
68
  if (this.moduleConfig?.modelConfig[e.name.toLowerCase()]?.restricted) {
@@ -135,9 +139,16 @@ class BaseCmsComponent {
135
139
  return type ? type.delete : false;
136
140
  }
137
141
  /**
138
- * If the id is truthy, navigate to the id, otherwise navigate to the parent route
142
+ * If the model name is found in the type array, return the duplicate property of the type object
139
143
  *
140
- * @param id - The id of the selected item.
144
+ * @returns A boolean value.
145
+ */
146
+ isDuplicatePossible() {
147
+ const type = this.getTypeByModelName();
148
+ return type ? type.duplicate : false;
149
+ }
150
+ /**
151
+ * If the id is truthy, navigate to the id, otherwise navigate to the parent route
141
152
  */
142
153
  idSelected(id) {
143
154
  if (id) {
@@ -149,10 +160,10 @@ class BaseCmsComponent {
149
160
  }
150
161
  }
151
162
  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 });
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\n href=\"/\"\n class=\"d-flex flex-column align-items-start mb-3 mt-3 me-md-auto link-dark text-decoration-none\"\n *ngIf=\"!moduleConfig?.logoUrl\"\n >\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\n <a\n href=\"/\"\n class=\"d-flex flex-column align-items-start mb-3 mt-3 me-md-auto link-dark text-decoration-none w-100\"\n *ngIf=\"moduleConfig?.logoUrl\"\n >\n <img [src]=\"moduleConfig.logoUrl\" class=\"img-responsive w-100\" alt=\"Logo\" />\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 mb-3\">\n <base-model-table\n [config]=\"moduleConfig?.modelConfig[modelName?.toLowerCase()]\"\n [fieldConfig]=\"moduleConfig?.fieldConfig[modelName?.toLowerCase()] || {}\"\n [modelName]=\"modelName\"\n [logging]=\"moduleConfig?.logging\"\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", "logging", "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"] }] });
163
+ 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\n href=\"/\"\n class=\"d-flex flex-column align-items-start mb-3 mt-3 me-md-auto link-dark text-decoration-none\"\n *ngIf=\"!moduleConfig?.logoUrl\"\n >\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\n <a\n href=\"/\"\n class=\"d-flex flex-column align-items-start mb-3 mt-3 me-md-auto link-dark text-decoration-none w-100\"\n *ngIf=\"moduleConfig?.logoUrl\"\n >\n <img [src]=\"moduleConfig.logoUrl\" class=\"img-responsive w-100\" alt=\"Logo\" />\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 mb-3\">\n <base-model-table\n [config]=\"moduleConfig?.modelConfig[modelName?.toLowerCase()]\"\n [fieldConfig]=\"moduleConfig?.fieldConfig[modelName?.toLowerCase()] || {}\"\n [modelName]=\"modelName\"\n [logging]=\"moduleConfig?.logging\"\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 [duplicate]=\"isDuplicatePossible()\"\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", "logging", "create", "update", "delete", "duplicate", "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"] }] });
153
164
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: BaseCmsComponent, decorators: [{
154
165
  type: Component,
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\n href=\"/\"\n class=\"d-flex flex-column align-items-start mb-3 mt-3 me-md-auto link-dark text-decoration-none\"\n *ngIf=\"!moduleConfig?.logoUrl\"\n >\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\n <a\n href=\"/\"\n class=\"d-flex flex-column align-items-start mb-3 mt-3 me-md-auto link-dark text-decoration-none w-100\"\n *ngIf=\"moduleConfig?.logoUrl\"\n >\n <img [src]=\"moduleConfig.logoUrl\" class=\"img-responsive w-100\" alt=\"Logo\" />\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 mb-3\">\n <base-model-table\n [config]=\"moduleConfig?.modelConfig[modelName?.toLowerCase()]\"\n [fieldConfig]=\"moduleConfig?.fieldConfig[modelName?.toLowerCase()] || {}\"\n [modelName]=\"modelName\"\n [logging]=\"moduleConfig?.logging\"\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"] }]
166
+ 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\n href=\"/\"\n class=\"d-flex flex-column align-items-start mb-3 mt-3 me-md-auto link-dark text-decoration-none\"\n *ngIf=\"!moduleConfig?.logoUrl\"\n >\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\n <a\n href=\"/\"\n class=\"d-flex flex-column align-items-start mb-3 mt-3 me-md-auto link-dark text-decoration-none w-100\"\n *ngIf=\"moduleConfig?.logoUrl\"\n >\n <img [src]=\"moduleConfig.logoUrl\" class=\"img-responsive w-100\" alt=\"Logo\" />\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 mb-3\">\n <base-model-table\n [config]=\"moduleConfig?.modelConfig[modelName?.toLowerCase()]\"\n [fieldConfig]=\"moduleConfig?.fieldConfig[modelName?.toLowerCase()] || {}\"\n [modelName]=\"modelName\"\n [logging]=\"moduleConfig?.logging\"\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 [duplicate]=\"isDuplicatePossible()\"\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"] }]
156
167
  }], ctorParameters: function () { return [{ type: undefined, decorators: [{
157
168
  type: Inject,
158
169
  args: [BASE_CMS_MODULE_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 modelConfig?: { [key: string]: any };\n fieldConfig?: { [key: string]: any };\n logging?: boolean;\n logoUrl?: string;\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\n href=\"/\"\n class=\"d-flex flex-column align-items-start mb-3 mt-3 me-md-auto link-dark text-decoration-none\"\n *ngIf=\"!moduleConfig?.logoUrl\"\n >\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\n <a\n href=\"/\"\n class=\"d-flex flex-column align-items-start mb-3 mt-3 me-md-auto link-dark text-decoration-none w-100\"\n *ngIf=\"moduleConfig?.logoUrl\"\n >\n <img [src]=\"moduleConfig.logoUrl\" class=\"img-responsive w-100\" alt=\"Logo\" />\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 mb-3\">\n <base-model-table\n [config]=\"moduleConfig?.modelConfig[modelName?.toLowerCase()]\"\n [fieldConfig]=\"moduleConfig?.fieldConfig[modelName?.toLowerCase()] || {}\"\n [modelName]=\"modelName\"\n [logging]=\"moduleConfig?.logging\"\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 logoUrl: '',\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;QAS5B,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,KAAI;AACpC,YAAA,IAAI,KAAK,CAAC,WAAW,CAAC,EAAE;AACtB,gBAAA,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE,UAAU,CAAC;AACjF,gBAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,KAA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,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,aAAa,iBATT,gBAAgB,CAAA,EAAA,OAAA,EAAA;;QAL7B,YAAY;QACZ,mBAAmB;QACnB,oBAAoB;QACpB,oBAAoB,CAAA,EAAA,CAAA,CAAA;AAWX,aAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,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 logoUrl?: string;\n branding?: boolean;\n}\n\nexport const BASE_CMS_MODULE_CONFIG = new InjectionToken('BASE_CMS_MODULE_CONFIG');\n","import { Component, Inject, OnDestroy, 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';\nimport { Subscription } from 'rxjs';\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, OnDestroy {\n meta: GraphQLMeta;\n modelName: string;\n id: string;\n types: GraphqlCrudType[] = [];\n subscription = new Subscription();\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.subscription.add(\n this.route.params.subscribe((value) => {\n if (value['modelName']) {\n const exclude = this.moduleConfig.modelConfig[value['modelName']]?.exclude;\n\n if (exclude !== null && !exclude) {\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\n async ngOnInit() {\n await this.init();\n }\n\n ngOnDestroy() {\n this.subscription.unsubscribe();\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()]?.exclude);\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 model name is found in the type array, return the duplicate property of the type object\n *\n * @returns A boolean value.\n */\n isDuplicatePossible(): boolean {\n const type = this.getTypeByModelName();\n return type ? type.duplicate : false;\n }\n\n /**\n * If the id is truthy, navigate to the id, otherwise navigate to the parent route\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\n href=\"/\"\n class=\"d-flex flex-column align-items-start mb-3 mt-3 me-md-auto link-dark text-decoration-none\"\n *ngIf=\"!moduleConfig?.logoUrl\"\n >\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\n <a\n href=\"/\"\n class=\"d-flex flex-column align-items-start mb-3 mt-3 me-md-auto link-dark text-decoration-none w-100\"\n *ngIf=\"moduleConfig?.logoUrl\"\n >\n <img [src]=\"moduleConfig.logoUrl\" class=\"img-responsive w-100\" alt=\"Logo\" />\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 mb-3\">\n <base-model-table\n [config]=\"moduleConfig?.modelConfig[modelName?.toLowerCase()]\"\n [fieldConfig]=\"moduleConfig?.fieldConfig[modelName?.toLowerCase()] || {}\"\n [modelName]=\"modelName\"\n [logging]=\"moduleConfig?.logging\"\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 [duplicate]=\"isDuplicatePossible()\"\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 logoUrl: '',\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;;MCCpE,gBAAgB,CAAA;IAO3B,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;QARlC,IAAK,CAAA,KAAA,GAAsB,EAAE,CAAC;AAC9B,QAAA,IAAA,CAAA,YAAY,GAAG,IAAI,YAAY,EAAE,CAAC;AAShC,QAAA,IAAI,CAAC,YAAY,CAAC,GAAG,CACnB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,KAAI;AACpC,YAAA,IAAI,KAAK,CAAC,WAAW,CAAC,EAAE;AACtB,gBAAA,MAAM,OAAO,GAAG,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,EAAE,O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trigger, transition, query, style, animate } from '@angular/animations'
8
8
  import { Subscription } from 'rxjs';
9
9
  import * as i1$1 from '@lenne.tech/ng-base/shared';
10
10
  import { ToastType, GraphQLRequestType, BasicUser } from '@lenne.tech/ng-base/shared';
11
+ import * as i2$1 from '@angular/router';
11
12
  import * as i1$2 from '@angular/common/http';
12
13
 
13
14
  class InputComponent {
@@ -788,12 +789,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImpor
788
789
  }] } });
789
790
 
790
791
  class ModelFormComponent {
791
- constructor(graphQLMetaService, graphQLService, formsService, authService) {
792
+ constructor(graphQLMetaService, graphQLService, formsService, authService, router, route) {
792
793
  this.graphQLMetaService = graphQLMetaService;
793
794
  this.graphQLService = graphQLService;
794
795
  this.formsService = formsService;
795
796
  this.authService = authService;
797
+ this.router = router;
798
+ this.route = route;
796
799
  this.delete = true;
800
+ this.duplicate = false;
797
801
  this.logging = false;
798
802
  this.config = {};
799
803
  this.finished = new EventEmitter();
@@ -879,7 +883,7 @@ class ModelFormComponent {
879
883
  },
880
884
  error: (err) => {
881
885
  console.error('Error on load object', err);
882
- this.finished.emit(false);
886
+ this.finished.emit(null);
883
887
  },
884
888
  });
885
889
  }
@@ -948,7 +952,7 @@ class ModelFormComponent {
948
952
  })
949
953
  .subscribe({
950
954
  next: (value) => {
951
- this.finished.emit(true);
955
+ this.finished.emit(null);
952
956
  },
953
957
  error: (err) => {
954
958
  console.error('Error on delete object', err);
@@ -956,6 +960,33 @@ class ModelFormComponent {
956
960
  });
957
961
  }
958
962
  }
963
+ /**
964
+ * It sends a GraphQL mutation to the server to duplicate the object
965
+ */
966
+ async duplicateObject() {
967
+ if (confirm('Möchtest du das Objekt wirklich duplizieren?')) {
968
+ await this.submit(true);
969
+ this.graphQLService
970
+ .graphQl('duplicate' + this.capitalizeFirstLetter(this.modelName), {
971
+ arguments: { id: this.id },
972
+ fields: ['id'],
973
+ type: GraphQLRequestType.MUTATION,
974
+ })
975
+ .subscribe({
976
+ next: (value) => {
977
+ if (value?.id) {
978
+ this.router.navigate(['../' + value.id], { relativeTo: this.route });
979
+ }
980
+ else {
981
+ this.finished.emit(null);
982
+ }
983
+ },
984
+ error: (err) => {
985
+ console.error('Error on duplicate object', err);
986
+ },
987
+ });
988
+ }
989
+ }
959
990
  /**
960
991
  * It takes a string, capitalizes the first letter, and returns the modified string
961
992
  *
@@ -980,64 +1011,70 @@ class ModelFormComponent {
980
1011
  * @returns The id of the newly created or updated object.
981
1012
  */
982
1013
  submit(secret = false) {
983
- if (!secret) {
984
- this.loading = true;
985
- }
986
- if (this.form.invalid && !secret) {
987
- this.formsService.validateAllFormFields(this.form);
988
- this.loading = false;
989
- return;
990
- }
991
- if (this.operation === 'update' && !this.id) {
992
- console.error('ID is missing for update!');
993
- this.loading = false;
994
- return;
995
- }
996
- if (this.logging) {
997
- console.log('ModelFormComponent::submit->formValue', this.form.value);
998
- }
999
- const data = Object.assign({}, this.form.value);
1000
- for (const [key, value] of Object.entries(data)) {
1001
- if ((this.config[key]?.roles ? !this.user.hasAllRoles(this.config[key]?.roles) : false) ||
1002
- this.config[key]?.exclude) {
1003
- delete data[key];
1014
+ return new Promise((resolve, reject) => {
1015
+ if (!secret) {
1016
+ this.loading = true;
1004
1017
  }
1005
- // Set type for graphql method
1006
- if (this.fields[key]?.type === 'Float') {
1007
- data[key] = Number(value);
1018
+ if (this.form.invalid && !secret) {
1019
+ this.formsService.validateAllFormFields(this.form);
1020
+ this.loading = false;
1021
+ reject();
1022
+ return;
1008
1023
  }
1009
- }
1010
- if (this.logging) {
1011
- console.log('ModelFormComponent::submit->valueToGraphql', data);
1012
- }
1013
- this.graphQLService
1014
- .graphQl(this.operation + this.capitalizeFirstLetter(this.modelName), {
1015
- arguments: this.operation === 'update' ? { id: this.id, input: data } : { input: data },
1016
- fields: ['id'],
1017
- type: GraphQLRequestType.MUTATION,
1018
- })
1019
- .subscribe({
1020
- next: (value) => {
1021
- if (!secret) {
1022
- this.loading = false;
1023
- this.finished.emit(true);
1024
+ if (this.operation === 'update' && !this.id) {
1025
+ console.error('ID is missing for update!');
1026
+ this.loading = false;
1027
+ reject();
1028
+ return;
1029
+ }
1030
+ if (this.logging) {
1031
+ console.log('ModelFormComponent::submit->formValue', this.form.value);
1032
+ }
1033
+ const data = Object.assign({}, this.form.value);
1034
+ for (const [key, value] of Object.entries(data)) {
1035
+ if ((this.config[key]?.roles ? !this.user.hasAllRoles(this.config[key]?.roles) : false) ||
1036
+ this.config[key]?.exclude) {
1037
+ delete data[key];
1024
1038
  }
1025
- },
1026
- error: (err) => {
1027
- if (!secret) {
1028
- console.error('Failed on ' + this.operation, err);
1029
- this.loading = false;
1039
+ // Set type for graphql method
1040
+ if (this.fields[key]?.type === 'Float') {
1041
+ data[key] = Number(value);
1030
1042
  }
1031
- },
1043
+ }
1044
+ if (this.logging) {
1045
+ console.log('ModelFormComponent::submit->valueToGraphql', data);
1046
+ }
1047
+ this.graphQLService
1048
+ .graphQl(this.operation + this.capitalizeFirstLetter(this.modelName), {
1049
+ arguments: this.operation === 'update' ? { id: this.id, input: data } : { input: data },
1050
+ fields: ['id'],
1051
+ type: GraphQLRequestType.MUTATION,
1052
+ })
1053
+ .subscribe({
1054
+ next: (value) => {
1055
+ if (!secret) {
1056
+ this.loading = false;
1057
+ this.finished.emit(null);
1058
+ }
1059
+ resolve(value);
1060
+ },
1061
+ error: (err) => {
1062
+ if (!secret) {
1063
+ console.error('Failed on ' + this.operation, err);
1064
+ this.loading = false;
1065
+ }
1066
+ reject();
1067
+ },
1068
+ });
1032
1069
  });
1033
1070
  }
1034
1071
  }
1035
- 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 }, { token: i1$1.AuthService }], target: i0.ɵɵFactoryTarget.Component });
1036
- 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\n [fields]=\"fields\"\n [config]=\"config\"\n [form]=\"form\"\n (imageChanged)=\"id ? submit(true) : null\"\n ></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(false)\" *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"], outputs: ["imageChanged"] }], 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"] }] });
1072
+ 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 }, { token: i1$1.AuthService }, { token: i2$1.Router }, { token: i2$1.ActivatedRoute }], target: i0.ɵɵFactoryTarget.Component });
1073
+ 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", duplicate: "duplicate", logging: "logging", config: "config" }, outputs: { finished: "finished" }, usesOnChanges: true, ngImport: i0, template: "<div class=\"w-100\" *ngIf=\"form\">\n <div class=\"d-flex flex-row justify-content-between mt-3\">\n <h2>\n {{ label ? label : capitalizeFirstLetter(modelName) }} {{ operation === 'update' ? 'bearbeiten' : 'erstellen' }}\n </h2>\n\n <div>\n <button class=\"btn btn-outline-primary me-2\" *ngIf=\"id && duplicate && !loading\" (click)=\"duplicateObject()\">\n Duplizieren\n </button>\n <button class=\"btn btn-primary\" type=\"button\" (click)=\"submit(false)\" *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\n <form [formGroup]=\"form\">\n <base-model-form-sub\n [fields]=\"fields\"\n [config]=\"config\"\n [form]=\"form\"\n (imageChanged)=\"id ? submit(true) : null\"\n ></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(false)\" *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"], outputs: ["imageChanged"] }], 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"] }] });
1037
1074
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ModelFormComponent, decorators: [{
1038
1075
  type: Component,
1039
- 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\n [fields]=\"fields\"\n [config]=\"config\"\n [form]=\"form\"\n (imageChanged)=\"id ? submit(true) : null\"\n ></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(false)\" *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: [""] }]
1040
- }], ctorParameters: function () { return [{ type: i1$1.GraphQLMetaService }, { type: i1$1.GraphQLService }, { type: i1$1.FormsService }, { type: i1$1.AuthService }]; }, propDecorators: { modelName: [{
1076
+ args: [{ selector: 'base-model-form', template: "<div class=\"w-100\" *ngIf=\"form\">\n <div class=\"d-flex flex-row justify-content-between mt-3\">\n <h2>\n {{ label ? label : capitalizeFirstLetter(modelName) }} {{ operation === 'update' ? 'bearbeiten' : 'erstellen' }}\n </h2>\n\n <div>\n <button class=\"btn btn-outline-primary me-2\" *ngIf=\"id && duplicate && !loading\" (click)=\"duplicateObject()\">\n Duplizieren\n </button>\n <button class=\"btn btn-primary\" type=\"button\" (click)=\"submit(false)\" *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\n <form [formGroup]=\"form\">\n <base-model-form-sub\n [fields]=\"fields\"\n [config]=\"config\"\n [form]=\"form\"\n (imageChanged)=\"id ? submit(true) : null\"\n ></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(false)\" *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: [""] }]
1077
+ }], ctorParameters: function () { return [{ type: i1$1.GraphQLMetaService }, { type: i1$1.GraphQLService }, { type: i1$1.FormsService }, { type: i1$1.AuthService }, { type: i2$1.Router }, { type: i2$1.ActivatedRoute }]; }, propDecorators: { modelName: [{
1041
1078
  type: Input
1042
1079
  }], label: [{
1043
1080
  type: Input
@@ -1045,6 +1082,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImpor
1045
1082
  type: Input
1046
1083
  }], delete: [{
1047
1084
  type: Input
1085
+ }], duplicate: [{
1086
+ type: Input
1048
1087
  }], logging: [{
1049
1088
  type: Input
1050
1089
  }], config: [{
@@ -1062,6 +1101,7 @@ class ModelTableComponent {
1062
1101
  this.create = true;
1063
1102
  this.update = true;
1064
1103
  this.delete = true;
1104
+ this.duplicate = true;
1065
1105
  this.config = {};
1066
1106
  this.fieldConfig = {};
1067
1107
  this.idSelected = new EventEmitter();
@@ -1160,7 +1200,9 @@ class ModelTableComponent {
1160
1200
  if (this.logging) {
1161
1201
  console.log('ModelTableComponent::loadObjects->value', value);
1162
1202
  }
1163
- this.objects = value;
1203
+ const arrayForSort = [...value];
1204
+ this.objects = arrayForSort.sort((a, b) => (b?.createdAt ? new Date(b?.createdAt)?.getTime() : new Date().getTime()) -
1205
+ (a?.createdAt ? new Date(a?.createdAt)?.getTime() : new Date().getTime()));
1164
1206
  },
1165
1207
  error: (err) => {
1166
1208
  console.log('Error on loading objects', err);
@@ -1170,8 +1212,6 @@ class ModelTableComponent {
1170
1212
  /**
1171
1213
  * If the update property is true, then set the selectedId property to the id of the object passed in, and emit the
1172
1214
  * selectedId property
1173
- *
1174
- * @param object - any - this is the object that is passed in from the child component.
1175
1215
  */
1176
1216
  selectId(object) {
1177
1217
  if (!object) {
@@ -1194,10 +1234,10 @@ class ModelTableComponent {
1194
1234
  }
1195
1235
  }
1196
1236
  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 });
1197
- 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", logging: "logging", 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\">\n {{ tableFields[field]?.label ? tableFields[field]?.label : capitalizeFirstLetter(field) }}\n </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 <ng-container *ngIf=\"tableFields[field]?.dateFormat\">\n {{ object[field] | date: tableFields[field]?.dateFormat }} Uhr\n </ng-container>\n\n <ng-container *ngIf=\"!tableFields[field]?.dateFormat\">\n {{ object[field] }}\n </ng-container>\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]=\"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"] }], pipes: { "date": i1.DatePipe } });
1237
+ 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", logging: "logging", create: "create", update: "update", delete: "delete", duplicate: "duplicate", 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\">\n {{ tableFields[field]?.label ? tableFields[field]?.label : capitalizeFirstLetter(field) }}\n </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 <ng-container *ngIf=\"tableFields[field]?.dateFormat\">\n {{ object[field] | date: tableFields[field]?.dateFormat }} Uhr\n </ng-container>\n\n <ng-container *ngIf=\"!tableFields[field]?.dateFormat\">\n {{ object[field] }}\n </ng-container>\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]=\"logging\"\n [id]=\"selectedId\"\n (finished)=\"selectId('')\"\n [delete]=\"delete\"\n [duplicate]=\"duplicate\"\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", "duplicate", "logging", "config"], outputs: ["finished"] }], directives: [{ type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], pipes: { "date": i1.DatePipe } });
1198
1238
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImport: i0, type: ModelTableComponent, decorators: [{
1199
1239
  type: Component,
1200
- 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\">\n {{ tableFields[field]?.label ? tableFields[field]?.label : capitalizeFirstLetter(field) }}\n </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 <ng-container *ngIf=\"tableFields[field]?.dateFormat\">\n {{ object[field] | date: tableFields[field]?.dateFormat }} Uhr\n </ng-container>\n\n <ng-container *ngIf=\"!tableFields[field]?.dateFormat\">\n {{ object[field] }}\n </ng-container>\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]=\"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"] }]
1240
+ 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\">\n {{ tableFields[field]?.label ? tableFields[field]?.label : capitalizeFirstLetter(field) }}\n </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 <ng-container *ngIf=\"tableFields[field]?.dateFormat\">\n {{ object[field] | date: tableFields[field]?.dateFormat }} Uhr\n </ng-container>\n\n <ng-container *ngIf=\"!tableFields[field]?.dateFormat\">\n {{ object[field] }}\n </ng-container>\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]=\"logging\"\n [id]=\"selectedId\"\n (finished)=\"selectId('')\"\n [delete]=\"delete\"\n [duplicate]=\"duplicate\"\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"] }]
1201
1241
  }], ctorParameters: function () { return [{ type: i1$1.GraphQLMetaService }, { type: i1$1.GraphQLService }]; }, propDecorators: { modelName: [{
1202
1242
  type: Input
1203
1243
  }], objectId: [{
@@ -1212,6 +1252,8 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.3", ngImpor
1212
1252
  type: Input
1213
1253
  }], delete: [{
1214
1254
  type: Input
1255
+ }], duplicate: [{
1256
+ type: Input
1215
1257
  }], config: [{
1216
1258
  type: Input
1217
1259
  }], fieldConfig: [{