Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Context interactive tour #751

Merged
merged 15 commits into from
Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ export interface InteractiveTourOptions {
/* Disable an interaction with element? */
disableInteraction?: boolean;
/* Element to check to be able to start the tour */
condition?: string;
conditions?: string[];
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
})
export class InteractiveTourService {
private previousStep: InteractiveTourStep;
private nextIndex = 1;

constructor(
private configService: ConfigService,
Expand Down Expand Up @@ -52,9 +53,11 @@ export class InteractiveTourService {
toolName
);

if (stepConfig?.condition) {
if (document.querySelector(stepConfig.condition) === null) {
return true;
if (stepConfig?.conditions) {
for (const condition of stepConfig?.conditions) {
if (document.querySelector(condition) === null) {
return true;
}
}
}
return false;
Expand Down Expand Up @@ -156,13 +159,8 @@ export class InteractiveTourService {
const checkExist = setInterval(() => {
if (self.getCurrentStep()) {
if (self.getCurrentStep().options.attachTo.element && !document.querySelector(self.getCurrentStep().options.attachTo.element)) {
self.getCurrentStep().hide();
const id = self.getCurrentStep().id;
if (self.steps.findIndex(step => step.id === id) === self.steps.length - 1) {
return;
}
self.next();
self.removeStep(id);
self.cancel();
clearInterval(checkExist);
return;
} else {
const currentStepElement = self.getCurrentStep().getElement();
Expand Down Expand Up @@ -198,6 +196,29 @@ export class InteractiveTourService {
}, 100);
}

private checkNext(index, tour, service) {
if (tour.getCurrentStep()) {
if (tour.getCurrentStep().options.attachTo.element && document.querySelector(tour.getCurrentStep().options.attachTo.element)) {
tour.complete();
return;
}

if (index.index === tour.steps.length - 1) {
tour.complete();
return;
}

tour.steps.splice(index.index, 1);
const nextStep = tour.steps[index.index];
if (nextStep.options.attachTo.element && !document.querySelector(nextStep.options.attachTo.element)) {
service.checkNext(index, tour, service);
} else {
tour._setupModal();
tour.show(nextStep.id);
}
}
}

private executeAction(
step: InteractiveTourStep,
actionConfig: InteractiveTourAction
Expand Down Expand Up @@ -327,6 +348,9 @@ export class InteractiveTourService {
this.shepherdService.addSteps(shepherdSteps);

this.shepherdService.tourObject.on('show', this.addProgress);
this.shepherdService.tourObject.on('cancel', (index) => {
this.checkNext(index, this.shepherdService.tourObject, this);
});

this.shepherdService.start();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ <h4 matLine>{{context.title}}</h4>
class="igo-actions-container">

<button *ngIf="collapsed && selected && (context.permission === typePermission[typePermission.write] || context.imported)"
class="save-button"
mat-icon-button
[matTooltip]="'igo.context.contextManager.save' | translate"
matTooltipShowDelay="500"
Expand Down Expand Up @@ -47,6 +48,7 @@ <h4 matLine>{{context.title}}</h4>
</button-->

<button *ngIf="!context.imported"
class="clone-button"
mat-icon-button
[matTooltip]="'igo.context.contextManager.clone' | translate"
matTooltipShowDelay="500"
Expand All @@ -56,6 +58,7 @@ <h4 matLine>{{context.title}}</h4>
</button>

<button *ngIf="context.permission === typePermission[typePermission.write] && !context.imported"
class="edit-button"
mat-icon-button
[color]="color"
[matTooltip]="'igo.context.contextManager.edit' | translate"
Expand All @@ -65,6 +68,7 @@ <h4 matLine>{{context.title}}</h4>
</button>

<button *ngIf="!context.hidden && !context.imported"
class="hide-button"
mat-icon-button
[color]="color"
[matTooltip]="'igo.context.contextManager.hide' | translate"
Expand All @@ -74,6 +78,7 @@ <h4 matLine>{{context.title}}</h4>
</button>

<button *ngIf="context.hidden && !context.imported"
class="hide-button"
mat-icon-button
[color]="color"
[matTooltip]="'igo.context.contextManager.show' | translate"
Expand All @@ -83,6 +88,7 @@ <h4 matLine>{{context.title}}</h4>
</button>

<button *ngIf="context.permission === typePermission[typePermission.write] || context.imported"
class="delete-button"
mat-icon-button
color="warn"
[matTooltip]="'igo.context.contextManager.delete' | translate"
Expand All @@ -93,6 +99,7 @@ <h4 matLine>{{context.title}}</h4>
</div>

<button
class="actions-button"
mat-icon-button
igoCollapse
[color]="color"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<igo-list [navigation]="true">
<mat-form-field *ngIf="showFilter()" [ngClass]="auth.authenticated ? 'context-filter-min-width' : 'context-filter-max-width'">
<mat-form-field *ngIf="showFilter()" [ngClass]="auth.authenticated && configService.getConfig('context') ? 'context-filter-min-width' : 'context-filter-max-width'">
<input
matInput
type="text"
Expand All @@ -20,6 +20,7 @@

<button
*ngIf="!sortedAlpha"
class="sort-alpha"
mat-icon-button
[matTooltip]="'igo.context.contextManager.sortAlphabetically' | translate"
matTooltipShowDelay="500"
Expand All @@ -28,14 +29,15 @@
</button>
<button
*ngIf="sortedAlpha"
class="sort-alpha"
mat-icon-button
[matTooltip]="'igo.context.contextManager.sortContextOrder' | translate"
matTooltipShowDelay="500"
(click)="toggleSort(false)">
<mat-icon color="warn" svgIcon="sort-variant-remove"></mat-icon>
</button>

<igo-actionbar *ngIf="auth.authenticated"
<igo-actionbar *ngIf="auth.authenticated && configService.getConfig('context')"
class="add-context-button"
[iconColor]="color"
[store]="actionStore"
Expand All @@ -46,7 +48,8 @@
[mode]="actionbarMode">
</igo-actionbar>

<button *ngIf="auth.authenticated && users && users.length"
<button *ngIf="auth.authenticated && configService.getConfig('context')"
class="users-filter"
mat-icon-button
[matTooltip]="'igo.context.contextManager.filterUser' | translate"
matTooltipShowDelay="500"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '@angular/core';

import { AuthService } from '@igo2/auth';
import { LanguageService, StorageService } from '@igo2/core';
import { ConfigService, LanguageService, StorageService } from '@igo2/core';
import type { IgoMap } from '@igo2/geo';

import {
Expand Down Expand Up @@ -154,6 +154,7 @@ export class ContextListComponent implements OnInit, OnDestroy {
constructor(
private cdRef: ChangeDetectorRef,
private contextService: ContextService,
public configService: ConfigService,
public auth: AuthService,
private dialog: MatDialog,
private languageService: LanguageService,
Expand Down