@mediusinc/mng-commons 7.2.1-rc.0 → 7.3.0-rc.6

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 (23) hide show
  1. package/fesm2022/mediusinc-mng-commons-core.mjs +48 -10
  2. package/fesm2022/mediusinc-mng-commons-core.mjs.map +1 -1
  3. package/fesm2022/mediusinc-mng-commons-form.mjs +2 -4
  4. package/fesm2022/mediusinc-mng-commons-form.mjs.map +1 -1
  5. package/fesm2022/mediusinc-mng-commons-table-api.mjs.map +1 -1
  6. package/fesm2022/{mediusinc-mng-commons-table-column-toggle.component-BZU9-ZJV.mjs → mediusinc-mng-commons-table-column-toggle.component-4BDcYyDd.mjs} +2 -2
  7. package/fesm2022/{mediusinc-mng-commons-table-column-toggle.component-BZU9-ZJV.mjs.map → mediusinc-mng-commons-table-column-toggle.component-4BDcYyDd.mjs.map} +1 -1
  8. package/fesm2022/{mediusinc-mng-commons-table-mediusinc-mng-commons-table-D-cGtZ6e.mjs → mediusinc-mng-commons-table-mediusinc-mng-commons-table-DoXp48ZT.mjs} +28 -12
  9. package/fesm2022/mediusinc-mng-commons-table-mediusinc-mng-commons-table-DoXp48ZT.mjs.map +1 -0
  10. package/fesm2022/mediusinc-mng-commons-table.mjs +1 -1
  11. package/fesm2022/mediusinc-mng-commons-tableview-api.mjs +18 -0
  12. package/fesm2022/mediusinc-mng-commons-tableview-api.mjs.map +1 -1
  13. package/fesm2022/mediusinc-mng-commons-tableview.mjs +27 -11
  14. package/fesm2022/mediusinc-mng-commons-tableview.mjs.map +1 -1
  15. package/i18n/en.json +2 -1
  16. package/i18n/sl.json +2 -1
  17. package/package.json +1 -1
  18. package/types/mediusinc-mng-commons-core.d.ts +5 -0
  19. package/types/mediusinc-mng-commons-table.d.ts +5 -2
  20. package/types/mediusinc-mng-commons-tableview-api.d.ts +12 -2
  21. package/types/mediusinc-mng-commons-tableview.d.ts +4 -1
  22. package/version-info.json +5 -5
  23. package/fesm2022/mediusinc-mng-commons-table-mediusinc-mng-commons-table-D-cGtZ6e.mjs.map +0 -1
@@ -12,8 +12,8 @@ import 'reflect-metadata';
12
12
  import { takeUntilDestroyed, toObservable as toObservable$1 } from '@angular/core/rxjs-interop';
13
13
  import { Title } from '@angular/platform-browser';
14
14
  import { Router, NavigationEnd, NavigationStart, RouteConfigLoadStart, RouteConfigLoadEnd, NavigationCancel, NavigationError } from '@angular/router';
15
+ import { FilterService, FilterMatchMode as FilterMatchMode$1, MessageService, ConfirmationService } from 'primeng/api';
15
16
  import { PrimeNG } from 'primeng/config';
16
- import { MessageService, ConfirmationService } from 'primeng/api';
17
17
  import { DialogService } from 'primeng/dynamicdialog';
18
18
 
