@mediusinc/mng-commons 0.19.0 → 0.19.2
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.
- package/esm2020/lib/components/layout/services/main-layout.component.service.mjs +3 -1
- package/esm2020/lib/components/tableview/table/table.component.mjs +21 -15
- package/esm2020/lib/models/config.model.mjs +1 -1
- package/esm2020/lib/models/menu.model.mjs +1 -1
- package/esm2020/lib/services/commons.service.mjs +67 -2
- package/fesm2015/mediusinc-mng-commons.mjs +91 -21
- package/fesm2015/mediusinc-mng-commons.mjs.map +1 -1
- package/fesm2020/mediusinc-mng-commons.mjs +88 -15
- package/fesm2020/mediusinc-mng-commons.mjs.map +1 -1
- package/lib/models/config.model.d.ts +1 -0
- package/lib/models/menu.model.d.ts +3 -0
- package/lib/services/commons.service.d.ts +4 -0
- package/package.json +1 -1
- package/version-info.json +5 -5
|
@@ -7362,6 +7362,7 @@ class MngCommonsService {
|
|
|
7362
7362
|
this._menuModeSubject = new BehaviorSubject(this._menuMode);
|
|
7363
7363
|
this._menuItems = [];
|
|
7364
7364
|
this._menuPinEnabled = false;
|
|
7365
|
+
this._menuSidebarSlim = false;
|
|
7365
7366
|
this._menuActiveKeySubject = new Subject();
|
|
7366
7367
|
this._menuResetSubject = new Subject();
|
|
7367
7368
|
// breadcrumbs
|
|
@@ -7473,6 +7474,9 @@ class MngCommonsService {
|
|
|
7473
7474
|
get menuPinEnabled() {
|
|
7474
7475
|
return this._menuPinEnabled;
|
|
7475
7476
|
}
|
|
7477
|
+
get menuSidebarSlim() {
|
|
7478
|
+
return this._menuSidebarSlim;
|
|
7479
|
+
}
|
|
7476
7480
|
// BREADCRUMB section
|
|
7477
7481
|
get breadcrumbHome$() {
|
|
7478
7482
|
return this.breadcrumbHomeSubject.asObservable();
|
|
@@ -7513,6 +7517,7 @@ class MngCommonsService {
|
|
|
7513
7517
|
this._menuModeSubject.next(this._menuMode);
|
|
7514
7518
|
this._menuItems = this.moduleConfig?.menu?.menuItems ?? [];
|
|
7515
7519
|
this._menuPinEnabled = this.moduleConfig?.menu?.pinEnabled ?? false;
|
|
7520
|
+
this._menuSidebarSlim = this.moduleConfig?.menu?.sidebarSlim ?? false;
|
|
7516
7521
|
// visual
|
|
7517
7522
|
this._colorScheme = this.moduleConfig?.app?.colorScheme ?? 'light';
|
|
7518
7523
|
// ripple
|
|
@@ -7550,6 +7555,56 @@ class MngCommonsService {
|
|
|
7550
7555
|
this._menuResetSubject.next(null);
|
|
7551
7556
|
}
|
|
7552
7557
|
// BREADCRUMB actions
|
|
7558
|
+
findBreadcrumbItem(item) {
|
|
7559
|
+
const items = this.breadcrumbsSubject.value;
|
|
7560
|
+
if (item.id) {
|
|
7561
|
+
return items.find(i => i.id && i.id === item.id) ?? null;
|
|
7562
|
+
}
|
|
7563
|
+
else if (item.routerLink) {
|
|
7564
|
+
const routerLinkStr = Array.isArray(item.routerLink) ? item.routerLink.join('/') : item.routerLink;
|
|
7565
|
+
return items.find(i => i.routerLink && (Array.isArray(i.routerLink) ? i.routerLink.join('/') : i.routerLink) === routerLinkStr) ?? null;
|
|
7566
|
+
}
|
|
7567
|
+
else if (item.positionIndex) {
|
|
7568
|
+
return items.find(i => i.positionIndex && i.positionIndex === i.positionIndex) ?? null;
|
|
7569
|
+
}
|
|
7570
|
+
else if (item.label) {
|
|
7571
|
+
return items.find(i => i.label && i.label === i.label) ?? null;
|
|
7572
|
+
}
|
|
7573
|
+
else if (item.icon) {
|
|
7574
|
+
return items.find(i => i.icon && i.icon === i.icon) ?? null;
|
|
7575
|
+
}
|
|
7576
|
+
return null;
|
|
7577
|
+
}
|
|
7578
|
+
updateBreadcrumbItem(item) {
|
|
7579
|
+
const items = [...this.breadcrumbsSubject.value];
|
|
7580
|
+
let posIdx = -1;
|
|
7581
|
+
if (item.id) {
|
|
7582
|
+
posIdx = items.findIndex(i => i.id && i.id === item.id);
|
|
7583
|
+
}
|
|
7584
|
+
else if (item.routerLink) {
|
|
7585
|
+
const routerLinkStr = Array.isArray(item.routerLink) ? item.routerLink.join('/') : item.routerLink;
|
|
7586
|
+
posIdx = items.findIndex(i => i.routerLink && (Array.isArray(i.routerLink) ? i.routerLink.join('/') : i.routerLink) === routerLinkStr);
|
|
7587
|
+
}
|
|
7588
|
+
else if (item.positionIndex) {
|
|
7589
|
+
posIdx = items.findIndex(i => i.positionIndex && i.positionIndex === i.positionIndex);
|
|
7590
|
+
}
|
|
7591
|
+
else if (item.label) {
|
|
7592
|
+
posIdx = items.findIndex(i => i.label && i.label === i.label);
|
|
7593
|
+
}
|
|
7594
|
+
else if (item.icon) {
|
|
7595
|
+
posIdx = items.findIndex(i => i.icon && i.icon === i.icon);
|
|
7596
|
+
}
|
|
7597
|
+
if (posIdx < 0) {
|
|
7598
|
+
return false;
|
|
7599
|
+
}
|
|
7600
|
+
items[posIdx] = {
|
|
7601
|
+
...items[posIdx],
|
|
7602
|
+
...item,
|
|
7603
|
+
updated: true
|
|
7604
|
+
};
|
|
7605
|
+
this.breadcrumbsSubject.next(items);
|
|
7606
|
+
return true;
|
|
7607
|
+
}
|
|
7553
7608
|
updateBreadcrumbs() {
|
|
7554
7609
|
if (this.breadcrumbsTranslateSubscription) {
|
|
7555
7610
|
this.breadcrumbsTranslateSubscription.unsubscribe();
|
|
@@ -7574,11 +7629,14 @@ class MngCommonsService {
|
|
|
7574
7629
|
}
|
|
7575
7630
|
const breadcrumbs = [];
|
|
7576
7631
|
this.generateBreadcrumbs(rootRoute, [], breadcrumbs);
|
|
7632
|
+
breadcrumbs.forEach((b, idx) => {
|
|
7633
|
+
b.positionIndex = idx;
|
|
7634
|
+
});
|
|
7577
7635
|
const i18nKeys = breadcrumbs.filter(b => typeof b.label === 'string').map(b => b.label);
|
|
7578
7636
|
if (i18nKeys.length > 0) {
|
|
7579
7637
|
this.breadcrumbsTranslateSubscription = this.translate.get(i18nKeys).subscribe(i18n => {
|
|
7580
7638
|
// Construct the breadcrumb hierarchy
|
|
7581
|
-
breadcrumbs.forEach(b => {
|
|
7639
|
+
breadcrumbs.forEach((b, idx) => {
|
|
7582
7640
|
if (b.label && i18n[b.label]) {
|
|
7583
7641
|
b.label = i18n[b.label];
|
|
7584
7642
|
}
|
|
@@ -7644,8 +7702,14 @@ class MngCommonsService {
|
|
|
7644
7702
|
this.generateBreadcrumbs(route.firstChild, routeUrlSegments, breadcrumbs);
|
|
7645
7703
|
}
|
|
7646
7704
|
createBreadcrumb(routeUrl, routeBreadcrumb, includeHome = false) {
|
|
7705
|
+
const existingBreadcrumb = this.findBreadcrumbItem({ routerLink: routeUrl });
|
|
7706
|
+
if (existingBreadcrumb?.updated) {
|
|
7707
|
+
return existingBreadcrumb;
|
|
7708
|
+
}
|
|
7647
7709
|
if (typeof routeBreadcrumb === 'string') {
|
|
7710
|
+
// check for updated existing breadcrumb
|
|
7648
7711
|
return {
|
|
7712
|
+
id: routeUrl,
|
|
7649
7713
|
label: routeBreadcrumb,
|
|
7650
7714
|
routerLink: routeUrl
|
|
7651
7715
|
};
|
|
@@ -7658,6 +7722,7 @@ class MngCommonsService {
|
|
|
7658
7722
|
if (typeof routeBreadcrumb.routerLink === 'undefined') {
|
|
7659
7723
|
routeBreadcrumb.routerLink = routeUrl;
|
|
7660
7724
|
}
|
|
7725
|
+
routeBreadcrumb.id = routeUrl;
|
|
7661
7726
|
return routeBreadcrumb;
|
|
7662
7727
|
}
|
|
7663
7728
|
}
|
|
@@ -9648,14 +9713,16 @@ class MngTableComponent {
|
|
|
9648
9713
|
}
|
|
9649
9714
|
ngOnInit() {
|
|
9650
9715
|
this.viewContainer = this.viewContainerInit ?? this.viewContainerService ?? undefined;
|
|
9716
|
+
// Used for configs within this method and is not dynamically set by TableDynamicDescriptor
|
|
9717
|
+
const baseConfigDescriptor = this.initialDescriptor;
|
|
9651
9718
|
if (!(this.initialDescriptor instanceof TableDynamicDescriptor)) {
|
|
9652
9719
|
this.descriptor = this.initialDescriptor;
|
|
9653
9720
|
}
|
|
9654
9721
|
// map row settings
|
|
9655
9722
|
this.filterDescriptors = this.descriptor?.columns.filter(c => typeof c.filterDescriptor !== 'undefined').map(c => c.filterDescriptor) ?? [];
|
|
9656
9723
|
this.hasColumnFilters = this.filterDescriptors.length > 0;
|
|
9657
|
-
this.rows =
|
|
9658
|
-
this.rowsPerPageOptions =
|
|
9724
|
+
this.rows = baseConfigDescriptor?.defaultNumRows ?? 25;
|
|
9725
|
+
this.rowsPerPageOptions = baseConfigDescriptor?.rowsPerPageOptions ?? [25, 50, 100];
|
|
9659
9726
|
// process actions
|
|
9660
9727
|
for (const action of this.actions) {
|
|
9661
9728
|
switch (action.position) {
|
|
@@ -9669,14 +9736,14 @@ class MngTableComponent {
|
|
|
9669
9736
|
}
|
|
9670
9737
|
this.showInlineActionsColumn = typeof this.columnActionComponent !== 'undefined' || this.rowInlineActions.length > 0;
|
|
9671
9738
|
// define all styles
|
|
9672
|
-
this.className =
|
|
9673
|
-
this.tableFullHeightOffset =
|
|
9674
|
-
this.rowHeight =
|
|
9739
|
+
this.className = baseConfigDescriptor?.className ?? '';
|
|
9740
|
+
this.tableFullHeightOffset = baseConfigDescriptor?.tableFullHeightOffset ?? null;
|
|
9741
|
+
this.rowHeight = baseConfigDescriptor?.rowHeight ?? null;
|
|
9675
9742
|
if (typeof this.isColumnClickable === 'undefined') {
|
|
9676
9743
|
// define if cell click is being observed via output
|
|
9677
9744
|
this.isColumnClickable = this.rowClickActions.length > 0 || this.cellClickEventEmitter.observed;
|
|
9678
9745
|
}
|
|
9679
|
-
switch (
|
|
9746
|
+
switch (baseConfigDescriptor?.size) {
|
|
9680
9747
|
case TableSizeEnum.Small:
|
|
9681
9748
|
this.className += ' p-datatable-sm';
|
|
9682
9749
|
break;
|
|
@@ -9684,17 +9751,17 @@ class MngTableComponent {
|
|
|
9684
9751
|
this.className += ' p-datatable-lg';
|
|
9685
9752
|
break;
|
|
9686
9753
|
}
|
|
9687
|
-
if (
|
|
9754
|
+
if (baseConfigDescriptor?.hasGridlines) {
|
|
9688
9755
|
this.className += ' p-datatable-gridlines';
|
|
9689
9756
|
}
|
|
9690
|
-
if (
|
|
9691
|
-
this.columnActionMinWidth = StylesUtil.calculateTableColumnActionWidth(
|
|
9757
|
+
if (baseConfigDescriptor && !this.columnActionMinWidth) {
|
|
9758
|
+
this.columnActionMinWidth = StylesUtil.calculateTableColumnActionWidth(baseConfigDescriptor, this.rowInlineActions);
|
|
9692
9759
|
}
|
|
9693
9760
|
// check if infinite scroll
|
|
9694
9761
|
let paginationMode = TablePaginationModeEnum.None;
|
|
9695
|
-
if (typeof
|
|
9762
|
+
if (typeof baseConfigDescriptor?.paginationMode !== 'undefined') {
|
|
9696
9763
|
// descriptor choice is the most strong - if defined, use this value
|
|
9697
|
-
paginationMode =
|
|
9764
|
+
paginationMode = baseConfigDescriptor.paginationMode;
|
|
9698
9765
|
}
|
|
9699
9766
|
else if (typeof this.dataProvider !== 'undefined') {
|
|
9700
9767
|
// when data provider is used, use pagination
|
|
@@ -9702,8 +9769,8 @@ class MngTableComponent {
|
|
|
9702
9769
|
}
|
|
9703
9770
|
if (paginationMode === TablePaginationModeEnum.InfiniteScroll) {
|
|
9704
9771
|
this.infiniteScroll = true;
|
|
9705
|
-
this.tableFullHeightOffset =
|
|
9706
|
-
this.rowHeight =
|
|
9772
|
+
this.tableFullHeightOffset = baseConfigDescriptor?.tableFullHeightOffset ?? 315;
|
|
9773
|
+
this.rowHeight = baseConfigDescriptor?.rowHeight ?? 45;
|
|
9707
9774
|
this.useQueryParams = false;
|
|
9708
9775
|
}
|
|
9709
9776
|
else if (paginationMode === TablePaginationModeEnum.Pagination) {
|
|
@@ -9757,7 +9824,7 @@ class MngTableComponent {
|
|
|
9757
9824
|
}
|
|
9758
9825
|
const initialQueryParamMap = this.route.snapshot.queryParamMap;
|
|
9759
9826
|
if (this.useQueryParams &&
|
|
9760
|
-
((!initialQueryParamMap.has('sort') &&
|
|
9827
|
+
((!initialQueryParamMap.has('sort') && baseConfigDescriptor?.hasDefaultSort) ||
|
|
9761
9828
|
(!initialQueryParamMap.has('filter') && this.filterDescriptors.some(fd => fd.hasDefaultValue)))) {
|
|
9762
9829
|
// default sort/filters are applied, no additional filtering/sorting is specified in query param
|
|
9763
9830
|
// redirect must be done at first step
|
|
@@ -9891,6 +9958,10 @@ class MngTableComponent {
|
|
|
9891
9958
|
this.descriptor = this.initialDescriptor.toTableDescriptorFromData(res);
|
|
9892
9959
|
this.filterDescriptors = this.descriptor.columns.filter(c => typeof c.filterDescriptor !== 'undefined').map(c => c.filterDescriptor);
|
|
9893
9960
|
this.hasColumnFilters = this.filterDescriptors.length > 0;
|
|
9961
|
+
this.isPagination = false;
|
|
9962
|
+
this.infiniteScroll = false;
|
|
9963
|
+
this.rows = this.initialDescriptor.defaultNumRows;
|
|
9964
|
+
this.rowsPerPageOptions = this.initialDescriptor.rowsPerPageOptions;
|
|
9894
9965
|
// } else {
|
|
9895
9966
|
// this.descriptor = this.initialDescriptor.onDataReceivedTypeBuilding(res);
|
|
9896
9967
|
}
|
|
@@ -10908,6 +10979,8 @@ class MngMainLayoutComponentService {
|
|
|
10908
10979
|
this._pinActiveSubject = new BehaviorSubject(this._pinActive);
|
|
10909
10980
|
this._innerWidth = 1920;
|
|
10910
10981
|
this._innerWidthSubject = new BehaviorSubject(this._innerWidth);
|
|
10982
|
+
this.sidebarActive = !mngCommons.menuSidebarSlim;
|
|
10983
|
+
this.sidebarStatic = !mngCommons.menuSidebarSlim;
|
|
10911
10984
|
}
|
|
10912
10985
|
get overlayMenuActive$() {
|
|
10913
10986
|
return this._overlayMenuActiveSubject.asObservable();
|