Skip to content
Snippets Groups Projects
Commit 9d9eda08 authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT #15350 TIME 0:20 fix feature tour

parent 05655dde
No related branches found
No related tags found
No related merge requests found
...@@ -87,7 +87,7 @@ export class AdministrationComponent implements OnInit, AfterViewInit { ...@@ -87,7 +87,7 @@ export class AdministrationComponent implements OnInit, AfterViewInit {
} }
ngAfterViewInit(): void { ngAfterViewInit(): void {
if (this.headerService.user.mode === 'root_visible' || this.headerService.user.mode === 'root_invisible') { if (!this.featureTourService.isComplete()) {
this.featureTourService.init(); this.featureTourService.init();
} }
} }
......
...@@ -71,8 +71,8 @@ export class HomeComponent implements OnInit, AfterViewInit { ...@@ -71,8 +71,8 @@ export class HomeComponent implements OnInit, AfterViewInit {
}); });
} }
ngAfterViewInit(): void { ngAfterViewInit(): void {
if (this.headerService.user.mode === 'root_visible' || this.headerService.user.mode === 'root_invisible') { if (!this.featureTourService.isComplete()) {
this.featureTourService.init(); this.featureTourService.init();
} }
this.http.get('../rest/home/lastRessources') this.http.get('../rest/home/lastRessources')
......
...@@ -102,10 +102,11 @@ export class FeatureTourService { ...@@ -102,10 +102,11 @@ export class FeatureTourService {
private http: HttpClient, private http: HttpClient,
private notify: NotificationService, private notify: NotificationService,
) { ) {
this.getCurrentStepType();
} }
init() { init() {
this.getCurrentStepType();
if (!this.functionService.empty(this.currentStepType)) { if (!this.functionService.empty(this.currentStepType)) {
const steps = this.tour.filter(step => step.type === this.currentStepType).map(step => step.stepId); const steps = this.tour.filter(step => step.type === this.currentStepType).map(step => step.stepId);
this.joyrideService.startTour( this.joyrideService.startTour(
...@@ -132,7 +133,9 @@ export class FeatureTourService { ...@@ -132,7 +133,9 @@ export class FeatureTourService {
/*handle error*/ /*handle error*/
}, },
() => { () => {
if (this.currentTour.redirectToAdmin) { if (this.currentTour === null) {
this.router.navigate(['/home']);
} else if (this.currentTour.redirectToAdmin) {
this.router.navigate(['/administration']); this.router.navigate(['/administration']);
} else { } else {
this.endTour(); this.endTour();
...@@ -143,22 +146,28 @@ export class FeatureTourService { ...@@ -143,22 +146,28 @@ export class FeatureTourService {
} }
getCurrentStepType() { getCurrentStepType() {
if (this.headerService.user.userId !== null) { this.featureTourEnd = this.headerService.user.featureTour;
this.featureTourEnd = this.headerService.user.featureTour; this.currentStepType = this.getFeatureTourTypes().filter(stepType => this.featureTourEnd.indexOf(stepType) === -1)[0];
}
const unique = [...new Set(this.tour.map(item => item.type))];
this.currentStepType = unique.filter(stepType => this.featureTourEnd.indexOf(stepType) === -1)[0];
} }
endTour() { endTour() {
this.featureTourEnd.push(this.currentStepType); if (this.currentStepType !== undefined) {
this.http.put('../rest/currentUser/profile/featureTour', {featureTour : this.featureTourEnd}).pipe( this.featureTourEnd.push(this.currentStepType);
catchError((err: any) => { this.http.put('../rest/currentUser/profile/featureTour', {featureTour : this.featureTourEnd}).pipe(
this.notify.handleSoftErrors(err); catchError((err: any) => {
return of(false); this.notify.handleSoftErrors(err);
}) return of(false);
).subscribe(); })
this.getCurrentStepType(); ).subscribe();
this.getCurrentStepType();
}
}
getFeatureTourTypes() {
return [...new Set(this.tour.map(item => item.type))];
} }
isComplete() {
return (this.headerService.user.mode === 'root_visible' || this.headerService.user.mode === 'root_invisible') && this.headerService.user.featureTour.length === this.getFeatureTourTypes().length;
}
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment