@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,18 +1,16 @@
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';
15
10
  import { __awaiter } from 'tslib';
11
+ import * as i1$1 from '@angular/router';
12
+ import { NavigationEnd } from '@angular/router';
13
+ import * as i2 from '@angular/common';
16
14
  import { createClient } from 'graphql-ws';
17
15
 
18
16
  /**
@@ -419,6 +417,7 @@ class GraphQLType extends Standard {
419
417
  constructor() {
420
418
  super(...arguments);
421
419
  this.type = '';
420
+ this.fields = {};
422
421
  this.isRequired = false;
423
422
  this.isItemRequired = false;
424
423
  this.isList = false;
@@ -506,10 +505,10 @@ class GraphQLMeta {
506
505
  }
507
506
  }
508
507
  const func = this.getFunction(functionName, { type });
509
- const result = {};
508
+ const result = new GraphQLType();
510
509
  if (func === null || func === void 0 ? void 0 : func.args) {
511
510
  func.args.forEach((item) => {
512
- result[item.name] = this.getDeepType(item.type);
511
+ result.fields[item.name] = this.getDeepType(item.type);
513
512
  });
514
513
  }
515
514
  // Set cache
@@ -572,22 +571,48 @@ class GraphQLMeta {
572
571
  getType(name) {
573
572
  return this.schema.getType(name);
574
573
  }
574
+ /**
575
+ * Get (deep) type name
576
+ */
577
+ getTypeName(type) {
578
+ if (type instanceof GraphQLInputObjectType ||
579
+ type instanceof GraphQLScalarType ||
580
+ type instanceof GraphQLEnumType) {
581
+ return type.name;
582
+ }
583
+ else if (type.type) {
584
+ return this.getTypeName(type.type);
585
+ }
586
+ else if (type.ofType) {
587
+ return this.getTypeName(type.ofType);
588
+ }
589
+ else {
590
+ return type.name;
591
+ }
592
+ }
575
593
  /**
576
594
  * Get deep type data
577
595
  */
578
- getDeepType(type, prepared = new WeakMap(), setMetaData = false) {
596
+ getDeepType(type, prepared = {}, setMetaData = false) {
579
597
  var _a, _b;
580
598
  // Check type
581
599
  if (!type) {
582
600
  return type;
583
601
  }
584
602
  // Infinite regress protection
585
- const preparedObject = {};
603
+ const typeName = this.getTypeName(type);
604
+ const graphQLType = GraphQLType.map({
605
+ type: this.getTypeName(type),
606
+ });
586
607
  // Check prepared
587
608
  if (typeof type === 'object') {
588
- const preparedType = prepared.get(type);
609
+ const preparedType = prepared[typeName];
610
+ // Work with cached type
589
611
  if (preparedType) {
590
- const clone = cloneDeep(preparedType);
612
+ // Create a new object to protect own isXXX information
613
+ const clone = Object.assign({}, preparedType);
614
+ // But use fields as reference to get future changes via prepared caching
615
+ clone.fields = preparedType.fields;
591
616
  // Disable meta flags for sub objects
592
617
  if ((type === null || type === void 0 ? void 0 : type.type) instanceof GraphQLInputObjectType ||
593
618
  ((type === null || type === void 0 ? void 0 : type.type) instanceof GraphQLNonNull && ((_a = type === null || type === void 0 ? void 0 : type.type) === null || _a === void 0 ? void 0 : _a.ofType) instanceof GraphQLInputObjectType && setMetaData)) {
@@ -621,25 +646,29 @@ class GraphQLMeta {
621
646
  }
622
647
  return clone;
623
648
  }
624
- // Set prepared
625
- prepared.set(type, preparedObject);
649
+ // Set prepared cache for GraphQL types
650
+ // (type names start with uppercase letters as opposed to property names that start with lowercase letters)
651
+ if (type.name && type.name[0].toUpperCase() === type.name[0] && !prepared[type.name]) {
652
+ prepared[type.name] = graphQLType;
653
+ }
626
654
  }
627
655
  // Search deeper
628
656
  if (type.ofType) {
629
657
  const ofTypeResult = this.getDeepType(type.ofType, prepared, setMetaData);
630
- Object.assign(preparedObject, ofTypeResult);
631
- return ofTypeResult;
658
+ Object.assign(graphQLType, ofTypeResult);
659
+ return graphQLType;
632
660
  }
633
661
  // Process fields
634
662
  if (type._fields) {
635
- const result = {};
663
+ const fields = {};
636
664
  for (const [key, value] of Object.entries(type._fields)) {
637
- result[key] = this.getDeepType(value, prepared, true);
665
+ fields[key] = this.getDeepType(value, prepared, true);
638
666
  }
639
- Object.assign(preparedObject, result);
640
- return result;
667
+ // Assign and not replace to preserve updates in the cache
668
+ Object.assign(graphQLType.fields, fields);
669
+ return graphQLType;
641
670
  }
642
- // Get type name
671
+ // Process type
643
672
  if (type.type) {
644
673
  const typeResult = this.getDeepType(type.type, prepared, setMetaData);
645
674
  // Disable meta flags for sub objects
@@ -673,25 +702,20 @@ class GraphQLMeta {
673
702
  }
674
703
  }
675
704
  }
676
- Object.assign(preparedObject, typeResult);
677
- return typeResult;
705
+ Object.assign(graphQLType, typeResult);
706
+ return graphQLType;
678
707
  }
679
- // Initialize GraphQLType
680
- const graphqlType = GraphQLType.map({
681
- type: type.name,
682
- });
683
708
  // Set enum values
684
709
  if (!!type._values) {
685
- graphqlType.isEnum = true;
710
+ graphQLType.isEnum = true;
686
711
  for (const [key, value] of Object.entries(type._nameLookup)) {
687
712
  if (!value.isDeprecated) {
688
- graphqlType.validEnums.push(key);
713
+ graphQLType.validEnums.push(key);
689
714
  }
690
715
  }
691
716
  }
692
717
  // Finish
693
- prepared.set(type, graphqlType);
694
- return graphqlType;
718
+ return graphQLType;
695
719
  }