19
19
  class OverflowDirective {
@@ -406,17 +406,21 @@ function dataListParamsToUrlQuery(params, defaults = {
406
406
  offset: 0
407
407
  }, opts) {
408
408
  const urlParams = {};
409
+ const limitQpKey = (opts?.queryParamPrepend ?? '') + 'limit';
410
+ const offsetQpKey = (opts?.queryParamPrepend ?? '') + 'offset';
411
+ const searchQpKey = (opts?.queryParamPrepend ?? '') + 'q';
412
+ const sortQpKey = (opts?.queryParamPrepend ?? '') + 'sort';
409
413
  if (params.limit && params.limit !== defaults?.limit) {
410
- urlParams['limit'] = params.limit;
414
+ urlParams[limitQpKey] = params.limit;
411
415
  }
412
416
  else if (!opts?.skipPresetDefaultsLimit) {
413
- urlParams['limit'] = defaults?.limit;
417
+ urlParams[limitQpKey] = defaults?.limit;
414
418
  }
415
419
  if (params.offset && params.offset !== defaults?.offset) {
416
- urlParams['offset'] = params.offset;
420
+ urlParams[offsetQpKey] = params.offset;
417
421
  }
418
422
  if (params.search && params.search !== defaults?.search) {
419
- urlParams['q'] = `${params.searchCaseSensitive ? `cs:` : ''}${params.search}`;
423
+ urlParams[searchQpKey] = `${params.searchCaseSensitive ? `cs:` : ''}${params.search}`;
420
424
  }
421
425
  if (params.sort && Array.isArray(params.sort) && params.sort.length > 0) {
422
426
  if (defaults?.sort == null ||
@@ -424,7 +428,7 @@ function dataListParamsToUrlQuery(params, defaults = {
424
428
  defaults.sort.length === 0 ||
425
429
  params.sort.length !== defaults.sort.length ||
426
430
  defaults.sort.some((ds, idx) => ds.property !== params.sort[idx].property || (ds.ascending ?? true) !== (params.sort[idx].ascending ?? true))) {
427
- urlParams['sort'] = dataListParamsSortToUrlQuery(params);
431
+ urlParams[sortQpKey] = dataListParamsSortToUrlQuery(params);
428
432
  }
429
433
  }
430
434
  if (params.filters) {
@@ -582,20 +586,24 @@ function dataListParamsFilterToUrlQuery(paramFilter, allowNull = false) {
582
586
  */
583
587
  function fromUrlQueryToDataListParams(urlParams, opts) {
584
588
  const params = {};
589
+ const limitQpKey = (opts?.queryParamPrepend ?? '') + 'limit';
590
+ const offsetQpKey = (opts?.queryParamPrepend ?? '') + 'offset';
591
+ const searchQpKey = (opts?.queryParamPrepend ?? '') + 'q';
592
+ const sortQpKey = (opts?.queryParamPrepend ?? '') + 'sort';
585
593
  Object.entries(urlParams).forEach(([urlParamKey, urlParamValue]) => {
586
- if (urlParamKey === 'limit') {
594
+ if (urlParamKey === limitQpKey) {
587
595
  params.limit = +urlParamValue;
588
596
  if (isNaN(params.limit) || params.limit < 0) {
589
597
  delete params.limit;
590
598
  }
591
599
  }
592
- else if (urlParamKey === 'offset') {
600
+ else if (urlParamKey === offsetQpKey) {
593
601
  params.offset = +urlParamValue;
594
602
  if (isNaN(params.offset) || params.offset < 0) {
595
603
  delete params.offset;
596
604
  }
597
605
  }
598
- else if (urlParamKey === 'q') {
606
+ else if (urlParamKey === searchQpKey) {
599
607
  if (typeof urlParamValue === 'string' && urlParamValue.length > 0) {
600
608
  const searchQuery = urlParamValue.startsWith('cs:') || urlParamValue.startsWith('ci:') ? urlParamValue.substring(3) : urlParamValue;
601
609
  const caseSensitive = urlParamValue.startsWith('cs:');
@@ -613,7 +621,7 @@ function fromUrlQueryToDataListParams(urlParams, opts) {
613
621
  }
614
622
  }
615
623
  }
616
- else if (urlParamKey === 'sort') {
624
+ else if (urlParamKey === sortQpKey) {
617
625
  if (typeof urlParamValue === 'string') {
618
626
  params.sort = urlParamValue.split(',').map(s => {
619
627
  const [direction, property] = s.split(':');
@@ -2466,6 +2474,9 @@ class TypeRegistry {
2466
2474
  this._typeMap[typeName] = type;
2467
2475
  }
2468
2476
  }
2477
+ clearTypes() {
2478
+ Object.keys(this._typeMap).forEach(key => delete this._typeMap[key]);
2479
+ }
2469
2480
  registerEnums(enums) {
2470
2481
  for (const key in enums) {
2471
2482
  this.registerEnum(enums[key], key);
@@ -2481,6 +2492,9 @@ class TypeRegistry {
2481
2492
  this._enumMap[enumName] = enumType;
2482
2493
  }
2483
2494
  }
2495
+ clearEnums() {
2496
+ Object.keys(this._enumMap).forEach(key => delete this._enumMap[key]);
2497
+ }
2484
2498
  }
2485
2499
 
2486
2500
  const BROWSER_STORAGE_IT = new InjectionToken('BROWSER_STORAGE');
@@ -2488,6 +2502,7 @@ const BROWSER_STORAGE_IT = new InjectionToken('BROWSER_STORAGE');
2488
2502
  const COMMONS_MODULE_CONFIG_IT = new InjectionToken('COMMONS_MODULE_CONFIG');
2489
2503
 
2490
2504
  class CommonsService {
2505
+ #filterService;
2491
2506
  getDefaultLocale() {
2492
2507
  const browserLang = this.translate.getBrowserLang();
2493
2508
  if (browserLang && this.appLocales().some(l => l === browserLang)) {
@@ -2546,6 +2561,7 @@ class CommonsService {
2546
2561
  this.moduleConfig = inject(COMMONS_MODULE_CONFIG_IT, { optional: true });
2547
2562
  this.localStorage = inject(BROWSER_STORAGE_IT);
2548
2563
  this.destroyRef = inject(DestroyRef);
2564
+ this.#filterService = inject(FilterService);
2549
2565
  // breadcrumbs
2550
2566
  this.breadcrumbHome = signal({
2551
2567
  icon: 'pi pi-home',
@@ -2590,6 +2606,7 @@ class CommonsService {
2590
2606
  .stream('mngPrime')
2591
2607
  .pipe(takeUntilDestroyed())
2592
2608
  .subscribe((value) => this.primengConfig.setTranslation(value));
2609
+ this.#registerCustomFilters(this.#filterService);
2593
2610
  }
2594
2611
  initialize() {
2595
2612
  this.logger.debug('Initialize');
@@ -2791,6 +2808,27 @@ class CommonsService {
2791
2808
  titlePieces.push(this.translate.instant('app.name'));
2792
2809
  return titlePieces.join(' - ');
2793
2810
  }
2811
+ #registerCustomFilters(filterService) {
2812
+ // add custom modes
2813
+ filterService.register(FilterMatchMode.NotIn, (value, filter) => {
2814
+ if (value === undefined || value === null)
2815
+ return true;
2816
+ if (filter === undefined || filter === null || filter.length === 0)
2817
+ return true;
2818
+ return !filter.includes(value);
2819
+ });
2820
+ filterService.register(FilterMatchMode.Exists, (value) => {
2821
+ return value !== null && value !== undefined && value !== '';
2822
+ });
2823
+ filterService.register(FilterMatchMode.DoesNotExist, (value) => {
2824
+ return value === null || value === undefined || value === '';
2825
+ });
2826
+ // map existing modes to ours
2827
+ filterService.register(FilterMatchMode.LessThan, filterService.filters[FilterMatchMode$1.LESS_THAN]);
2828
+ filterService.register(FilterMatchMode.LessThanOrEqualTo, filterService.filters[FilterMatchMode$1.LESS_THAN_OR_EQUAL_TO]);
2829
+ filterService.register(FilterMatchMode.GreaterThan, filterService.filters[FilterMatchMode$1.GREATER_THAN]);
2830
+ filterService.register(FilterMatchMode.GreaterThanOrEqualTo, filterService.filters[FilterMatchMode$1.GREATER_THAN_OR_EQUAL_TO]);
2831
+ }
2794
2832
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: CommonsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
2795
2833
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.0.8", ngImport: i0, type: CommonsService }); }
2796
2834
  }