@lenne.tech/ng-base 14.0.4 → 14.1.1

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 (52) hide show
  1. package/base-components/base-components.module.d.ts +20 -17
  2. package/base-components/components/model-form/model-form.component.d.ts +9 -4
  3. package/base-components/components/model-form-sub/model-form-sub.component.d.ts +7 -3
  4. package/base-components/components/model-table/model-table.component.d.ts +14 -5
  5. package/base-components/components/refence-input/refence-input.component.d.ts +10 -4
  6. package/{shared → base-components}/directives/back-button.directive.d.ts +1 -1
  7. package/{src → base-components}/directives/context-menu.directive.d.ts +0 -0
  8. package/{shared → base-components}/directives/sort.directive.d.ts +2 -2
  9. package/base-components/public-api.d.ts +3 -0
  10. package/esm2020/base-components/base-components.module.mjs +16 -1
  11. package/esm2020/base-components/components/model-form/model-form.component.mjs +87 -58
  12. package/esm2020/base-components/components/model-form-sub/model-form-sub.component.mjs +9 -3
  13. package/esm2020/base-components/components/model-table/model-table.component.mjs +30 -13
  14. package/esm2020/base-components/components/refence-input/refence-input.component.mjs +28 -22
  15. package/esm2020/base-components/components/tags/tags.component.mjs +2 -2
  16. package/esm2020/base-components/components/upload-image/upload-image.component.mjs +3 -3
  17. package/esm2020/{shared → base-components}/directives/back-button.directive.mjs +2 -2
  18. package/esm2020/base-components/directives/context-menu.directive.mjs +108 -0
  19. package/esm2020/base-components/directives/sort.directive.mjs +54 -0
  20. package/esm2020/base-components/public-api.mjs +5 -1
  21. package/esm2020/public-api.mjs +1 -2
  22. package/esm2020/shared/classes/graphql-meta.class.mjs +52 -28
  23. package/esm2020/shared/classes/graphql-type.class.mjs +2 -1
  24. package/esm2020/shared/classes/sort.class.mjs +1 -8
  25. package/esm2020/shared/public-api.mjs +2 -4
  26. package/esm2020/shared/services/auth.service.mjs +7 -1
  27. package/esm2020/shared/services/cms.service.mjs +75 -0
  28. package/esm2020/shared/services/graphql.service.mjs +30 -36
  29. package/esm2020/src/base.module.mjs +1 -5
  30. package/fesm2015/lenne.tech-ng-base-base-components.mjs +361 -112
  31. package/fesm2015/lenne.tech-ng-base-base-components.mjs.map +1 -1
  32. package/fesm2015/lenne.tech-ng-base-shared.mjs +209 -190
  33. package/fesm2015/lenne.tech-ng-base-shared.mjs.map +1 -1
  34. package/fesm2015/lenne.tech-ng-base.mjs +2 -113
  35. package/fesm2015/lenne.tech-ng-base.mjs.map +1 -1
  36. package/fesm2020/lenne.tech-ng-base-base-components.mjs +340 -97
  37. package/fesm2020/lenne.tech-ng-base-base-components.mjs.map +1 -1
  38. package/fesm2020/lenne.tech-ng-base-shared.mjs +207 -188
  39. package/fesm2020/lenne.tech-ng-base-shared.mjs.map +1 -1
  40. package/fesm2020/lenne.tech-ng-base.mjs +2 -112
  41. package/fesm2020/lenne.tech-ng-base.mjs.map +1 -1
  42. package/package.json +1 -1
  43. package/public-api.d.ts +0 -1
  44. package/shared/classes/graphql-meta.class.d.ts +7 -4
  45. package/shared/classes/graphql-type.class.d.ts +1 -0
  46. package/shared/classes/sort.class.d.ts +0 -7
  47. package/shared/public-api.d.ts +1 -2
  48. package/shared/services/cms.service.d.ts +23 -0
  49. package/shared/services/graphql.service.d.ts +4 -4
  50. package/src/base.module.d.ts +9 -10
  51. package/esm2020/shared/directives/sort.directive.mjs +0 -54
  52. package/esm2020/src/directives/context-menu.directive.mjs +0 -109
@@ -1,17 +1,15 @@
1
- import { GraphQLInputObjectType, GraphQLNonNull, GraphQLList, buildClientSchema, getIntrospectionQuery } from 'graphql';
2
- import { cloneDeep } from '@apollo/client/utilities';
1
+ import { GraphQLInputObjectType, GraphQLScalarType, GraphQLEnumType, GraphQLNonNull, GraphQLList, buildClientSchema, getIntrospectionQuery } from 'graphql';
3
2
  import * as i0 from '@angular/core';
