Skip to content

Commit 37711a2

Browse files
committed
Merge remote-tracking branch 'origin/release/7.0.0-rev8' into release/7.0.0-rev9
2 parents f6d7bf9 + 07ffba7 commit 37711a2

File tree

51 files changed

+362
-122
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+362
-122
lines changed

projects/netgrif-components-core/src/lib/navigation/dashboard/abstract-dashboard.component.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,10 +264,15 @@ export abstract class AbstractDashboardComponent {
264264
return;
265265
}
266266
const itemRoute = this._doubleDrawerNavigationService.getItemRoutingPath(menuItemCase);
267-
this._pathService.activePath = this.getFieldValue(menuItemCase, GroupNavigationConstants.ITEM_FIELD_ID_NODE_PATH);
268267
const nodePath = this.getFieldValue(menuItemCase, GroupNavigationConstants.ITEM_FIELD_ID_NODE_PATH);
269-
if (nodePath) {
268+
const menuItem = this._doubleDrawerNavigationService.resolveItemCaseToNavigationItem(menuItemCase);
269+
if (menuItem) {
270+
this._doubleDrawerNavigationService.currentNavigationItem = menuItem;
271+
}
272+
if (menuItemCase.immediateData.find(f => f.stringId === GroupNavigationConstants.ITEM_FIELD_ID_HAS_CHILDREN)?.value && nodePath) {
270273
this._pathService.activePath = nodePath;
274+
} else if (nodePath) {
275+
this._pathService.activePath = this._doubleDrawerNavigationService.extractParentPath(nodePath);
271276
}
272277
this._router.navigate([itemRoute]);
273278
} else {

projects/netgrif-components-core/src/lib/navigation/group-navigation-component-resolver/group-navigation-component-resolver.service.spec.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {LoggerService} from '../../logger/services/logger.service';
66
import {TestMockDependenciesModule} from '../../utility/tests/test-mock-dependencies.module';
77
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
88
import {HttpClientTestingModule} from '@angular/common/http/testing';
9+
import {PathService} from '../service/path.service';
910

1011
describe('GroupNavigationComponentResolverService', () => {
1112
let service: GroupNavigationComponentResolverService;
@@ -46,8 +47,9 @@ class TestPortalComponent {
4647
export class TestGroupNavigationComponentResolverService extends GroupNavigationComponentResolverService {
4748

4849
constructor(taskResourceService: TaskResourceService,
50+
pathService: PathService,
4951
log: LoggerService) {
50-
super(taskResourceService, log);
52+
super(taskResourceService, pathService, log);
5153
}
5254

5355
protected resolveViewComponent(navigationItemTaskData: any): Type<any> {

projects/netgrif-components-core/src/lib/navigation/group-navigation-component-resolver/group-navigation-component-resolver.service.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import {TaskResourceService} from '../../resources/engine-endpoint/task-resource
66
import {LoggerService} from '../../logger/services/logger.service';
77
import {DataGroup} from '../../resources/interface/data-groups';
88
import {HttpErrorResponse} from '@angular/common/http';
9+
import { PathService } from '../service/path.service';
910

1011
export abstract class GroupNavigationComponentResolverService {
1112

1213
protected constructor(protected _taskResourceService: TaskResourceService,
14+
protected _pathService: PathService,
1315
protected _log: LoggerService) {
1416
}
1517

@@ -19,6 +21,9 @@ export abstract class GroupNavigationComponentResolverService {
1921
const result = new ReplaySubject<ComponentPortal<any>>(1);
2022
this._taskResourceService.getData(taskId).subscribe(taskData => {
2123
try {
24+
if (!this._pathService.isMenuResolverClosed) {
25+
this._pathService.datafieldsForMenuResolver = taskData;
26+
}
2227
result.next(new ComponentPortal(
2328
this.resolveViewComponent(taskData),
2429
null,
@@ -41,6 +46,9 @@ export abstract class GroupNavigationComponentResolverService {
4146
}
4247

4348
private forwardError(result: Subject<any>, error: Error): void {
49+
if (!this._pathService.isMenuResolverClosed) {
50+
this._pathService.datafieldsForMenuResolverError = error;
51+
}
4452
result.error(error instanceof HttpErrorResponse ? error.error.message : error.message);
4553
result.complete();
4654
}

projects/netgrif-components-core/src/lib/navigation/model/group-navigation-constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export enum GroupNavigationConstants {
123123
/**
124124
* Boolean field, that is true to use default headers configuration for case view
125125
* */
126-
ITEM_FIELD_ID_USE_CASE_DEFAULT_HEADERS = 'use_default_headers',
126+
ITEM_FIELD_ID_USE_CASE_DEFAULT_HEADERS = 'use_case_default_headers',
127127

128128
/**
129129
* Text field, that contains default header metadata separated by comma for case view as a value

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

Lines changed: 48 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {TranslateService} from '@ngx-translate/core';
55
import {ResizeEvent} from 'angular-resizable-element';
66
import {Observable, Subscription} from 'rxjs';
77
import {filter, take} from 'rxjs/operators';
8-
import {AccessService} from '../../authorization/permission/access.service';
98
import {ConfigurationService} from '../../configuration/configuration.service';
109
import {ImpersonationUserSelectService} from '../../impersonation/services/impersonation-user-select.service';
1110
import {ImpersonationService} from '../../impersonation/services/impersonation.service';
@@ -32,6 +31,8 @@ import {
3231
} from '../model/navigation-menu-events';
3332
import {DoubleDrawerNavigationService} from "./service/double-drawer-navigation.service";
3433
import {GroupNavigationConstants} from "../model/group-navigation-constants";
34+
import {extractFieldValueFromData} from "../utility/navigation-item-task-utility-methods";
35+
import {LoadingEmitter} from "../../utility/loading-emitter";
3536

3637
@Component({
3738
selector: 'ncc-abstract-navigation-double-drawer',
@@ -72,6 +73,7 @@ export abstract class AbstractNavigationDoubleDrawerComponent implements OnInit,
7273
* Siblings of the node are on the left, children are on the right
7374
*/
7475
protected _currentPath: string;
76+
protected _pathResolverLoading$: LoadingEmitter;
7577

7678
protected _configLeftMenu: ConfigDoubleMenu = {
7779
mode: 'side',
@@ -113,6 +115,7 @@ export abstract class AbstractNavigationDoubleDrawerComponent implements OnInit,
113115
this._navigationService.itemLoaded$.subscribe((itemLoadedEvent: MenuItemLoadedEvent) => {
114116
this.itemLoaded.emit(itemLoadedEvent);
115117
})
118+
this._pathResolverLoading$ = new LoadingEmitter();
116119
}
117120

118121
public ngOnInit(): void {
@@ -125,10 +128,12 @@ export abstract class AbstractNavigationDoubleDrawerComponent implements OnInit,
125128
});
126129

127130
this._userService.user$.pipe(filter(u => !!u && u.id !== ''), take(1)).subscribe(() => {
131+
this.resolveInitialValueOfPath();
132+
128133
this._currentPathSubscription = this._pathService.activePath$.subscribe(path => {
129-
if (path !== this.currentPath) {
134+
if (path !== this.currentPath && !this._pathResolverLoading$.isActive) {
130135
this.currentPath = path;
131-
} else {
136+
} else if (!this._pathResolverLoading$.isActive) {
132137
this.openAvailableView();
133138
}
134139
});
@@ -151,8 +156,6 @@ export abstract class AbstractNavigationDoubleDrawerComponent implements OnInit,
151156
this.hideMoreMenu = !hiddenCustomItems?.length;
152157
})
153158
});
154-
155-
156159
}
157160

158161
public ngOnDestroy(): void {
@@ -223,6 +226,10 @@ export abstract class AbstractNavigationDoubleDrawerComponent implements OnInit,
223226
return this._navigationService.rightLoading$;
224227
}
225228

229+
public get pathResolverLoading$() {
230+
return this._pathResolverLoading$;
231+
}
232+
226233
public toggleMenu() {
227234
this.toggleRightMenu();
228235
if (this.allClosable) {
@@ -376,4 +383,40 @@ export abstract class AbstractNavigationDoubleDrawerComponent implements OnInit,
376383
protected openAvailableView() {
377384
this._navigationService.openAvailableView();
378385
}
386+
387+
protected resolveInitialValueOfPath() {
388+
if (this.currentPath === undefined) {
389+
const groupNavigationRoute = this._config.getServicesConfiguration()?.groupNavigation?.groupNavigationRoute;
390+
if (this._router.url.includes(groupNavigationRoute)) {
391+
this._pathResolverLoading$.on();
392+
this._pathService.datafieldsForMenuResolver.pipe(take(1)).subscribe(data => {
393+
this._pathResolverLoading$.off();
394+
let nodePath;
395+
let hasChildren;
396+
try {
397+
nodePath = extractFieldValueFromData<string>(data, GroupNavigationConstants.ITEM_FIELD_ID_NODE_PATH);
398+
hasChildren = extractFieldValueFromData<boolean>(data, GroupNavigationConstants.ITEM_FIELD_ID_HAS_CHILDREN);
399+
} catch (e) {
400+
this._log.info("Couldn't resolve menu, skipping...")
401+
}
402+
if (hasChildren && nodePath) {
403+
this._navigationService.fromResolver = true;
404+
this._pathService.activePath = nodePath;
405+
} else if (nodePath) {
406+
this._navigationService.fromResolver = true;
407+
this._pathService.activePath = this._navigationService.extractParentPath(nodePath);
408+
}
409+
}, error => {
410+
this._pathResolverLoading$.off();
411+
this.currentPath = this._pathService.activePath;
412+
});
413+
} else {
414+
const viewConfiguration = this._config.getViewByUrl(this._router.url)
415+
if (viewConfiguration?.processUri) {
416+
this._navigationService.fromResolver = true;
417+
this._pathService.activePath = viewConfiguration.processUri;
418+
}
419+
}
420+
}
421+
}
379422
}

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

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ export class DoubleDrawerNavigationService implements OnDestroy {
7373
* Siblings of the node are on the left, children are on the right
7474
*/
7575
protected _currentPath: string;
76+
private _fromResolver: boolean;
7677
/**
7778
* Currently selected navigation item
7879
*/
79-
protected _currentNavigationItem: NavigationItem;
80+
protected _currentNavigationItem: NavigationItem | undefined;
8081
protected defaultViewIcon: string = 'filter_alt';
8182
protected customItemsInitialized: boolean;
8283
protected hiddenCustomItemsInitialized: boolean;
@@ -103,7 +104,7 @@ export class DoubleDrawerNavigationService implements OnDestroy {
103104
this._leftLoading$ = new LoadingEmitter();
104105
this._rightLoading$ = new LoadingEmitter();
105106
this._nodeLoading$ = new LoadingEmitter();
106-
this._currentNavigationItem = null;
107+
this._currentNavigationItem = undefined;
107108
this.itemsOrder = MenuOrder.Ascending;
108109
this.customItemsInitialized = false;
109110
this.hiddenCustomItemsInitialized = false;
@@ -145,6 +146,10 @@ export class DoubleDrawerNavigationService implements OnDestroy {
145146
}
146147
}
147148

149+
public set currentNavigationItem(item: NavigationItem | undefined) {
150+
this._currentNavigationItem = item;
151+
}
152+
148153
protected resolveMenuItems(path: string) {
149154
if (path === PathService.SEPARATOR) {
150155
this._leftItems$.next([])
@@ -209,6 +214,10 @@ export class DoubleDrawerNavigationService implements OnDestroy {
209214
return this._nodeLoading$;
210215
}
211216

217+
set fromResolver(value: boolean) {
218+
this._fromResolver = value;
219+
}
220+
212221
public loadNavigationItems(node: UriNodeResource) {
213222
if (this.currentPath === PathService.SEPARATOR) {
214223
this._leftItems$.next([]);
@@ -242,7 +251,7 @@ export class DoubleDrawerNavigationService implements OnDestroy {
242251
if (this.leftLoading$.isActive || this.rightLoading$.isActive || this.currentPath === PathService.SEPARATOR) {
243252
return
244253
}
245-
this._pathService.activePath = this.extractParent(this.currentPath);
254+
this._pathService.activePath = this.extractParentPath(this.currentPath);
246255
this.itemClicked.emit({path: this._pathService.activePath, isHome: false});
247256
}
248257

@@ -252,17 +261,16 @@ export class DoubleDrawerNavigationService implements OnDestroy {
252261
* On second check if the clicked item has a view. On third, pick any other children's view, else show nothing.
253262
* */
254263
public onItemClick(item: NavigationItem): void {
264+
this._currentNavigationItem = item;
255265
if (item.resource === undefined) {
256-
this._currentNavigationItem = null;
257266
// custom view represented only in nae.json
258267
if (item.processUri === this.currentPath) {
259268
this._pathService.activePath = this.currentPath;
260269
} else {
261-
this._pathService.activePath = this.extractParent(this.currentPath);
270+
this._pathService.activePath = this.extractParentPath(this.currentPath);
262271
}
263272
this.itemClicked.emit({path: this._pathService.activePath, isHome: false});
264273
} else {
265-
this._currentNavigationItem = item;
266274
const path = item.resource.immediateData.find(f => f.stringId === GroupNavigationConstants.ITEM_FIELD_ID_NODE_PATH)?.value
267275

268276
if (DoubleDrawerUtils.hasItemChildren(item) && !this.leftLoading$.isActive && !this.rightLoading$.isActive) {
@@ -275,7 +283,7 @@ export class DoubleDrawerNavigationService implements OnDestroy {
275283
this.openAvailableView();
276284
})
277285
} else if (!path.includes(this.currentPath)) {
278-
this._pathService.activePath = this.extractParent(this.currentPath);
286+
this._pathService.activePath = this.extractParentPath(this.currentPath);
279287
this.itemClicked.emit({path: this._pathService.activePath, isHome: false});
280288

281289
} else {
@@ -303,6 +311,11 @@ export class DoubleDrawerNavigationService implements OnDestroy {
303311
}
304312
}
305313

314+
if (this._fromResolver) {
315+
this._fromResolver = false;
316+
return;
317+
}
318+
306319
let autoOpenItems: Array<NavigationItem> = allItems.filter(item => DoubleDrawerUtils.hasItemAutoOpenView(item));
307320
if (autoOpenItems.length > 0) {
308321
this._redirectService.redirect(autoOpenItems[0].routing.path);
@@ -376,7 +389,7 @@ export class DoubleDrawerNavigationService implements OnDestroy {
376389
}
377390
this.leftLoading$.on();
378391

379-
this.getItemCaseByPath(this.extractParent(this.currentPath)).subscribe(page => {
392+
this.getItemCaseByPath(this.extractParentPath(this.currentPath)).subscribe(page => {
380393
let childCases$;
381394
let targetItem;
382395
let orderedChildCaseIds;
@@ -510,9 +523,9 @@ export class DoubleDrawerNavigationService implements OnDestroy {
510523
}
511524

512525
protected resolveCustomViewsInLeftSide() {
513-
if (!!this.extractParent(this.currentPath) && !!this._childCustomViews[this.extractParent(this.currentPath)]) {
526+
if (!!this.extractParentPath(this.currentPath) && !!this._childCustomViews[this.extractParentPath(this.currentPath)]) {
514527
let currentLeftItems = this._leftItems$.getValue();
515-
currentLeftItems.push(...Object.values(this._childCustomViews[this.extractParent(this.currentPath)]));
528+
currentLeftItems.push(...Object.values(this._childCustomViews[this.extractParentPath(this.currentPath)]));
516529
this._leftItems$.next(currentLeftItems);
517530
}
518531
}
@@ -590,14 +603,14 @@ export class DoubleDrawerNavigationService implements OnDestroy {
590603
return this._caseResourceService.searchCases(SimpleFilter.fromCaseQuery(searchBody), httpParams);
591604
}
592605

593-
private extractParent(path: string): string {
606+
public extractParentPath(path: string): string {
594607
if (path === '/') {
595608
return path;
596609
}
597-
if (path.lastIndexOf('/') === 0) {
610+
if (path?.lastIndexOf('/') === 0) {
598611
return '/';
599612
}
600-
return path.substring(0, path.lastIndexOf('/'));
613+
return path?.substring(0, path?.lastIndexOf('/'));
601614
}
602615

603616

0 commit comments

Comments
 (0)