696
720
  }
697
721
 
@@ -715,10 +739,6 @@ class Sort {
715
739
  }
716
740
  /**
717
741
  * Sorts clicked column
718
- *
719
- * @param property
720
- * @param order
721
- * @param type
722
742
  */
723
743
  startSort(property, order, type = '') {
724
744
  if (order === 'desc') {
@@ -738,9 +758,6 @@ class Sort {
738
758
  }
739
759
  /**
740
760
  * Sorts dates
741
- *
742
- * @param a
743
- * @param b
744
761
  */
745
762
  sortDate(a, b) {
746
763
  if (a < b) {
@@ -755,109 +772,6 @@ class Sort {
755
772
  }
756
773
  }
757
774
 
758
- class SortDirective {
759
- constructor(renderer, targetElem, document) {
760
- this.renderer = renderer;
761
- this.targetElem = targetElem;
762
- }
763
- /**
764
- * Sorts columns on click
765
- */
766
- sortColumn() {
767
- const items = document.getElementsByTagName('th');
768
- for (let i = 0; i < items.length; i++) {
769
- items[i].classList.remove('asc');
770
- items[i].classList.remove('desc');
771
- }
772
- const sort = new Sort();
773
- const elem = this.targetElem.nativeElement;
774
- const order = elem.getAttribute('data-order');
775
- const type = elem.getAttribute('data-type');
776
- const property = elem.getAttribute('data-name');
777
- if (order === 'desc') {
778
- this.lcSort.sort(sort.startSort(property, order, type));
779
- elem.setAttribute('data-order', 'asc');
780
- elem.classList.remove('desc');
781
- elem.classList.add('asc');
782
- }
783
- else {
784
- this.lcSort.sort(sort.startSort(property, order, type));
785
- elem.setAttribute('data-order', 'desc');
786
- elem.classList.remove('asc');
787
- elem.classList.add('desc');
788
- }
789
- }
790
- }
791
- 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 });
792
- 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 });
793
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: SortDirective, decorators: [{
794
- type: Directive,
795
- args: [{
796
- selector: '[baseSort]',
797
- }]
798
- }], ctorParameters: function () {
799
- return [{ type: i0.Renderer2 }, { type: i0.ElementRef }, { type: Document, decorators: [{
800
- type: Inject,
801
- args: [DOCUMENT]
802
- }] }];
803
- }, propDecorators: { lcSort: [{
804
- type: Input
805
- }], sortColumn: [{
806
- type: HostListener,
807
- args: ['click']
808
- }] } });
809
-
810
- class NavigationService {
811
- constructor(router, location) {
812
- this.router = router;
813
- this.location = location;
814
- this.history = [];
815
- this.router.events.subscribe((event) => {
816
- if (event instanceof NavigationEnd) {
817
- this.history.push(event.urlAfterRedirects);
818
- }
819
- });
820
- }
821
- /**
822
- * If the history stack is empty, navigate to the home page, otherwise go back to the previous page
823
- */
824
- back() {
825
- this.history.pop();
826
- if (this.history.length > 0) {
827
- this.location.back();
828
- }
829
- else {
830
- this.router.navigateByUrl('/');
831
- }
832
- }
833
- }
834
- 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 });
835
- NavigationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: NavigationService, providedIn: 'root' });
836
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: NavigationService, decorators: [{
837
- type: Injectable,
838
- args: [{ providedIn: 'root' }]
839
- }], ctorParameters: function () { return [{ type: i1.Router }, { type: i2.Location }]; } });
840
-
841
- class BackButtonDirective {
842
- constructor(navigation) {
843
- this.navigation = navigation;
844
- }
845
- onClick() {
846
- this.navigation.back();
847
- }
848
- }
849
- BackButtonDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: BackButtonDirective, deps: [{ token: NavigationService }], target: i0.ɵɵFactoryTarget.Directive });
850
- BackButtonDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "14.1.0", type: BackButtonDirective, selector: "[baseBackButton]", host: { listeners: { "click": "onClick()" } }, ngImport: i0 });
851
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: BackButtonDirective, decorators: [{
852
- type: Directive,
853
- args: [{
854
- selector: '[baseBackButton]',
855
- }]
856
- }], ctorParameters: function () { return [{ type: NavigationService }]; }, propDecorators: { onClick: [{
857
- type: HostListener,
858
- args: ['click']
859
- }] } });
860
-
861
775
  function debounce(delay = 300) {
862
776
  return function (target, propertyKey, descriptor) {
863
777
  let timeout = null;
@@ -1047,6 +961,9 @@ class AuthService {
1047
961
  // Current User
1048
962
  // #################################################################
1049
963
  get currentUser() {
964
+ if (!localStorage) {
965
+ return undefined;
966
+ }
1050
967
  return this._currentUser.value;
1051
968
  }
1052
969
  set currentUser(user) {
@@ -1060,6 +977,9 @@ class AuthService {
1060
977
  // Token
1061
978
  // #################################################################
1062
979
  get token() {
980
+ if (!localStorage) {
981
+ return undefined;
982
+ }
1063
983
  return this._token.value;
1064
984
  }
1065
985
  set token(token) {
@@ -1192,14 +1112,14 @@ class GraphQLMetaService {
1192
1112
  return observable;
1193
1113
  }
1194
1114
  }
1195
- 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 });
1115
+ GraphQLMetaService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLMetaService, deps: [{ token: i1.Apollo }], target: i0.ɵɵFactoryTarget.Injectable });
1196
1116
  GraphQLMetaService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLMetaService, providedIn: 'root' });
