Skip to content

Commit 05c5b16

Browse files
committed
[NAE-2119] Fix MenuItem
1 parent acc9a97 commit 05c5b16

File tree

3 files changed

+43
-10
lines changed

3 files changed

+43
-10
lines changed

projects/netgrif-components-core/src/lib/navigation/model/uri-resource.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11

22
export interface UriNodeResource {
3-
id: string;
4-
uriPath: string;
3+
id?: string;
4+
uriPath?: string;
5+
path: string;
56
name: string;
67
parentId: string;
7-
parent: UriNodeResource;
8+
parent?: UriNodeResource;
89
childrenId: Set<string>;
9-
children: Set<UriNodeResource>;
10+
children?: Set<UriNodeResource>;
1011
level: number;
11-
contentTypes: Set<UriContentType>
12+
contentTypes?: Set<UriContentType>
1213
}
1314

1415
export enum UriContentType {

projects/netgrif-components-core/src/lib/navigation/navigation-double-drawer/abstract-navigation-double-drawer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ export abstract class AbstractNavigationDoubleDrawerComponent implements OnInit,
526526

527527
protected getTranslation(value: I18nFieldValue): string {
528528
const locale = this._translateService.currentLang.split('-')[0];
529-
return locale in value.translations ? value.translations[locale] : value.defaultValue;
529+
return value.translations?.[locale] ?? value.defaultValue;
530530
}
531531

532532
protected resolveAccessRoles(filter: Case, roleType: string): Array<RoleAccess> | undefined {

projects/netgrif-components-core/src/lib/navigation/service/uri-resource.service.ts

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,53 @@ export class UriResourceService extends AbstractResourceService {
2020

2121
public getRoot(): Observable<UriNodeResource> {
2222
return this._resourceProvider.get$('uri/root', this.SERVER_URL).pipe(
23-
map(r => this.changeType(r, 'uriNode')));
23+
map(r => this.changeType(r, 'uriNode')),
24+
map((r: UriNodeResource) => {
25+
if (r.path) {
26+
r.uriPath = r.path;
27+
r.id = r.path;
28+
}
29+
return r;
30+
}));
2431
}
2532

2633
public getByLevel(level: number): Observable<Array<UriNodeResource>> {
2734
return this._resourceProvider.get$('uri/level/' + level, this.SERVER_URL).pipe(
28-
map(r => this.changeType(r, 'uriNodes')));
35+
map(r => this.changeType(r, 'uriNodes')),
36+
map((ar: Array<UriNodeResource>) => {
37+
return ar.map(r => {
38+
if (r.path) {
39+
r.uriPath = r.path;
40+
r.id = r.path;
41+
}
42+
return r;
43+
})
44+
}));
2945
}
3046

3147
public getNodesByParent(parentId: string): Observable<Array<UriNodeResource>> {
3248
return this._resourceProvider.get$('uri/parent/' + parentId, this.SERVER_URL).pipe(
33-
map(r => this.changeType(r, 'uriNodes')));
49+
map(r => this.changeType(r, 'uriNodes')),
50+
map((ar: Array<UriNodeResource>) => {
51+
return ar.map(r => {
52+
if (r.path) {
53+
r.uriPath = r.path;
54+
r.id = r.path;
55+
}
56+
return r;
57+
})
58+
}));
3459
}
3560

3661
public getNodeByUri(uriPath: string): Observable<UriNodeResource> {
3762
return this._resourceProvider.get$('uri/' + btoa(uriPath), this.SERVER_URL).pipe(
38-
map(r => this.changeType(r, 'uriNode')));
63+
map(r => this.changeType(r, 'uriNode')),
64+
map((r: UriNodeResource) => {
65+
if (r.path) {
66+
r.uriPath = r.path;
67+
r.id = r.path;
68+
}
69+
return r;
70+
}));
3971
}
4072
}

0 commit comments

Comments
 (0)