Skip to content

Commit

Permalink
Fixing a bug--> when the project launches it navigates to the last page
Browse files Browse the repository at this point in the history
  • Loading branch information
Omnia Kahla authored and Omnia Kahla committed Nov 3, 2020
1 parent 7e91e5d commit db855ec
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/app/app-engine/page/page/page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ export class PageComponent implements OnInit, AfterViewChecked {
this.route.queryParams.subscribe(params => {
this.hashOfThisPage = params.page;
this.actionID = params.actionID;
this.generateNavigation(params.actionID, true);
this.generateNavigation(params.actionID);
});
// route
if ( this.route.snapshot.queryParams.page ) {
Expand Down Expand Up @@ -556,7 +556,7 @@ export class PageComponent implements OnInit, AfterViewChecked {
/**
* This function generates the pagesOfThisActtion Array
* */
generateNavigation(actionID: string, goToPage?: boolean) {
generateNavigation(actionID: string) {
if (!this.alreadyLoaded && actionID) {
this.subPagesOfPage = [];
this.actionService.getAction(actionID)
Expand All @@ -577,15 +577,15 @@ export class PageComponent implements OnInit, AfterViewChecked {
this.alreadyLoaded = true;
}
console.log( this.pagesOfThisActtion, this.subPagesOfPage );
if ( goToPage ) {
this.selectedPageIndex = this.pagesOfThisActtion.length - 1;
//if ( goToPage ) {
//this.selectedPageIndex = this.pagesOfThisActtion.length - 1;
this.router.navigate( [ 'page' ], {
queryParams: {
'actionID': this.actionID,
'page': this.pagesOfThisActtion[ this.pagesOfThisActtion.length - 1 ]._id // this.hashOfThisPage
'page': this.pagesOfThisActtion[ this.selectedPageIndex ]._id // this.hashOfThisPage
}
} );
}
//}
}
},
error => {
Expand Down Expand Up @@ -1306,7 +1306,7 @@ export class PageComponent implements OnInit, AfterViewChecked {
.subscribe(
data => {
this.alreadyLoaded = false;
this.generateNavigation(this.actionID, true);
this.generateNavigation(this.actionID);
console.log( this.pagesOfThisActtion );
}, error => console.log( error )
);
Expand All @@ -1327,8 +1327,7 @@ export class PageComponent implements OnInit, AfterViewChecked {
.subscribe(
data => {
this.alreadyLoaded = false;
this.generateNavigation(this.actionID, true
);
this.generateNavigation(this.actionID);
}, error => console.log( error )
);
});
Expand Down

0 comments on commit db855ec

Please sign in to comment.