@quadrel-enterprise-ui/framework 20.0.0-beta.97.1 → 20.0.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.
@@ -3,7 +3,7 @@ import { inject, ElementRef, Directive, InjectionToken, HostBinding, Input, View
3
3
  import { Dialog, DialogRef, DialogModule } from '@angular/cdk/dialog';
4
4
  import * as i1 from '@angular/common';
5
5
  import { CommonModule, NgFor, NgIf, NgClass, NgTemplateOutlet, AsyncPipe } from '@angular/common';
6
- import { BehaviorSubject, pairwise, from, switchMap, map as map$1, Subject, throwError, of, ReplaySubject, merge, fromEvent, isObservable, NEVER, Observable, EMPTY, shareReplay, Subscription, distinctUntilChanged as distinctUntilChanged$1, debounce, timer, startWith as startWith$1, debounceTime as debounceTime$1, takeUntil as takeUntil$1, firstValueFrom, combineLatest, concat, take as take$1, delay, tap as tap$1, first, scan, combineLatestWith, iif, delayWhen, withLatestFrom, async, filter as filter$1 } from 'rxjs';
6
+ import { BehaviorSubject, pairwise, from, switchMap, map as map$1, Subject, throwError, of, ReplaySubject, merge, fromEvent, isObservable, NEVER, Observable, EMPTY, shareReplay, Subscription, distinctUntilChanged as distinctUntilChanged$1, debounce, timer, startWith as startWith$1, debounceTime as debounceTime$1, takeUntil as takeUntil$1, firstValueFrom, combineLatest, concat, take as take$1, delay, tap as tap$1, first, scan, combineLatestWith, forkJoin, delayWhen, withLatestFrom, async, filter as filter$1 } from 'rxjs';
7
7
  import { map, takeUntil, take, filter, catchError, debounceTime, startWith, distinctUntilChanged, concatMap, tap, skip, pairwise as pairwise$1, switchMap as switchMap$1, mergeMap, delay as delay$1 } from 'rxjs/operators';
8
8
  import { v4 } from 'uuid';
9
9
  import * as i3 from '@ngx-translate/core';
@@ -12052,8 +12052,8 @@ class QdTranslateService {
12052
12052
  get use() {
12053
12053
  return this.translateService.use;
12054
12054
  }
12055
- get getTranslation() {
12056
- return this.translateService.getTranslation;
12055
+ get get() {
12056
+ return this.translateService.get;
12057
12057
  }
12058
12058
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: QdTranslateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
12059
12059
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: QdTranslateService, providedIn: 'root' });
@@ -29819,17 +29819,49 @@ class QdShellServiceNavigationService {
29819
29819
  customButtonsLinks: 'custom-buttons'
29820
29820
  };
29821
29821
  getMappedAttributes$() {
29822
- /* There is an issue with the translateService.getTranslation method. In this method a pointer is set
29823
- * to the language given in the method call so that this language is used as the current language as long as
29824
- * the translations files are being loaded. That's why we swap the current language to the last position of
29825
- * the language list for the getTranslation calls. So the internal pointer in the getTranslation method will
29826
- * be set to the current language. */
29827
- const languageListSorted = this.swapCurrentLangToTheEndOfLanguageList(this.languageList);
29828
- return combineLatest(languageListSorted.map(language => this.translateService.getTranslation(language))).pipe(tap(translations => {
29829
- translations.forEach((languageTranslations, languageIndex) => {
29830
- this._translations[languageListSorted[languageIndex]] = languageTranslations;
29822
+ const languagesInOrder = this.swapCurrentLangToTheEndOfLanguageList(this.languageList);
29823
+ const keysFromConfig = this.collectI18nKeysFromConfig(this.config);
29824
+ const keys = Array.isArray(keysFromConfig) ? keysFromConfig : [];
29825
+ const translationObservables = languagesInOrder.map(lang => {
29826
+ this.translateService.use(lang);
29827
+ return this.translateService.get(keys).pipe(map(trans => ({ lang, trans })));
29828
+ });
29829
+ return forkJoin(translationObservables).pipe(tap(results => {
29830
+ results.forEach(({ lang, trans }) => {
29831
+ this._translations[lang] = typeof trans === 'object' && trans !== null ? trans : {};
29831
29832
  });
29832
- }), mergeMap(() => iif(() => this.config.defaultLanguage != null, of(this.mapAttributes()), this.eportalLanguageService.fetchEportalLanguage$().pipe(map(eportalLanguage => eportalLanguage?.toLowerCase()), map(eportalLanguage => this.languageList.includes(eportalLanguage) ? eportalLanguage : 'de'), map(eportalLanguage => this.mapAttributes(eportalLanguage))))));
29833
+ }), mergeMap(() => {
29834
+ if (this.config?.defaultLanguage != null) {
29835
+ return of(this.mapAttributes());
29836
+ }
29837
+ return this.eportalLanguageService.fetchEportalLanguage$().pipe(map(lang => lang?.toLowerCase()), map(lang => (this.languageList.includes(lang) ? lang : 'de')), map(lang => this.mapAttributes(lang)));
29838
+ }));
29839
+ }
29840
+ collectI18nKeysFromConfig(config) {
29841
+ if (!config)
29842
+ return [];
29843
+ const keys = new Set();
29844
+ const visitLink = (link) => {
29845
+ if (!link || typeof link !== 'object')
29846
+ return;
29847
+ const linkItem = link;
29848
+ if (typeof linkItem.i18n === 'string')
29849
+ keys.add(linkItem.i18n);
29850
+ if (linkItem.iconLink && typeof linkItem.iconLink.i18n === 'string') {
29851
+ keys.add(linkItem.iconLink.i18n);
29852
+ }
29853
+ if (Array.isArray(linkItem.childLinks)) {
29854
+ linkItem.childLinks.forEach(visitLink);
29855
+ }
29856
+ };
29857
+ const visitArray = (maybeArray) => {
29858
+ if (Array.isArray(maybeArray))
29859
+ maybeArray.forEach(visitLink);
29860
+ };
29861
+ visitArray(config.infoLinks);
29862
+ visitArray(config.profileLinks);
29863
+ visitArray(config.customButtonsLinks);
29864
+ return Array.from(keys);
29833
29865
  }
29834
29866
  swapCurrentLangToTheEndOfLanguageList(languageList) {
29835
29867
  const currentLangIndex = languageList.indexOf(this.currentLang);
@@ -30122,27 +30154,57 @@ class QdShellHeaderWidgetService {
30122
30154
  this._config = config;
30123
30155
  }
30124
30156
  getMappedAttributes$() {
30125
- /* There is an issue with the translateService.getTranslation method. In this method a pointer is set
30126
- * to the language given in the method call so that this language is used as the current language as long as
30127
- * the translations files are being loaded. That's why we swap the current language to the last position of
30128
- * the language list for the getTranslation calls. So the internal pointer in the getTranslation method will
30129
- * be set to the current language. */
30130
- const languageListSorted = this.swapCurrentLangToTheEndOfLanguageList(this.languageList);
30131
- return combineLatest(languageListSorted.map(language => this.translateService.getTranslation(language))).pipe(tap(translations => {
30132
- translations.forEach((languageTranslations, languageIndex) => {
30133
- this._translations[languageListSorted[languageIndex]] = languageTranslations;
30157
+ const languagesInOrder = this.swapCurrentLangToTheEndOfLanguageList(this.languageList);
30158
+ const keysFromConfig = this.collectI18nKeysFromConfig(this._config);
30159
+ const keys = Array.isArray(keysFromConfig) ? keysFromConfig : [];
30160
+ const translationObservables = languagesInOrder.map((lang) => {
30161
+ this.translateService.use(lang);
30162
+ return this.translateService.get(keys).pipe(map(translations => ({ lang, translations })));
30163
+ });
30164
+ return forkJoin(translationObservables).pipe(tap(results => {
30165
+ results.forEach(({ lang, translations }) => {
30166
+ this._translations[lang] = typeof translations === 'object' && translations !== null ? translations : {};
30134
30167
  });
30135
- }), mergeMap(() => iif(() => this._config.defaultLanguage != null, of(this.mapAttributes()), this.eportalLanguageService.fetchEportalLanguage$().pipe(map(eportalLanguage => eportalLanguage?.toLowerCase()), map(eportalLanguage => this.languageList.includes(eportalLanguage) ? eportalLanguage : 'de'), map(eportalLanguage => this.mapAttributes(eportalLanguage))))));
30168
+ }), mergeMap(() => {
30169
+ if (this._config?.defaultLanguage != null) {
30170
+ return of(this.mapAttributes());
30171
+ }
30172
+ return this.eportalLanguageService.fetchEportalLanguage$().pipe(map(lang => lang?.toLowerCase()), map(lang => (this.languageList.includes(lang) ? lang : 'de')), map(lang => this.mapAttributes(lang)));
30173
+ }));
30174
+ }
30175
+ collectI18nKeysFromConfig(config) {
30176
+ if (!config)
30177
+ return [];
30178
+ const keys = new Set();
30179
+ const visitLink = (linkCandidate) => {
30180
+ if (!linkCandidate || typeof linkCandidate !== 'object')
30181
+ return;
30182
+ const link = linkCandidate;
30183
+ if (typeof link.i18n === 'string')
30184
+ keys.add(link.i18n);
30185
+ if (link.iconLink && typeof link.iconLink.i18n === 'string')
30186
+ keys.add(link.iconLink.i18n);
30187
+ if (Array.isArray(link.childLinks))
30188
+ link.childLinks.forEach(visitLink);
30189
+ };
30190
+ const visitArray = (maybeArray) => {
30191
+ if (Array.isArray(maybeArray))
30192
+ maybeArray.forEach(visitLink);
30193
+ };
30194
+ visitArray(config.infoLinks);
30195
+ visitArray(config.profileLinks);
30196
+ visitArray(config.customButtonsLinks);
30197
+ return Array.from(keys);
30136
30198
  }
30137
30199
  swapCurrentLangToTheEndOfLanguageList(languageList) {
30138
30200
  const currentLangIndex = languageList.indexOf(this.currentLang);
30139
30201
  if (currentLangIndex === -1)
30140
30202
  return languageList;
30141
- const languageListSorted = [...languageList];
30203
+ const sorted = [...languageList];
30142
30204
  const lastIndex = languageList.length - 1;
30143
- languageListSorted[languageList.indexOf(this.currentLang)] = languageList[lastIndex];
30144
- languageListSorted[lastIndex] = this.currentLang;
30145
- return languageListSorted;
30205
+ sorted[currentLangIndex] = languageList[lastIndex];
30206
+ sorted[lastIndex] = this.currentLang;
30207
+ return sorted;
30146
30208
  }
30147
30209
  get currentLang() {
30148
30210
  return (this.translateService?.currentLang || this.translateService?.defaultLang);
@@ -30237,7 +30299,7 @@ class QdShellHeaderWidgetService {
30237
30299
  : {};
30238
30300
  }
30239
30301
  getChildLinks(linkObject) {
30240
- return linkObject.hasOwnProperty('childLinks')
30302
+ return linkObject && Object.prototype.hasOwnProperty.call(linkObject, 'childLinks')
30241
30303
  ? {
30242
30304
  childLinks: linkObject.childLinks.map(childLink => ({
30243
30305
  ...this.getMappedLinkTexts(childLink),
@@ -30249,7 +30311,11 @@ class QdShellHeaderWidgetService {
30249
30311
  : {};
30250
30312
  }
30251
30313
  getDefaultAttribute(configValue) {
30252
- return typeof configValue === 'boolean' ? (configValue ? 'true' : 'false') : configValue;
30314
+ if (typeof configValue === 'boolean')
30315
+ return configValue ? 'true' : 'false';
30316
+ if (configValue == null)
30317
+ return '';
30318
+ return String(configValue);
30253
30319
  }
30254
30320
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: QdShellHeaderWidgetService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
30255
30321
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: QdShellHeaderWidgetService });