Bug with optional routes: move the error case in the end of all routes
This commit is contained in:
parent
513bb83769
commit
1839b3a82a
|
@ -95,8 +95,7 @@ const routes: Routes = [
|
||||||
data: {hasSidebar: false}
|
data: {hasSidebar: false}
|
||||||
},
|
},
|
||||||
{path: 'user-info', loadChildren: () => import('./login/libUser.module').then(m => m.LibUserModule)},
|
{path: 'user-info', loadChildren: () => import('./login/libUser.module').then(m => m.LibUserModule)},
|
||||||
{path: 'error', component: OpenaireErrorPageComponent},
|
{path: 'error', component: OpenaireErrorPageComponent}
|
||||||
{path: '**', pathMatch: 'full', component: OpenaireErrorPageComponent}
|
|
||||||
];
|
];
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
|
@ -107,7 +106,7 @@ const routes: Routes = [
|
||||||
})
|
})
|
||||||
export class AppRoutingModule {
|
export class AppRoutingModule {
|
||||||
subs = [];
|
subs = [];
|
||||||
routes =[];
|
enabledRoutes =[];
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
for (let sub of this.subs) {
|
for (let sub of this.subs) {
|
||||||
sub.unsubscribe();
|
sub.unsubscribe();
|
||||||
|
@ -118,17 +117,17 @@ export class AppRoutingModule {
|
||||||
if (data) {
|
if (data) {
|
||||||
if (data['pages']) {
|
if (data['pages']) {
|
||||||
for (var i = 0; i < data['pages'].length; i++) {
|
for (var i = 0; i < data['pages'].length; i++) {
|
||||||
this.routes[data['pages'][i]['route']] = data['pages'][i]['isEnabled'];
|
this.enabledRoutes[data['pages'][i]['route']] = data['pages'][i]['isEnabled'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.getRoutes();
|
this.getOptionalRoutes();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error => {
|
error => {
|
||||||
// this.handleError('Error getting community information (e.g. pages,entities) for community with id: ' + this.communityId, error);
|
// this.handleError('Error getting community information (e.g. pages,entities) for community with id: ' + this.communityId, error);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
getRoutes(){
|
getOptionalRoutes(){
|
||||||
let optionalRoutes = [
|
let optionalRoutes = [
|
||||||
// Deposit Pages
|
// Deposit Pages
|
||||||
{ path: 'participate/deposit-datasets', redirectTo: 'participate/deposit/learn-how', pathMatch: 'full'},
|
{ path: 'participate/deposit-datasets', redirectTo: 'participate/deposit/learn-how', pathMatch: 'full'},
|
||||||
|
@ -145,12 +144,12 @@ export class AppRoutingModule {
|
||||||
{ path: 'participate/direct-claim', loadChildren: () => import('./claims/directLinking/directLinking.module').then(m => m.LibDirectLinkingModule)},
|
{ path: 'participate/direct-claim', loadChildren: () => import('./claims/directLinking/directLinking.module').then(m => m.LibDirectLinkingModule)},
|
||||||
{path: 'develop', loadChildren: () => import('./develop/develop.module').then(m => m.DevelopModule)}
|
{path: 'develop', loadChildren: () => import('./develop/develop.module').then(m => m.DevelopModule)}
|
||||||
];
|
];
|
||||||
|
|
||||||
for (var i = 0; i <optionalRoutes.length; i++) {
|
for (var i = 0; i <optionalRoutes.length; i++) {
|
||||||
if(this.routes["/"+optionalRoutes[i].path]){
|
if(this.enabledRoutes[("/"+optionalRoutes[i].path)]){
|
||||||
this.router.config.push(optionalRoutes[i]);
|
this.router.config.push(optionalRoutes[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.router.config.push({path: '**', pathMatch: 'full', component: OpenaireErrorPageComponent});
|
||||||
return routes;
|
return routes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue