@lenne.tech/ng-base 14.0.3 → 14.1.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 (51) 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 -5
  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/cms.service.mjs +75 -0
  27. package/esm2020/shared/services/graphql.service.mjs +30 -36
  28. package/esm2020/src/base.module.mjs +1 -5
  29. package/fesm2015/lenne.tech-ng-base-base-components.mjs +361 -114
  30. package/fesm2015/lenne.tech-ng-base-base-components.mjs.map +1 -1
  31. package/fesm2015/lenne.tech-ng-base-shared.mjs +203 -190
  32. package/fesm2015/lenne.tech-ng-base-shared.mjs.map +1 -1
  33. package/fesm2015/lenne.tech-ng-base.mjs +2 -113
  34. package/fesm2015/lenne.tech-ng-base.mjs.map +1 -1
  35. package/fesm2020/lenne.tech-ng-base-base-components.mjs +340 -99
  36. package/fesm2020/lenne.tech-ng-base-base-components.mjs.map +1 -1
  37. package/fesm2020/lenne.tech-ng-base-shared.mjs +201 -188
  38. package/fesm2020/lenne.tech-ng-base-shared.mjs.map +1 -1
  39. package/fesm2020/lenne.tech-ng-base.mjs +2 -112
  40. package/fesm2020/lenne.tech-ng-base.mjs.map +1 -1
  41. package/package.json +1 -1
  42. package/public-api.d.ts +0 -1
  43. package/shared/classes/graphql-meta.class.d.ts +7 -4
  44. package/shared/classes/graphql-type.class.d.ts +1 -0
  45. package/shared/classes/sort.class.d.ts +0 -7
  46. package/shared/public-api.d.ts +1 -2
  47. package/shared/services/cms.service.d.ts +23 -0
  48. package/shared/services/graphql.service.d.ts +4 -4
  49. package/src/base.module.d.ts +9 -10
  50. package/esm2020/shared/directives/sort.directive.mjs +0 -54
  51. 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;
@@ -1211,14 +1127,14 @@ class GraphQLMetaService {
1211
1127
  return observable;
1212
1128
  }
1213
1129
  }
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 });
1130
+ 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
1131
  GraphQLMetaService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLMetaService, providedIn: 'root' });
1216
1132
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLMetaService, decorators: [{
1217
1133
  type: Injectable,
1218
1134
  args: [{
1219
1135
  providedIn: 'root',
1220
1136
  }]
1221
- }], ctorParameters: function () { return [{ type: i1$1.Apollo }]; } });
1137
+ }], ctorParameters: function () { return [{ type: i1.Apollo }]; } });
1222
1138
 
1223
1139
  /**
1224
1140
  * GraphQL service
@@ -1285,7 +1201,7 @@ class GraphQLService {
1285
1201
  fieldsData.usedFields.sort();
1286
1202
  fieldsData.schemaFields.sort();
1287
1203
  const filtered = fieldsData.schemaFields.filter((field) => !fieldsData.usedFields.includes(field));
1288
- const unused = this.graphQLTypeCollectionToStringArray(allowedFields).filter((field) => !fieldsData.usedFields.includes(field));
1204
+ const unused = this.graphQLTypeToStringArray(allowedFields).filter((field) => !fieldsData.usedFields.includes(field));
1289
1205
  console.log({ fieldsData, filtered, unused });
1290
1206
  }
1291
1207
  fields = fieldsData.fieldsString;
@@ -1311,7 +1227,7 @@ class GraphQLService {
1311
1227
  argsData.usedArgs.sort();
1312
1228
  argsData.schemaArgs.sort();
1313
1229
  const filtered = argsData.schemaArgs.filter((field) => !argsData.usedArgs.includes(field));
1314
- const unused = this.graphQLTypeCollectionToStringArray(allowedArgs)
1230
+ const unused = this.graphQLTypeToStringArray(allowedArgs)
1315
1231
  .sort()
1316
1232
  .filter((field) => !argsData.usedArgs.includes(field));
1317
1233
  console.log({ argsData, filtered, unused });
@@ -1378,25 +1294,21 @@ class GraphQLService {
1378
1294
  /**
1379
1295
  * Get fields / args from IGraphQLTypeCollection
1380
1296
  */
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
- }
1297
+ graphQLTypeToStringArray(graphQLType, current = '', result = [], cacheNode = []) {
1298
+ if (!graphQLType) {
1299
+ return result;
1300
+ }
1301
+ if (current?.includes('.')) {
1302
+ cacheNode.push(current.split('.')[1]);
1303
+ }
1304
+ else if (current) {
1305
+ cacheNode.push(current);
1306
+ }
1307
+ for (const key of Object.keys(graphQLType.fields)) {
1308
+ if (current === key || cacheNode.includes(key)) {
1309
+ continue;
1399
1310
  }
1311
+ this.graphQLTypeToStringArray(graphQLType.fields[key], current ? current + '.' + key : key, result, cacheNode);
1400
1312
  }
1401
1313
  return result;
1402
1314
  }
@@ -1421,18 +1333,18 @@ class GraphQLService {
1421
1333
  const result = [];
1422
1334
  // Process array
1423
1335
  if (Array.isArray(args)) {
1424
- const allowedKeys = allowed ? Object.keys(allowed) : null;
1336
+ const allowedKeys = allowed ? Object.keys(allowed.fields) : null;
1425
1337
  for (const item of args) {
1426
1338
  let key = null;
1427
1339
  if (allowed) {
1428
- if (allowed.length < 1) {
1340
+ if (!allowedKeys || allowedKeys.length < 1) {
1429
1341
  break;
1430
1342
  }
1431
- key = allowedKeys?.shift();
1343
+ key = allowedKeys.shift();
1432
1344
  }
1433
1345
  // Process value
1434
1346
  result.push(this.prepareArguments(item, {
1435
- allowed: key ? allowed[key] : null,
1347
+ allowed: key ? allowed.fields[key] : null,
1436
1348
  level: level + 1,
1437
1349
  parent: parent + key + '.',
1438
1350
  schemaArgs,
@@ -1464,7 +1376,7 @@ class GraphQLService {
1464
1376
  schemaArgs.push(currentKey);
1465
1377
  // If the allowed key handling is enabled and the current key is not included in the list of allowed keys,
1466
1378
  // the current key will be skipped
1467
- if (allowed && !allowed[key]) {
1379
+ if (allowed && !allowed.fields[key]) {
1468
1380
  continue;
1469
1381
  }
1470
1382
  // Skip value if not exists
@@ -1487,7 +1399,7 @@ class GraphQLService {
1487
1399
  result.push(key +
1488
1400
  ': [' +
1489
1401
  value.map((item) => this.prepareArguments(item, {
1490
- allowed: allowed[key],
1402
+ allowed: allowed.fields[key],
1491
1403
  level: level + 1,
1492
1404
  parent: currentKey + '.',
1493
1405
  schemaArgs,
@@ -1505,7 +1417,7 @@ class GraphQLService {
1505
1417
  // Value is a string
1506
1418
  else if (typeof value === 'string') {
1507
1419
  // Enum (doesn't need quotation marks)
1508
- if (allowed[key].isEnum) {
1420
+ if (allowed.fields[key].isEnum) {
1509
1421
  additionalResult += value;
1510
1422
  }
1511
1423
  // String
@@ -1520,7 +1432,7 @@ class GraphQLService {
1520
1432
  // Others
1521
1433
  else {
1522
1434
  additionalResult += this.prepareArguments(value, {
1523
- allowed: allowed[key],
1435
+ allowed: allowed.fields[key],
1524
1436
  level: level + 1,
1525
1437
  parent: currentKey + '.',
1526
1438
  schemaArgs,
@@ -1569,8 +1481,7 @@ class GraphQLService {
1569
1481
  }
1570
1482
  // Process string
1571
1483
  if (typeof fields === 'string') {
1572
- if (allowed &&
1573
- ((typeof allowed === 'string' && allowed !== fields) || (typeof allowed === 'object' && !allowed[fields]))) {
1484
+ if (allowed && !allowed.fields[fields]) {
1574
1485
  return { fieldsString, schemaFields, usedFields };
1575
1486
  }
1576
1487
  return { fieldsString: '\n' + ' '.repeat(spaces).repeat(tab) + fields, schemaFields, usedFields };
@@ -1593,14 +1504,14 @@ class GraphQLService {
1593
1504
  }
1594
1505
  const currentPath = parent + item;
1595
1506
  schemaFields.push(currentPath);
1596
- if (allowed && !allowed?.[item]) {
1507
+ if (allowed && !allowed.fields[item]) {
1597
1508
  continue;
1598
1509
  }
1599
1510
  usedFields.push(currentPath);
1600
1511
  fieldsString =
1601
1512
  fieldsString +
1602
1513
  this.prepareFields(item, {
1603
- allowed: typeof allowed?.[item] === 'object' && !(allowed?.[item] instanceof GraphQLType) ? allowed?.[item] : item,
1514
+ allowed: null,
1604
1515
  parent: currentPath + '.',
1605
1516
  spaces,
1606
1517
  schemaFields,
@@ -1614,7 +1525,7 @@ class GraphQLService {
1614
1525
  for (const [key, val] of Object.entries(fields)) {
1615
1526
  const currentPath = parent + key;
1616
1527
  schemaFields.push(currentPath);
1617
- if (allowed && !allowed[key]) {
1528
+ if (allowed && !allowed.fields[key]) {
1618
1529
  continue;
1619
1530
  }
1620
1531
  usedFields.push(currentPath);
@@ -1630,7 +1541,7 @@ class GraphQLService {
1630
1541
  ' ' +
1631
1542
  '{' +
1632
1543
  this.prepareFields(val, {
1633
- allowed: typeof allowed?.[key] === 'object' && !(allowed?.[key] instanceof GraphQLType) ? allowed?.[key] : key,
1544
+ allowed: allowed.fields[key],
1634
1545
  parent: currentPath + '.',
1635
1546
  spaces,
1636
1547
  schemaFields,
@@ -1647,14 +1558,14 @@ class GraphQLService {
1647
1558
  return { fieldsString, schemaFields, usedFields };
1648
1559
  }
1649
1560
  }
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 });
1561
+ 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
1562
  GraphQLService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLService, providedIn: 'root' });
1652
1563
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLService, decorators: [{
1653
1564
  type: Injectable,
1654
1565
  args: [{
1655
1566
  providedIn: 'root',
1656
1567
  }]
1657
- }], ctorParameters: function () { return [{ type: i1$1.Apollo }, { type: GraphQLMetaService }]; } });
1568
+ }], ctorParameters: function () { return [{ type: i1.Apollo }, { type: GraphQLMetaService }]; } });
1658
1569
 
1659
1570
  /**
1660
1571
  * Loader service for loading indication
@@ -1749,14 +1660,14 @@ class GraphQLPlusService extends GraphQLService {
1749
1660
  console.error(error);
1750
1661
  }
1751
1662
  }
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 });
1663
+ 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
1664
  GraphQLPlusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLPlusService, providedIn: 'root' });
1754
1665
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLPlusService, decorators: [{
1755
1666
  type: Injectable,
1756
1667
  args: [{
1757
1668
  providedIn: 'root',
1758
1669
  }]
1759
- }], ctorParameters: function () { return [{ type: i1$1.Apollo }, { type: GraphQLMetaService }, { type: LoaderService }]; } });
1670
+ }], ctorParameters: function () { return [{ type: i1.Apollo }, { type: GraphQLMetaService }, { type: LoaderService }]; } });
1760
1671
 
1761
1672
  class FormsService {
1762
1673
  validateAllFormFields(formGroup) {
@@ -1856,14 +1767,14 @@ class UserService extends GraphQLPlusService {
1856
1767
  });
1857
1768
  }
1858
1769
  }
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 });
1770
+ 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
1771
  UserService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: UserService, providedIn: 'root' });
1861
1772
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: UserService, decorators: [{
1862
1773
  type: Injectable,
1863
1774
  args: [{
1864
1775
  providedIn: 'root',
1865
1776
  }]
1866
- }], ctorParameters: function () { return [{ type: i1$1.Apollo }, { type: GraphQLMetaService }, { type: LoaderService }, { type: AuthService }]; } });
1777
+ }], ctorParameters: function () { return [{ type: i1.Apollo }, { type: GraphQLMetaService }, { type: LoaderService }, { type: AuthService }]; } });
1867
1778
 
1868
1779
  /**
1869
1780
  * Image service
@@ -2126,14 +2037,14 @@ class ScrollService {
2126
2037
  return this.scrollPromise;
2127
2038
  }
2128
2039
  }
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 });
2040
+ 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
2041
  ScrollService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: ScrollService, providedIn: 'root' });
2131
2042
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: ScrollService, decorators: [{
2132
2043
  type: Injectable,
2133
2044
  args: [{
2134
2045
  providedIn: 'root',
2135
2046
  }]
2136
- }], ctorParameters: function () { return [{ type: i1.Router }, { type: undefined, decorators: [{
2047
+ }], ctorParameters: function () { return [{ type: i1$1.Router }, { type: undefined, decorators: [{
2137
2048
  type: Inject,
2138
2049
  args: [BASE_MODULE_CONFIG]
2139
2050
  }] }, { type: ImageService }]; } });
@@ -2230,14 +2141,116 @@ class BreadcrumbService {
2230
2141
  return typeof data.breadcrumb === 'function' ? data.breadcrumb(data) : data.breadcrumb;
2231
2142
  }
2232
2143
  }
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 });
2144
+ 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
2145
  BreadcrumbService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: BreadcrumbService, providedIn: 'root' });
2235
2146
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: BreadcrumbService, decorators: [{
2236
2147
  type: Injectable,
2237
2148
  args: [{
2238
2149
  providedIn: 'root',
2239
2150
  }]
2240
- }], ctorParameters: function () { return [{ type: i1.Router }]; } });
2151
+ }], ctorParameters: function () { return [{ type: i1$1.Router }]; } });
2152
+
2153
+ class NavigationService {
2154
+ constructor(router, location) {
2155
+ this.router = router;
2156
+ this.location = location;
2157
+ this.history = [];
2158
+ this.router.events.subscribe((event) => {
2159
+ if (event instanceof NavigationEnd) {
2160
+ this.history.push(event.urlAfterRedirects);
2161
+ }
2162
+ });
2163
+ }
2164
+ /**
2165
+ * If the history stack is empty, navigate to the home page, otherwise go back to the previous page
2166
+ */
2167
+ back() {
2168
+ this.history.pop();
2169
+ if (this.history.length > 0) {
2170
+ this.location.back();
2171
+ }
2172
+ else {
2173
+ this.router.navigateByUrl('/');
2174
+ }
2175
+ }
2176
+ }
2177
+ 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 });
2178
+ NavigationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: NavigationService, providedIn: 'root' });
2179
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: NavigationService, decorators: [{
2180
+ type: Injectable,
2181
+ args: [{ providedIn: 'root' }]
2182
+ }], ctorParameters: function () { return [{ type: i1$1.Router }, { type: i2.Location }]; } });
2183
+
2184
+ class CmsService {
2185
+ constructor(graphQLService) {
2186
+ this.graphQLService = graphQLService;
2187
+ }
2188
+ /**
2189
+ * It calls the graphQLService to delete the object with the id of the object that is currently being edited
2190
+ */
2191
+ deleteObject(id, modelName) {
2192
+ return new Promise((resolve, reject) => {
2193
+ if (confirm('Möchtest du das Objekt wirklich löschen?')) {
2194
+ this.graphQLService
2195
+ .graphQl('delete' + this.capitalizeFirstLetter(modelName), {
2196
+ arguments: { id },
2197
+ fields: ['id'],
2198
+ type: GraphQLRequestType.MUTATION,
2199
+ })
2200
+ .subscribe({
2201
+ next: (value) => {
2202
+ resolve(value);
2203
+ },
2204
+ error: (err) => {
2205
+ reject(err);
2206
+ console.error('Error on delete object', err);
2207
+ },
2208
+ });
2209
+ }
2210
+ });
2211
+ }
2212
+ /**
2213
+ * It sends a GraphQL mutation to the server to duplicate the object
2214
+ */
2215
+ async duplicateObject(id, modelName) {
2216
+ return new Promise((resolve, reject) => {
2217
+ if (confirm('Möchtest du das Objekt wirklich duplizieren?')) {
2218
+ this.graphQLService
2219
+ .graphQl('duplicate' + this.capitalizeFirstLetter(modelName), {
2220
+ arguments: { id },
2221
+ fields: ['id'],
2222
+ type: GraphQLRequestType.MUTATION,
2223
+ })
2224
+ .subscribe({
2225
+ next: (value) => {
2226
+ resolve(value);
2227
+ },
2228
+ error: (err) => {
2229
+ reject(err);
2230
+ console.error('Error on duplicate object', err);
2231
+ },
2232
+ });
2233
+ }
2234
+ });
2235
+ }
2236
+ /**
2237
+ * It takes a string, capitalizes the first letter, and returns the modified string
2238
+ *
2239
+ * @param value - The string to capitalize.
2240
+ * @returns The first letter of the string is being capitalized and the rest of the string is being returned.
2241
+ */
2242
+ capitalizeFirstLetter(value) {
2243
+ return value.charAt(0).toUpperCase() + value.slice(1);
2244
+ }
2245
+ }
2246
+ CmsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: CmsService, deps: [{ token: GraphQLService }], target: i0.ɵɵFactoryTarget.Injectable });
2247
+ CmsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: CmsService, providedIn: 'root' });
2248
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: CmsService, decorators: [{
2249
+ type: Injectable,
2250
+ args: [{
2251
+ providedIn: 'root',
2252
+ }]
2253
+ }], ctorParameters: function () { return [{ type: GraphQLService }]; } });
2241
2254
 
2242
2255
  /**
2243
2256
  * Comparison operator enum
@@ -2351,5 +2364,5 @@ function createRestartableClient(options) {
2351
2364
  * Generated bundle index. Do not edit.
2352
2365
  */
2353
2366
 
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 };
2367
+ 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
2368
  //# sourceMappingURL=lenne.tech-ng-base-shared.mjs.map