4
- import { Directive, Inject, Input, HostListener, Injectable, InjectionToken } from '@angular/core';
5
- import * as i2 from '@angular/common';
6
- import { DOCUMENT } from '@angular/common';
7
- import * as i1 from '@angular/router';
8
- import { NavigationEnd } from '@angular/router';
3
+ import { InjectionToken, Injectable, Inject } from '@angular/core';
9
4
  import { BehaviorSubject, of, throwError, Observable, map as map$1, filter } from 'rxjs';
10
- import * as i1$1 from 'apollo-angular';
5
+ import * as i1 from 'apollo-angular';
11
6
  import { gql } from 'apollo-angular';
12
7
  import { sha256 } from 'js-sha256';
13
8
  import { map } from 'rxjs/operators';
14
9
  import { UntypedFormControl, UntypedFormGroup } from '@angular/forms';
10
+ import * as i1$1 from '@angular/router';
11
+ import { NavigationEnd } from '@angular/router';
12
+ import * as i2 from '@angular/common';
15
13
  import { createClient } from 'graphql-ws';
16
14
 
17
15
  /**
@@ -423,6 +421,7 @@ class GraphQLType extends Standard {
423
421
  constructor() {
424
422
  super(...arguments);
425
423
  this.type = '';
424
+ this.fields = {};
426
425
  this.isRequired = false;
427
426
  this.isItemRequired = false;
428
427
  this.isList = false;
@@ -515,10 +514,10 @@ class GraphQLMeta {
515
514
  }
516
515
  }
517
516
  const func = this.getFunction(functionName, { type });
518
- const result = {};
517
+ const result = new GraphQLType();
519
518
  if (func?.args) {
520
519
  func.args.forEach((item) => {
521
- result[item.name] = this.getDeepType(item.type);
520
+ result.fields[item.name] = this.getDeepType(item.type);
522
521
  });
523
522
  }
524
523
  // Set cache
@@ -591,21 +590,47 @@ class GraphQLMeta {
591
590
  getType(name) {
592
591
  return this.schema.getType(name);
593
592
  }
593
+ /**
594
+ * Get (deep) type name
595
+ */
596
+ getTypeName(type) {
597
+ if (type instanceof GraphQLInputObjectType ||
598
+ type instanceof GraphQLScalarType ||
599
+ type instanceof GraphQLEnumType) {
600
+ return type.name;
601
+ }
602
+ else if (type.type) {
603
+ return this.getTypeName(type.type);
604
+ }
605
+ else if (type.ofType) {
606
+ return this.getTypeName(type.ofType);
607
+ }
608
+ else {
609
+ return type.name;
610
+ }
611
+ }
594
612
  /**
595
613
  * Get deep type data
596
614
  */
597
- getDeepType(type, prepared = new WeakMap(), setMetaData = false) {
615
+ getDeepType(type, prepared = {}, setMetaData = false) {
598
616
  // Check type
599
617
  if (!type) {
600
618
  return type;
601
619
  }
602
620
  // Infinite regress protection
603
- const preparedObject = {};
621
+ const typeName = this.getTypeName(type);
622
+ const graphQLType = GraphQLType.map({
623
+ type: this.getTypeName(type),
624
+ });
604
625
  // Check prepared
605
626
  if (typeof type === 'object') {
606
- const preparedType = prepared.get(type);
627
+ const preparedType = prepared[typeName];
628
+ // Work with cached type
607
629
  if (preparedType) {
608
- const clone = cloneDeep(preparedType);
630
+ // Create a new object to protect own isXXX information
631
+ const clone = Object.assign({}, preparedType);
632
+ // But use fields as reference to get future changes via prepared caching
633
+ clone.fields = preparedType.fields;
609
634
  // Disable meta flags for sub objects
610
635
  if (type?.type instanceof GraphQLInputObjectType ||
611
636
  (type?.type instanceof GraphQLNonNull && type?.type?.ofType instanceof GraphQLInputObjectType && setMetaData)) {
@@ -639,25 +664,29 @@ class GraphQLMeta {
639
664
  }
640
665
  return clone;
641
666
  }
642
- // Set prepared
643
- prepared.set(type, preparedObject);
667
+ // Set prepared cache for GraphQL types
668
+ // (type names start with uppercase letters as opposed to property names that start with lowercase letters)
669
+ if (type.name && type.name[0].toUpperCase() === type.name[0] && !prepared[type.name]) {
670
+ prepared[type.name] = graphQLType;
671
+ }
644
672
  }
645
673
  // Search deeper
646
674
  if (type.ofType) {
647
675
  const ofTypeResult = this.getDeepType(type.ofType, prepared, setMetaData);
648
- Object.assign(preparedObject, ofTypeResult);
649
- return ofTypeResult;
676
+ Object.assign(graphQLType, ofTypeResult);
677
+ return graphQLType;
650
678
  }
651
679
  // Process fields
652
680
  if (type._fields) {
653
- const result = {};
681
+ const fields = {};
654
682
  for (const [key, value] of Object.entries(type._fields)) {
655
- result[key] = this.getDeepType(value, prepared, true);
683
+ fields[key] = this.getDeepType(value, prepared, true);
656
684
  }
657
- Object.assign(preparedObject, result);
658
- return result;
685
+ // Assign and not replace to preserve updates in the cache
686
+ Object.assign(graphQLType.fields, fields);
687
+ return graphQLType;
659
688
  }
660
- // Get type name
689
+ // Process type
661
690
  if (type.type) {
662
691
  const typeResult = this.getDeepType(type.type, prepared, setMetaData);
663
692
  // Disable meta flags for sub objects
@@ -691,25 +720,20 @@ class GraphQLMeta {
691
720
  }
692
721
  }
693
722
  }
694
- Object.assign(preparedObject, typeResult);
695
- return typeResult;
723
+ Object.assign(graphQLType, typeResult);
724
+ return graphQLType;
696
725
  }
697
- // Initialize GraphQLType
698
- const graphqlType = GraphQLType.map({
699
- type: type.name,
700
- });
701
726
  // Set enum values
702
727
  if (!!type._values) {
703
- graphqlType.isEnum = true;
728
+ graphQLType.isEnum = true;
704
729
  for (const [key, value] of Object.entries(type._nameLookup)) {
705
730
  if (!value.isDeprecated) {
706
- graphqlType.validEnums.push(key);
731
+ graphQLType.validEnums.push(key);
707
732
  }
708
733
  }
709
734
  }
710
735
  // Finish
711
- prepared.set(type, graphqlType);
712
- return graphqlType;
736
+ return graphQLType;
713
737
  }
714
738
  }
715
739
 
@@ -733,10 +757,6 @@ class Sort {
733
757
  }
734
758
  /**
735
759
  * Sorts clicked column
736
- *
737
- * @param property
738
- * @param order
739
- * @param type
740
760
  */
741
761
  startSort(property, order, type = '') {
742
762
  if (order === 'desc') {
@@ -756,9 +776,6 @@ class Sort {
756
776
  }
757
777
  /**
758
778
  * Sorts dates
759
- *
760
- * @param a
761
- * @param b
762
779
  */
763
780
  sortDate(a, b) {
764
781
  if (a < b) {
@@ -773,107 +790,6 @@ class Sort {
773
790
  }
774
791
  }
775
792
 
776
- class SortDirective {
777
- constructor(renderer, targetElem, document) {
778
- this.renderer = renderer;
779
- this.targetElem = targetElem;
780
- }
781
- /**
782
- * Sorts columns on click
783
- */
784
- sortColumn() {
785
- const items = document.getElementsByTagName('th');
786
- for (let i = 0; i < items.length; i++) {
787
- items[i].classList.remove('asc');
788
- items[i].classList.remove('desc');
789
- }
790
- const sort = new Sort();
791
- const elem = this.targetElem.nativeElement;
792
- const order = elem.getAttribute('data-order');
793
- const type = elem.getAttribute('data-type');
794
- const property = elem.getAttribute('data-name');
795
- if (order === 'desc') {
796
- this.lcSort.sort(sort.startSort(property, order, type));
797
- elem.setAttribute('data-order', 'asc');
798
- elem.classList.remove('desc');
799
- elem.classList.add('asc');
800
- }
801
- else {
802
- this.lcSort.sort(sort.startSort(property, order, type));
803
- elem.setAttribute('data-order', 'desc');
804
- elem.classList.remove('asc');
805
- elem.classList.add('desc');
806
- }
807
- }
808
- }
809
- SortDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: SortDirective, deps: [{ token: i0.Renderer2 }, { token: i0.ElementRef }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Directive });
810
- SortDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0", type: SortDirective, selector: "[baseSort]", inputs: { lcSort: "lcSort" }, host: { listeners: { "click": "sortColumn()" } }, ngImport: i0 });
811
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: SortDirective, decorators: [{
812
- type: Directive,
813
- args: [{
814
- selector: '[baseSort]',
815
- }]
816
- }], ctorParameters: function () { return [{ type: i0.Renderer2 }, { type: i0.ElementRef }, { type: Document, decorators: [{
817
- type: Inject,
818
- args: [DOCUMENT]
819
- }] }]; }, propDecorators: { lcSort: [{
820
- type: Input
821
- }], sortColumn: [{
822
- type: HostListener,
823
- args: ['click']
824
- }] } });
825
-
826
- class NavigationService {
827
- constructor(router, location) {
828
- this.router = router;
829
- this.location = location;
830
- this.history = [];
831
- this.router.events.subscribe((event) => {
832
- if (event instanceof NavigationEnd) {
833
- this.history.push(event.urlAfterRedirects);
834
- }
835
- });
836
- }
837
- /**
838
- * If the history stack is empty, navigate to the home page, otherwise go back to the previous page
839
- */
840
- back() {
841
- this.history.pop();
842
- if (this.history.length > 0) {
843
- this.location.back();
844
- }
845
- else {
846
- this.router.navigateByUrl('/');
847
- }
848
- }
849
- }
850
- NavigationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: NavigationService, deps: [{ token: i1.Router }, { token: i2.Location }], target: i0.ɵɵFactoryTarget.Injectable });
851
- NavigationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: NavigationService, providedIn: 'root' });
852
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: NavigationService, decorators: [{
853
- type: Injectable,
854
- args: [{ providedIn: 'root' }]
855
- }], ctorParameters: function () { return [{ type: i1.Router }, { type: i2.Location }]; } });
856
-
857
- class BackButtonDirective {
858
- constructor(navigation) {
859
- this.navigation = navigation;
860
- }
861
- onClick() {
862
- this.navigation.back();
863
- }
864
- }
865
- BackButtonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: BackButtonDirective, deps: [{ token: NavigationService }], target: i0.ɵɵFactoryTarget.Directive });
866
- BackButtonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0", type: BackButtonDirective, selector: "[baseBackButton]", host: { listeners: { "click": "onClick()" } }, ngImport: i0 });
867
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: BackButtonDirective, decorators: [{
868
- type: Directive,
869
- args: [{
870
- selector: '[baseBackButton]',
871
- }]
872
- }], ctorParameters: function () { return [{ type: NavigationService }]; }, propDecorators: { onClick: [{
873
- type: HostListener,
874
- args: ['click']
875
- }] } });
876
-
877
793
  function debounce(delay = 300) {
878
794
  return function (target, propertyKey, descriptor) {
879
795
  let timeout = null;
@@ -1060,6 +976,9 @@ class AuthService {
1060
976
  // Current User
1061
977
  // #################################################################
1062
978
  get currentUser() {
979
+ if (!localStorage) {
980
+ return undefined;
981
+ }
1063
982
  return this._currentUser.value;
1064
983
  }
1065
984
  set currentUser(user) {
@@ -1073,6 +992,9 @@ class AuthService {
1073
992
  // Token
1074
993
  // #################################################################
1075
994
  get token() {
995
+ if (!localStorage) {
996
+ return undefined;
997
+ }
1076
998
  return this._token.value;
1077
999
  }
1078
1000
  set token(token) {
@@ -1211,14 +1133,14 @@ class GraphQLMetaService {
1211
1133
  return observable;
1212
1134
  }
1213
1135
  }
1214
- GraphQLMetaService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLMetaService, deps: [{ token: i1$1.Apollo }], target: i0.ɵɵFactoryTarget.Injectable });
1136
+ GraphQLMetaService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLMetaService, deps: [{ token: i1.Apollo }], target: i0.ɵɵFactoryTarget.Injectable });
1215
1137
  GraphQLMetaService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLMetaService, providedIn: 'root' });
