[ACA-4041] [ADW] Sort order doesn't work correctly after opening a document (#1738)

* [ACA-4041] [ADW] Sort order doesn't work correctly after opening a document

* fixed header

* * fix test and improvements

Co-authored-by: Eugenio Romano <eromano@users.noreply.github.com>
This commit is contained in:
dhrn 2020-10-13 14:36:55 +05:30 committed by GitHub
parent 8430ea0929
commit b949aad9d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 7 deletions

View File

@ -241,6 +241,13 @@ describe('FilesComponent', () => {
expect(router.navigate).toHaveBeenCalledWith(['personal-files', 'favourites', node.id]); expect(router.navigate).toHaveBeenCalledWith(['personal-files', 'favourites', node.id]);
}); });
it('should remove the header filters param on click of folders', () => {
router.url = '/personal-files?name=abc';
component.navigate(node.id);
expect(router.navigate).toHaveBeenCalledWith(['personal-files', node.id]);
});
it('should navigates to node when id provided', () => { it('should navigates to node when id provided', () => {
router.url = '/personal-files'; router.url = '/personal-files';
component.navigate(node.id); component.navigate(node.id);

View File

@ -124,18 +124,19 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
navigate(nodeId: string = null) { navigate(nodeId: string = null) {
const uuidRegEx = /[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-4[0-9A-Za-z]{3}-[89ABab][0-9A-Za-z]{3}-[0-9A-Za-z]{12}/gi; const uuidRegEx = /[0-9A-Za-z]{8}-[0-9A-Za-z]{4}-4[0-9A-Za-z]{3}-[89ABab][0-9A-Za-z]{3}-[0-9A-Za-z]{12}/gi;
let urlToNavigate; let urlToNavigate: string[];
const urlWithoutParams = this.router.url.split('?')[0];
if (this.router.url.match(uuidRegEx)) { if (urlWithoutParams.match(uuidRegEx)) {
if (nodeId && !this.isRootNode(nodeId)) { if (nodeId && !this.isRootNode(nodeId)) {
urlToNavigate = this.router.url.replace(uuidRegEx, nodeId).split('/'); urlToNavigate = urlWithoutParams.replace(uuidRegEx, nodeId).split('/');
} else { } else {
urlToNavigate = this.router.url.replace(uuidRegEx, '').split('/'); urlToNavigate = urlWithoutParams.replace(uuidRegEx, '').split('/');
urlToNavigate.pop(); urlToNavigate.pop();
} }
urlToNavigate.shift(); urlToNavigate.shift();
} else { } else {
urlToNavigate = this.router.url.split('/'); urlToNavigate = urlWithoutParams.split('/');
if (nodeId && !this.isRootNode(nodeId)) { if (nodeId && !this.isRootNode(nodeId)) {
urlToNavigate.push(nodeId); urlToNavigate.push(nodeId);
} }
@ -296,6 +297,7 @@ export class FilesComponent extends PageComponent implements OnInit, OnDestroy {
this.showHeader = ShowHeaderMode.Always; this.showHeader = ShowHeaderMode.Always;
this.navigateToFilter(activeFilters); this.navigateToFilter(activeFilters);
} else { } else {
this.router.navigate(['.'], { relativeTo: this.route });
this.showHeader = ShowHeaderMode.Data; this.showHeader = ShowHeaderMode.Data;
this.onAllFilterCleared(); this.onAllFilterCleared();
} }

View File

@ -151,7 +151,7 @@ export class AppViewerComponent implements OnInit, OnDestroy {
}); });
this.route.queryParams.subscribe((params) => { this.route.queryParams.subscribe((params) => {
this.navigationPath = params.path; this.navigationPath = params.path || params.location;
}); });
if (this.route.snapshot.data && this.route.snapshot.data.navigateSource) { if (this.route.snapshot.data && this.route.snapshot.data.navigateSource) {
@ -420,7 +420,7 @@ export class AppViewerComponent implements OnInit, OnDestroy {
} }
private getFileLocation(): string { private getFileLocation(): string {
return this.router.parseUrl(this.navigationPath || this.router.url).root.children[PRIMARY_OUTLET].toString(); return this.navigationPath || this.router.parseUrl(this.router.url).root.children[PRIMARY_OUTLET].toString();
} }
private shouldNavigate(element: HTMLElement): boolean { private shouldNavigate(element: HTMLElement): boolean {