1197
1117
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLMetaService, decorators: [{
1198
1118
  type: Injectable,
1199
1119
  args: [{
1200
1120
  providedIn: 'root',
1201
1121
  }]
1202
- }], ctorParameters: function () { return [{ type: i1$1.Apollo }]; } });
1122
+ }], ctorParameters: function () { return [{ type: i1.Apollo }]; } });
1203
1123
 
1204
1124
  /**
1205
1125
  * GraphQL service
@@ -1259,7 +1179,7 @@ class GraphQLService {
1259
1179
  fieldsData.usedFields.sort();
1260
1180
  fieldsData.schemaFields.sort();
1261
1181
  const filtered = fieldsData.schemaFields.filter((field) => !fieldsData.usedFields.includes(field));
1262
- const unused = this.graphQLTypeCollectionToStringArray(allowedFields).filter((field) => !fieldsData.usedFields.includes(field));
1182
+ const unused = this.graphQLTypeToStringArray(allowedFields).filter((field) => !fieldsData.usedFields.includes(field));
1263
1183
  console.log({ fieldsData, filtered, unused });
1264
1184
  }
1265
1185
  fields = fieldsData.fieldsString;
@@ -1285,7 +1205,7 @@ class GraphQLService {
1285
1205
  argsData.usedArgs.sort();
1286
1206
  argsData.schemaArgs.sort();
1287
1207
  const filtered = argsData.schemaArgs.filter((field) => !argsData.usedArgs.includes(field));
1288
- const unused = this.graphQLTypeCollectionToStringArray(allowedArgs)
1208
+ const unused = this.graphQLTypeToStringArray(allowedArgs)
1289
1209
  .sort()
1290
1210
  .filter((field) => !argsData.usedArgs.includes(field));
1291
1211
  console.log({ argsData, filtered, unused });
@@ -1353,25 +1273,21 @@ class GraphQLService {
1353
1273
  /**
1354
1274
  * Get fields / args from IGraphQLTypeCollection
1355
1275
  */
1356
- graphQLTypeCollectionToStringArray(collection, current = '', result = [], cacheNode = []) {
1357
- if (collection) {
1358
- if (collection instanceof GraphQLType) {
1359
- result.push(current);
1360
- }
1361
- else {
1362
- if (current === null || current === void 0 ? void 0 : current.includes('.')) {
1363
- cacheNode.push(current.split('.')[1]);
1364
- }
1365
- else if (current) {
1366
- cacheNode.push(current);
1367
- }
1368
- for (const key of Object.keys(collection)) {
1369
- if (current === key || cacheNode.includes(key)) {
1370
- continue;
1371
- }
1372
- this.graphQLTypeCollectionToStringArray(collection[key], current ? current + '.' + key : key, result, cacheNode);
1373
- }
1276
+ graphQLTypeToStringArray(graphQLType, current = '', result = [], cacheNode = []) {
1277
+ if (!graphQLType) {
1278
+ return result;
1279
+ }
1280
+ if (current === null || current === void 0 ? void 0 : current.includes('.')) {
1281
+ cacheNode.push(current.split('.')[1]);
1282
+ }
1283
+ else if (current) {
1284
+ cacheNode.push(current);
1285
+ }
1286
+ for (const key of Object.keys(graphQLType.fields)) {
1287
+ if (current === key || cacheNode.includes(key)) {
1288
+ continue;
1374
1289
  }
1290
+ this.graphQLTypeToStringArray(graphQLType.fields[key], current ? current + '.' + key : key, result, cacheNode);
1375
1291
  }
1376
1292
  return result;
1377
1293
  }
@@ -1389,18 +1305,18 @@ class GraphQLService {
1389
1305
  const result = [];
1390
1306
  // Process array
1391
1307
  if (Array.isArray(args)) {
1392
- const allowedKeys = allowed ? Object.keys(allowed) : null;
1308
+ const allowedKeys = allowed ? Object.keys(allowed.fields) : null;
1393
1309
  for (const item of args) {
1394
1310
  let key = null;
1395
1311
  if (allowed) {
1396
- if (allowed.length < 1) {
1312
+ if (!allowedKeys || allowedKeys.length < 1) {
1397
1313
  break;
1398
1314
  }
1399
- key = allowedKeys === null || allowedKeys === void 0 ? void 0 : allowedKeys.shift();
1315
+ key = allowedKeys.shift();
1400
1316
  }
1401
1317
  // Process value
1402
1318
  result.push(this.prepareArguments(item, {
1403
- allowed: key ? allowed[key] : null,
1319
+ allowed: key ? allowed.fields[key] : null,
1404
1320
  level: level + 1,
1405
1321
  parent: parent + key + '.',
1406
1322
  schemaArgs,
@@ -1432,7 +1348,7 @@ class GraphQLService {
1432
1348
  schemaArgs.push(currentKey);
1433
1349
  // If the allowed key handling is enabled and the current key is not included in the list of allowed keys,
1434
1350
  // the current key will be skipped
1435
- if (allowed && !allowed[key]) {
1351
+ if (allowed && !allowed.fields[key]) {
1436
1352
  continue;
1437
1353
  }
1438
1354
  // Skip value if not exists
@@ -1455,7 +1371,7 @@ class GraphQLService {
1455
1371
  result.push(key +
1456
1372
  ': [' +
1457
1373
  value.map((item) => this.prepareArguments(item, {
1458
- allowed: allowed[key],
1374
+ allowed: allowed.fields[key],
1459
1375
  level: level + 1,
1460
1376
  parent: currentKey + '.',
1461
1377
  schemaArgs,
@@ -1473,7 +1389,7 @@ class GraphQLService {
1473
1389
  // Value is a string
1474
1390
  else if (typeof value === 'string') {
1475
1391
  // Enum (doesn't need quotation marks)
1476
- if (allowed[key].isEnum) {
1392
+ if (allowed.fields[key].isEnum) {
1477
1393
  additionalResult += value;
1478
1394
  }
1479
1395
  // String
@@ -1488,7 +1404,7 @@ class GraphQLService {
1488
1404
  // Others
1489
1405
  else {
1490
1406
  additionalResult += this.prepareArguments(value, {
1491
- allowed: allowed[key],
1407
+ allowed: allowed.fields[key],
1492
1408
  level: level + 1,
1493
1409
  parent: currentKey + '.',
1494
1410
  schemaArgs,
@@ -1529,8 +1445,7 @@ class GraphQLService {
1529
1445
  }
1530
1446
  // Process string
1531
1447
  if (typeof fields === 'string') {
1532
- if (allowed &&
1533
- ((typeof allowed === 'string' && allowed !== fields) || (typeof allowed === 'object' && !allowed[fields]))) {
1448
+ if (allowed && !allowed.fields[fields]) {
1534
1449
  return { fieldsString, schemaFields, usedFields };
1535
1450
  }
1536
1451
  return { fieldsString: '\n' + ' '.repeat(spaces).repeat(tab) + fields, schemaFields, usedFields };
@@ -1553,14 +1468,14 @@ class GraphQLService {
1553
1468
  }
1554
1469
  const currentPath = parent + item;
1555
1470
  schemaFields.push(currentPath);
1556
- if (allowed && !(allowed === null || allowed === void 0 ? void 0 : allowed[item])) {
1471
+ if (allowed && !allowed.fields[item]) {
1557
1472
  continue;
1558
1473
  }
1559
1474
  usedFields.push(currentPath);
1560
1475
  fieldsString =
1561
1476
  fieldsString +
1562
1477
  this.prepareFields(item, {
1563
- allowed: typeof (allowed === null || allowed === void 0 ? void 0 : allowed[item]) === 'object' && !((allowed === null || allowed === void 0 ? void 0 : allowed[item]) instanceof GraphQLType) ? allowed === null || allowed === void 0 ? void 0 : allowed[item] : item,
1478
+ allowed: null,
1564
1479
  parent: currentPath + '.',
1565
1480
  spaces,
1566
1481
  schemaFields,
@@ -1574,7 +1489,7 @@ class GraphQLService {
1574
1489
  for (const [key, val] of Object.entries(fields)) {
1575
1490
  const currentPath = parent + key;
1576
1491
  schemaFields.push(currentPath);
1577
- if (allowed && !allowed[key]) {
1492
+ if (allowed && !allowed.fields[key]) {
1578
1493
  continue;
1579
1494
  }
1580
1495
  usedFields.push(currentPath);
@@ -1590,7 +1505,7 @@ class GraphQLService {
1590
1505
  ' ' +
1591
1506
  '{' +
1592
1507
  this.prepareFields(val, {
1593
- allowed: typeof (allowed === null || allowed === void 0 ? void 0 : allowed[key]) === 'object' && !((allowed === null || allowed === void 0 ? void 0 : allowed[key]) instanceof GraphQLType) ? allowed === null || allowed === void 0 ? void 0 : allowed[key] : key,
1508
+ allowed: allowed.fields[key],
1594
1509
  parent: currentPath + '.',
1595
1510
  spaces,
1596
1511
  schemaFields,
@@ -1607,14 +1522,14 @@ class GraphQLService {
1607
1522
  return { fieldsString, schemaFields, usedFields };
1608
1523
  }
1609
1524
  }
1610
- 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 });
1525
+ 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 });
1611
1526
  GraphQLService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLService, providedIn: 'root' });
1612
1527
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLService, decorators: [{
1613
1528
  type: Injectable,
1614
1529
  args: [{
1615
1530
  providedIn: 'root',
1616
1531
  }]
1617
- }], ctorParameters: function () { return [{ type: i1$1.Apollo }, { type: GraphQLMetaService }]; } });
1532
+ }], ctorParameters: function () { return [{ type: i1.Apollo }, { type: GraphQLMetaService }]; } });
1618
1533
 
1619
1534
  /**
1620
1535
  * Loader service for loading indication
@@ -1709,14 +1624,14 @@ class GraphQLPlusService extends GraphQLService {
1709
1624
  console.error(error);
1710
1625
  }
1711
1626
  }
1712
- 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 });
1627
+ 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 });
1713
1628
  GraphQLPlusService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLPlusService, providedIn: 'root' });
1714
1629
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: GraphQLPlusService, decorators: [{
1715
1630
  type: Injectable,
1716
1631
  args: [{
1717
1632
  providedIn: 'root',
1718
1633
  }]
1719
- }], ctorParameters: function () { return [{ type: i1$1.Apollo }, { type: GraphQLMetaService }, { type: LoaderService }]; } });
1634
+ }], ctorParameters: function () { return [{ type: i1.Apollo }, { type: GraphQLMetaService }, { type: LoaderService }]; } });
1720
1635
 
1721
1636
  class FormsService {
1722
1637
  validateAllFormFields(formGroup) {
@@ -1816,14 +1731,14 @@ class UserService extends GraphQLPlusService {
1816
1731
  });
1817
1732
  }
1818
1733
  }
1819
- 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 });
1734
+ 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 });
1820
1735
  UserService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: UserService, providedIn: 'root' });
1821
1736
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: UserService, decorators: [{
1822
1737
  type: Injectable,
1823
1738
  args: [{
1824
1739
  providedIn: 'root',
1825
1740
  }]
1826
- }], ctorParameters: function () { return [{ type: i1$1.Apollo }, { type: GraphQLMetaService }, { type: LoaderService }, { type: AuthService }]; } });
1741
+ }], ctorParameters: function () { return [{ type: i1.Apollo }, { type: GraphQLMetaService }, { type: LoaderService }, { type: AuthService }]; } });
1827
1742
 
1828
1743
  /**
1829
1744
  * Image service
@@ -2073,7 +1988,7 @@ class ScrollService {
2073
1988
  return this.scrollPromise;
2074
1989
  }
2075
1990
  }
2076
- 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 });
1991
+ 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 });
2077
1992
  ScrollService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: ScrollService, providedIn: 'root' });
2078
1993
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: ScrollService, decorators: [{
2079
1994
  type: Injectable,
@@ -2081,7 +1996,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImpor
2081
1996
  providedIn: 'root',
2082
1997
  }]
2083
1998
  }], ctorParameters: function () {
2084
- return [{ type: i1.Router }, { type: undefined, decorators: [{
1999
+ return [{ type: i1$1.Router }, { type: undefined, decorators: [{
2085
2000
  type: Inject,
2086
2001
  args: [BASE_MODULE_CONFIG]
2087
2002
  }] }, { type: ImageService }];
@@ -2180,14 +2095,118 @@ class BreadcrumbService {
2180
2095
  return typeof data.breadcrumb === 'function' ? data.breadcrumb(data) : data.breadcrumb;
2181
2096
  }
2182
2097
  }
2183
- BreadcrumbService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: BreadcrumbService, deps: [{ token: i1.Router }], target: i0.ɵɵFactoryTarget.Injectable });
2098
+ 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 });
2184
2099
  BreadcrumbService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: BreadcrumbService, providedIn: 'root' });
2185
2100
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: BreadcrumbService, decorators: [{
2186
2101
  type: Injectable,
2187
2102
  args: [{
2188
2103
  providedIn: 'root',
2189
2104
  }]
2190
- }], ctorParameters: function () { return [{ type: i1.Router }]; } });
2105
+ }], ctorParameters: function () { return [{ type: i1$1.Router }]; } });
2106
+
2107
+ class NavigationService {
2108
+ constructor(router, location) {
2109
+ this.router = router;
2110
+ this.location = location;
2111
+ this.history = [];
2112
+ this.router.events.subscribe((event) => {
2113
+ if (event instanceof NavigationEnd) {
2114
+ this.history.push(event.urlAfterRedirects);
2115
+ }
2116
+ });
2117
+ }
2118
+ /**
2119
+ * If the history stack is empty, navigate to the home page, otherwise go back to the previous page
2120
+ */
2121
+ back() {
2122
+ this.history.pop();
2123
+ if (this.history.length > 0) {
2124
+ this.location.back();
2125
+ }
2126
+ else {
2127
+ this.router.navigateByUrl('/');
2128
+ }
2129
+ }
2130
+ }
2131
+ 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 });
2132
+ NavigationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: NavigationService, providedIn: 'root' });
2133
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: NavigationService, decorators: [{
2134
+ type: Injectable,
2135
+ args: [{ providedIn: 'root' }]
2136
+ }], ctorParameters: function () { return [{ type: i1$1.Router }, { type: i2.Location }]; } });
2137
+
2138
+ class CmsService {
2139
+ constructor(graphQLService) {
2140
+ this.graphQLService = graphQLService;
2141
+ }
2142
+ /**
2143
+ * It calls the graphQLService to delete the object with the id of the object that is currently being edited
2144
+ */
2145
+ deleteObject(id, modelName) {
2146
+ return new Promise((resolve, reject) => {
2147
+ if (confirm('Möchtest du das Objekt wirklich löschen?')) {
2148
+ this.graphQLService
2149
+ .graphQl('delete' + this.capitalizeFirstLetter(modelName), {
2150
+ arguments: { id },
2151
+ fields: ['id'],
2152
+ type: GraphQLRequestType.MUTATION,
2153
+ })
2154
+ .subscribe({
2155
+ next: (value) => {
2156
+ resolve(value);
2157
+ },
2158
+ error: (err) => {
2159
+ reject(err);
2160
+ console.error('Error on delete object', err);
2161
+ },
2162
+ });
2163
+ }
2164
+ });
2165
+ }
2166
+ /**
2167
+ * It sends a GraphQL mutation to the server to duplicate the object
2168
+ */
2169
+ duplicateObject(id, modelName) {
2170
+ return __awaiter(this, void 0, void 0, function* () {
2171
+ return new Promise((resolve, reject) => {
2172
+ if (confirm('Möchtest du das Objekt wirklich duplizieren?')) {
2173
+ this.graphQLService
2174
+ .graphQl('duplicate' + this.capitalizeFirstLetter(modelName), {
2175
+ arguments: { id },
2176
+ fields: ['id'],
2177
+ type: GraphQLRequestType.MUTATION,
2178
+ })
2179
+ .subscribe({
2180
+ next: (value) => {
2181
+ resolve(value);
2182
+ },
2183
+ error: (err) => {
2184
+ reject(err);
2185
+ console.error('Error on duplicate object', err);
2186
+ },
2187
+ });
2188
+ }
2189
+ });
2190
+ });
2191
+ }
2192
+ /**
2193
+ * It takes a string, capitalizes the first letter, and returns the modified string
2194
+ *
2195
+ * @param value - The string to capitalize.
2196
+ * @returns The first letter of the string is being capitalized and the rest of the string is being returned.
2197
+ */
2198
+ capitalizeFirstLetter(value) {
2199
+ return value.charAt(0).toUpperCase() + value.slice(1);
2200
+ }
2201
+ }
2202
+ CmsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: CmsService, deps: [{ token: GraphQLService }], target: i0.ɵɵFactoryTarget.Injectable });
2203
+ CmsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: CmsService, providedIn: 'root' });
2204
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.1.0", ngImport: i0, type: CmsService, decorators: [{
2205
+ type: Injectable,
2206
+ args: [{
2207
+ providedIn: 'root',
2208
+ }]
2209
+ }], ctorParameters: function () { return [{ type: GraphQLService }]; } });
2191
2210
 
2192
2211
  /**
2193
2212
  * Comparison operator enum
@@ -2294,5 +2313,5 @@ function createRestartableClient(options) {
2294
2313
  * Generated bundle index. Do not edit.
2295
2314
  */
2296
2315
 
2297
- 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 };
2316
+ 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 };
2298
2317
  //# sourceMappingURL=lenne.tech-ng-base-shared.mjs.map