1216
1138
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLMetaService, decorators: [{
1217
1139
  type: Injectable,
1218
1140
  args: [{
1219
1141
  providedIn: 'root',
1220
1142
  }]
1221
- }], ctorParameters: function () { return [{ type: i1$1.Apollo }]; } });
1143
+ }], ctorParameters: function () { return [{ type: i1.Apollo }]; } });
1222
1144
 
1223
1145
  /**
1224
1146
  * GraphQL service
@@ -1285,7 +1207,7 @@ class GraphQLService {
1285
1207
  fieldsData.usedFields.sort();
1286
1208
  fieldsData.schemaFields.sort();
1287
1209
  const filtered = fieldsData.schemaFields.filter((field) => !fieldsData.usedFields.includes(field));
1288
- const unused = this.graphQLTypeCollectionToStringArray(allowedFields).filter((field) => !fieldsData.usedFields.includes(field));
1210
+ const unused = this.graphQLTypeToStringArray(allowedFields).filter((field) => !fieldsData.usedFields.includes(field));
1289
1211
  console.log({ fieldsData, filtered, unused });
1290
1212
  }
1291
1213
  fields = fieldsData.fieldsString;
@@ -1311,7 +1233,7 @@ class GraphQLService {
1311
1233
  argsData.usedArgs.sort();
1312
1234
  argsData.schemaArgs.sort();
1313
1235
  const filtered = argsData.schemaArgs.filter((field) => !argsData.usedArgs.includes(field));
1314
- const unused = this.graphQLTypeCollectionToStringArray(allowedArgs)
1236
+ const unused = this.graphQLTypeToStringArray(allowedArgs)
1315
1237
  .sort()
1316
1238
  .filter((field) => !argsData.usedArgs.includes(field));
1317
1239
  console.log({ argsData, filtered, unused });
@@ -1378,25 +1300,21 @@ class GraphQLService {
1378
1300
  /**
1379
1301
  * Get fields / args from IGraphQLTypeCollection
1380
1302
  */
