feat: tour integration
Tour Integration
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { Component, OnInit, TemplateRef, ElementRef, ViewChild, AfterViewInit } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { FormBuilder, Validators } from '@angular/forms';
|
||||
|
||||
@@ -9,6 +9,11 @@ import { DeleteDialogComponent } from '../../../shared/delete-dialog/delete-dial
|
||||
|
||||
/** Custom Services */
|
||||
import { OrganizationService } from '../../organization.service';
|
||||
import { PopoverService } from '../../../configuration-wizard/popover/popover.service';
|
||||
import { ConfigurationWizardService } from '../../../configuration-wizard/configuration-wizard.service';
|
||||
|
||||
/** Custom Dialog Component */
|
||||
import { ContinueSetupDialogComponent } from '../../../configuration-wizard/continue-setup-dialog/continue-setup-dialog.component';
|
||||
|
||||
/**
|
||||
* Manage Currencies component.
|
||||
@@ -18,7 +23,7 @@ import { OrganizationService } from '../../organization.service';
|
||||
templateUrl: './manage-currencies.component.html',
|
||||
styleUrls: ['./manage-currencies.component.scss']
|
||||
})
|
||||
export class ManageCurrenciesComponent implements OnInit {
|
||||
export class ManageCurrenciesComponent implements OnInit, AfterViewInit {
|
||||
|
||||
/** Selected Currencies data. */
|
||||
selectedCurrencies: any[];
|
||||
@@ -29,6 +34,8 @@ export class ManageCurrenciesComponent implements OnInit {
|
||||
|
||||
/** Currency form reference */
|
||||
@ViewChild('formRef', { static: true }) formRef: any;
|
||||
@ViewChild('currencyFormRef') currencyFormRef: ElementRef<any>;
|
||||
@ViewChild('templateCurrencyFormRef') templateCurrencyFormRef: TemplateRef<any>;
|
||||
|
||||
/**
|
||||
* Retrieves the currency data from `resolve`.
|
||||
@@ -40,7 +47,10 @@ export class ManageCurrenciesComponent implements OnInit {
|
||||
constructor(private route: ActivatedRoute,
|
||||
private formBuilder: FormBuilder,
|
||||
private organizationservice: OrganizationService,
|
||||
public dialog: MatDialog) {
|
||||
public dialog: MatDialog,
|
||||
private router: Router,
|
||||
private configurationWizardService: ConfigurationWizardService,
|
||||
private popoverService: PopoverService) {
|
||||
this.route.parent.data.subscribe(( data: { currencies: any }) => {
|
||||
this.selectedCurrencies = data.currencies.selectedCurrencyOptions;
|
||||
this.currencyData = data.currencies.currencyOptions;
|
||||
@@ -72,6 +82,10 @@ export class ManageCurrenciesComponent implements OnInit {
|
||||
.subscribe((response: any) => {
|
||||
this.selectedCurrencies.push(newCurrency);
|
||||
this.formRef.resetForm();
|
||||
if (this.configurationWizardService.showCurrencyForm === true) {
|
||||
this.configurationWizardService.showCurrencyForm = false;
|
||||
this.openDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -98,4 +112,50 @@ export class ManageCurrenciesComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
showPopover(template: TemplateRef<any>, target: HTMLElement | ElementRef<any>, position: string, backdrop: boolean): void {
|
||||
setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200);
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
if (this.configurationWizardService.showCurrencyForm === true) {
|
||||
setTimeout(() => {
|
||||
this.showPopover(this.templateCurrencyFormRef, this.currencyFormRef.nativeElement, 'bottom', true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
nextStep() {
|
||||
this.configurationWizardService.showCurrencyForm = false;
|
||||
this.configurationWizardService.showCreateHoliday = true;
|
||||
this.router.navigate(['/organization']);
|
||||
}
|
||||
|
||||
previousStep() {
|
||||
this.configurationWizardService.showCurrencyForm = false;
|
||||
this.configurationWizardService.showCurrencyList = true;
|
||||
this.router.navigate(['/organization/currencies']);
|
||||
}
|
||||
|
||||
openDialog() {
|
||||
const continueSetupDialogRef = this.dialog.open(ContinueSetupDialogComponent, {
|
||||
data: {
|
||||
stepName: 'currency'
|
||||
},
|
||||
});
|
||||
continueSetupDialogRef.afterClosed().subscribe((response: { step: number }) => {
|
||||
if (response.step === 1) {
|
||||
this.configurationWizardService.showCurrencyForm = false;
|
||||
this.router.navigate(['../'], { relativeTo: this.route });
|
||||
} else if (response.step === 2) {
|
||||
this.configurationWizardService.showCurrencyForm = true;
|
||||
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
|
||||
this.router.onSameUrlNavigation = 'reload';
|
||||
this.router.navigate(['/organization/currencies/manage']);
|
||||
} else if (response.step === 3) {
|
||||
this.configurationWizardService.showCurrencyForm = false;
|
||||
this.configurationWizardService.showCreateHoliday = true;
|
||||
this.router.navigate(['/organization']);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user