1381
- graphQLTypeCollectionToStringArray(collection, current = '', result = [], cacheNode = []) {
1382
- if (collection) {
1383
- if (collection instanceof GraphQLType) {
1384
- result.push(current);
1385
- }
1386
- else {
1387
- if (current?.includes('.')) {
1388
- cacheNode.push(current.split('.')[1]);
1389
- }
1390
- else if (current) {
1391
- cacheNode.push(current);
1392
- }
1393
- for (const key of Object.keys(collection)) {
1394
- if (current === key || cacheNode.includes(key)) {
1395
- continue;
1396
- }
1397
- this.graphQLTypeCollectionToStringArray(collection[key], current ? current + '.' + key : key, result, cacheNode);
1398
- }
1303
+ graphQLTypeToStringArray(graphQLType, current = '', result = [], cacheNode = []) {
1304
+ if (!graphQLType) {
1305
+ return result;
1306
+ }
1307
+ if (current?.includes('.')) {
1308
+ cacheNode.push(current.split('.')[1]);
1309
+ }
1310
+ else if (current) {
1311
+ cacheNode.push(current);
1312
+ }
1313
+ for (const key of Object.keys(graphQLType.fields)) {
1314
+ if (current === key || cacheNode.includes(key)) {
1315
+ continue;
1399
1316
  }
1317
+ this.graphQLTypeToStringArray(graphQLType.fields[key], current ? current + '.' + key : key, result, cacheNode);
1400
1318
  }
1401
1319
  return result;
1402
1320
  }
@@ -1421,18 +1339,18 @@ class GraphQLService {
1421
1339
  const result = [];
1422
1340
  // Process array
1423
1341
  if (Array.isArray(args)) {
1424
- const allowedKeys = allowed ? Object.keys(allowed) : null;
1342
+ const allowedKeys = allowed ? Object.keys(allowed.fields) : null;
1425
1343
  for (const item of args) {
1426
1344
  let key = null;
1427
1345
  if (allowed) {
1428
- if (allowed.length < 1) {
1346
+ if (!allowedKeys || allowedKeys.length < 1) {
1429
1347
  break;
1430
1348
  }
1431
- key = allowedKeys?.shift();
1349
+ key = allowedKeys.shift();
1432
1350
  }
1433
1351
  // Process value
1434
1352
  result.push(this.prepareArguments(item, {
1435
- allowed: key ? allowed[key] : null,
1353
+ allowed: key ? allowed.fields[key] : null,
1436
1354
  level: level + 1,
1437
1355
  parent: parent + key + '.',
1438
1356
  schemaArgs,
@@ -1464,7 +1382,7 @@ class GraphQLService {
1464
1382
  schemaArgs.push(currentKey);
1465
1383
  // If the allowed key handling is enabled and the current key is not included in the list of allowed keys,
1466
1384
  // the current key will be skipped
1467
- if (allowed && !allowed[key]) {
1385
+ if (allowed && !allowed.fields[key]) {
1468
1386
  continue;
1469
1387
  }
1470
1388
  // Skip value if not exists
@@ -1487,7 +1405,7 @@ class GraphQLService {
1487
1405
  result.push(key +
1488
1406
  ': [' +
1489
1407
  value.map((item) => this.prepareArguments(item, {
1490
- allowed: allowed[key],
1408
+ allowed: allowed.fields[key],
1491
1409
  level: level + 1,
1492
1410
  parent: currentKey + '.',
1493
1411
  schemaArgs,
@@ -1505,7 +1423,7 @@ class GraphQLService {
1505
1423
  // Value is a string
1506
1424
  else if (typeof value === 'string') {
1507
1425
  // Enum (doesn't need quotation marks)
1508
- if (allowed[key].isEnum) {
1426
+ if (allowed.fields[key].isEnum) {
1509
1427
  additionalResult += value;
1510
1428
  }
1511
1429
  // String
@@ -1520,7 +1438,7 @@ class GraphQLService {
1520
1438
  // Others
1521
1439
  else {
1522
1440
  additionalResult += this.prepareArguments(value, {
1523
- allowed: allowed[key],
1441
+ allowed: allowed.fields[key],
1524
1442
  level: level + 1,
1525
1443
  parent: currentKey + '.',
1526
1444
  schemaArgs,
@@ -1569,8 +1487,7 @@ class GraphQLService {
1569
1487
  }
1570
1488
  // Process string
1571
1489
  if (typeof fields === 'string') {
1572
- if (allowed &&
1573
- ((typeof allowed === 'string' && allowed !== fields) || (typeof allowed === 'object' && !allowed[fields]))) {
1490
+ if (allowed && !allowed.fields[fields]) {
1574
1491
  return { fieldsString, schemaFields, usedFields };
1575
1492
  }
1576
1493
  return { fieldsString: '\n' + ' '.repeat(spaces).repeat(tab) + fields, schemaFields, usedFields };
@@ -1593,14 +1510,14 @@ class GraphQLService {
1593
1510
  }
1594
1511
  const currentPath = parent + item;
1595
1512
  schemaFields.push(currentPath);
1596
- if (allowed && !allowed?.[item]) {
1513
+ if (allowed && !allowed.fields[item]) {
1597
1514
  continue;
1598
1515
  }
1599
1516
  usedFields.push(currentPath);
1600
1517
  fieldsString =
1601
1518
  fieldsString +
1602
1519
  this.prepareFields(item, {
1603
- allowed: typeof allowed?.[item] === 'object' && !(allowed?.[item] instanceof GraphQLType) ? allowed?.[item] : item,
1520
+ allowed: null,
1604
1521
  parent: currentPath + '.',
1605
1522
  spaces,
1606
1523
  schemaFields,
@@ -1614,7 +1531,7 @@ class GraphQLService {
1614
1531
  for (const [key, val] of Object.entries(fields)) {
1615
1532
  const currentPath = parent + key;
1616
1533
  schemaFields.push(currentPath);
1617
- if (allowed && !allowed[key]) {
1534
+ if (allowed && !allowed.fields[key]) {
1618
1535
  continue;
1619
1536
  }
1620
1537
  usedFields.push(currentPath);
@@ -1630,7 +1547,7 @@ class GraphQLService {
1630
1547
  ' ' +
1631
1548
  '{' +
1632
1549
  this.prepareFields(val, {
1633
- allowed: typeof allowed?.[key] === 'object' && !(allowed?.[key] instanceof GraphQLType) ? allowed?.[key] : key,
1550
+ allowed: allowed.fields[key],
1634
1551
  parent: currentPath + '.',
1635
1552
  spaces,
1636
1553
  schemaFields,
@@ -1647,14 +1564,14 @@ class GraphQLService {
1647
1564
  return { fieldsString, schemaFields, usedFields };
1648
1565
  }
1649
1566
  }
1650
- GraphQLService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLService, deps: [{ token: i1$1.Apollo }, { token: GraphQLMetaService }], target: i0.ɵɵFactoryTarget.Injectable });
1567
+ GraphQLService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLService, deps: [{ token: i1.Apollo }, { token: GraphQLMetaService }], target: i0.ɵɵFactoryTarget.Injectable });
1651
1568
  GraphQLService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLService, providedIn: 'root' });
1652
1569
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLService, decorators: [{
1653
1570
  type: Injectable,
1654
1571
  args: [{
1655
1572
  providedIn: 'root',
1656
1573
  }]
1657
- }], ctorParameters: function () { return [{ type: i1$1.Apollo }, { type: GraphQLMetaService }]; } });
1574
+ }], ctorParameters: function () { return [{ type: i1.Apollo }, { type: GraphQLMetaService }]; } });
1658
1575
 
1659
1576
  /**
1660
1577
  * Loader service for loading indication
@@ -1749,14 +1666,14 @@ class GraphQLPlusService extends GraphQLService {
1749
1666
  console.error(error);
1750
1667
  }
1751
1668
  }
1752
- GraphQLPlusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLPlusService, deps: [{ token: i1$1.Apollo }, { token: GraphQLMetaService }, { token: LoaderService }], target: i0.ɵɵFactoryTarget.Injectable });
1669
+ GraphQLPlusService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLPlusService, deps: [{ token: i1.Apollo }, { token: GraphQLMetaService }, { token: LoaderService }], target: i0.ɵɵFactoryTarget.Injectable });
1753
1670
  GraphQLPlusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLPlusService, providedIn: 'root' });
1754
1671
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLPlusService, decorators: [{
1755
1672
  type: Injectable,
1756
1673
  args: [{
1757
1674
  providedIn: 'root',
1758
1675
  }]
1759
- }], ctorParameters: function () { return [{ type: i1$1.Apollo }, { type: GraphQLMetaService }, { type: LoaderService }]; } });
1676
+ }], ctorParameters: function () { return [{ type: i1.Apollo }, { type: GraphQLMetaService }, { type: LoaderService }]; } });
1760
1677
 
1761
1678
  class FormsService {
1762
1679
  validateAllFormFields(formGroup) {
@@ -1856,14 +1773,14 @@ class UserService extends GraphQLPlusService {
1856
1773
  });
1857
1774
  }
1858
1775
  }
1859
- UserService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: UserService, deps: [{ token: i1$1.Apollo }, { token: GraphQLMetaService }, { token: LoaderService }, { token: AuthService }], target: i0.ɵɵFactoryTarget.Injectable });
1776
+ UserService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: UserService, deps: [{ token: i1.Apollo }, { token: GraphQLMetaService }, { token: LoaderService }, { token: AuthService }], target: i0.ɵɵFactoryTarget.Injectable });
1860
1777
  UserService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: UserService, providedIn: 'root' });
1861
1778
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: UserService, decorators: [{
1862
1779
  type: Injectable,
1863
1780
  args: [{
1864
1781
  providedIn: 'root',
1865
1782
  }]
1866
- }], ctorParameters: function () { return [{ type: i1$1.Apollo }, { type: GraphQLMetaService }, { type: LoaderService }, { type: AuthService }]; } });
1783
+ }], ctorParameters: function () { return [{ type: i1.Apollo }, { type: GraphQLMetaService }, { type: LoaderService }, { type: AuthService }]; } });
1867
1784
 
1868
1785
  /**
1869
1786
  * Image service
@@ -2126,14 +2043,14 @@ class ScrollService {
2126
2043
  return this.scrollPromise;
2127
2044
  }
2128
2045
  }
2129
- ScrollService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: ScrollService, deps: [{ token: i1.Router }, { token: BASE_MODULE_CONFIG }, { token: ImageService }], target: i0.ɵɵFactoryTarget.Injectable });
2046
+ ScrollService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: ScrollService, deps: [{ token: i1$1.Router }, { token: BASE_MODULE_CONFIG }, { token: ImageService }], target: i0.ɵɵFactoryTarget.Injectable });
2130
2047
  ScrollService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: ScrollService, providedIn: 'root' });
2131
2048
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: ScrollService, decorators: [{
2132
2049
  type: Injectable,
2133
2050
  args: [{
2134
2051
  providedIn: 'root',
2135
2052
  }]
2136
- }], ctorParameters: function () { return [{ type: i1.Router }, { type: undefined, decorators: [{
2053
+ }], ctorParameters: function () { return [{ type: i1$1.Router }, { type: undefined, decorators: [{
2137
2054
  type: Inject,
2138
2055
  args: [BASE_MODULE_CONFIG]
2139
2056
  }] }, { type: ImageService }]; } });
@@ -2230,14 +2147,116 @@ class BreadcrumbService {
2230
2147
  return typeof data.breadcrumb === 'function' ? data.breadcrumb(data) : data.breadcrumb;
2231
2148
  }
2232
2149
  }
2233
- BreadcrumbService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: BreadcrumbService, deps: [{ token: i1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
2150
+ BreadcrumbService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: BreadcrumbService, deps: [{ token: i1$1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
2234
2151
  BreadcrumbService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: BreadcrumbService, providedIn: 'root' });
2235
2152
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: BreadcrumbService, decorators: [{
2236
2153
  type: Injectable,
2237
2154
  args: [{
2238
2155
  providedIn: 'root',
2239
2156
  }]
2240
- }], ctorParameters: function () { return [{ type: i1.Router }]; } });
2157
+ }], ctorParameters: function () { return [{ type: i1$1.Router }]; } });
2158
+
2159
+ class NavigationService {
2160
+ constructor(router, location) {
2161
+ this.router = router;
2162
+ this.location = location;
2163
+ this.history = [];
2164
+ this.router.events.subscribe((event) => {
2165
+ if (event instanceof NavigationEnd) {
2166
+ this.history.push(event.urlAfterRedirects);
2167
+ }
2168
+ });
2169
+ }
2170
+ /**
2171
+ * If the history stack is empty, navigate to the home page, otherwise go back to the previous page
2172
+ */
2173
+ back() {
2174
+ this.history.pop();
2175
+ if (this.history.length > 0) {
2176
+ this.location.back();
2177
+ }
2178
+ else {
2179
+ this.router.navigateByUrl('/');
2180
+ }
2181
+ }
2182
+ }
2183
+ NavigationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: NavigationService, deps: [{ token: i1$1.Router }, { token: i2.Location }], target: i0.ɵɵFactoryTarget.Injectable });
2184
+ NavigationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: NavigationService, providedIn: 'root' });
2185
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: NavigationService, decorators: [{
2186
+ type: Injectable,
2187
+ args: [{ providedIn: 'root' }]
2188
+ }], ctorParameters: function () { return [{ type: i1$1.Router }, { type: i2.Location }]; } });
2189
+
2190
+ class CmsService {
2191
+ constructor(graphQLService) {
2192
+ this.graphQLService = graphQLService;
2193
+ }
2194
+ /**
2195
+ * It calls the graphQLService to delete the object with the id of the object that is currently being edited
2196
+ */
2197
+ deleteObject(id, modelName) {
2198
+ return new Promise((resolve, reject) => {
2199
+ if (confirm('Möchtest du das Objekt wirklich löschen?')) {
2200
+ this.graphQLService
2201
+ .graphQl('delete' + this.capitalizeFirstLetter(modelName), {
2202
+ arguments: { id },
2203
+ fields: ['id'],
2204
+ type: GraphQLRequestType.MUTATION,
2205
+ })
2206
+ .subscribe({
2207
+ next: (value) => {
2208
+ resolve(value);
2209
+ },
2210
+ error: (err) => {
2211
+ reject(err);
2212
+ console.error('Error on delete object', err);
2213
+ },
2214
+ });
2215
+ }
2216
+ });
2217
+ }
2218
+ /**
2219
+ * It sends a GraphQL mutation to the server to duplicate the object
2220
+ */
2221
+ async duplicateObject(id, modelName) {
2222
+ return new Promise((resolve, reject) => {
2223
+ if (confirm('Möchtest du das Objekt wirklich duplizieren?')) {
2224
+ this.graphQLService
2225
+ .graphQl('duplicate' + this.capitalizeFirstLetter(modelName), {
2226
+ arguments: { id },
2227
+ fields: ['id'],
2228
+ type: GraphQLRequestType.MUTATION,
2229
+ })
2230
+ .subscribe({
2231
+ next: (value) => {
2232
+ resolve(value);
2233
+ },
2234
+ error: (err) => {
2235
+ reject(err);
2236
+ console.error('Error on duplicate object', err);
2237
+ },
2238
+ });
2239
+ }
2240
+ });
2241
+ }
2242
+ /**
2243
+ * It takes a string, capitalizes the first letter, and returns the modified string
2244
+ *
2245
+ * @param value - The string to capitalize.
2246
+ * @returns The first letter of the string is being capitalized and the rest of the string is being returned.
2247
+ */
2248
+ capitalizeFirstLetter(value) {
2249
+ return value.charAt(0).toUpperCase() + value.slice(1);
2250
+ }
2251
+ }
2252
+ CmsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: CmsService, deps: [{ token: GraphQLService }], target: i0.ɵɵFactoryTarget.Injectable });
2253
+ CmsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: CmsService, providedIn: 'root' });
2254
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: CmsService, decorators: [{
2255
+ type: Injectable,
2256
+ args: [{
2257
+ providedIn: 'root',
2258
+ }]
2259
+ }], ctorParameters: function () { return [{ type: GraphQLService }]; } });
2241
2260
 
2242
2261
  /**
2243
2262
  * Comparison operator enum
@@ -2351,5 +2370,5 @@ function createRestartableClient(options) {
2351
2370
  * Generated bundle index. Do not edit.
2352
2371
  */
2353
2372
 
2354
- export { Auth, AuthService, BASE_MODULE_CONFIG, BackButtonDirective, BasicUser, BreadcrumbService, ComparisonOperatorEnum, FormsService, GraphQLEnum, GraphQLMeta, GraphQLMetaService, GraphQLPlusService, GraphQLRequestType, GraphQLService, GraphQLType, Helper, ImageService, LoaderService, LogicalOperatorEnum, NavigationService, ScrollService, SkeletonType, Sort, SortDirective, SortOrderEnum, Standard, StorageService, ToastService, ToastType, UserService, Validation, WsService, createRestartableClient, debounce };
2373
+ export { Auth, AuthService, BASE_MODULE_CONFIG, BasicUser, BreadcrumbService, CmsService, ComparisonOperatorEnum, FormsService, GraphQLEnum, GraphQLMeta, GraphQLMetaService, GraphQLPlusService, GraphQLRequestType, GraphQLService, GraphQLType, Helper, ImageService, LoaderService, LogicalOperatorEnum, NavigationService, ScrollService, SkeletonType, Sort, SortOrderEnum, Standard, StorageService, ToastService, ToastType, UserService, Validation, WsService, createRestartableClient, debounce };
2355
2374
  //# sourceMappingURL=lenne.tech-ng-base-shared.mjs.map