feat: tour integration
Tour Integration
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { Component, OnInit, TemplateRef, ElementRef, ViewChild, AfterViewInit } from '@angular/core';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
@@ -9,6 +9,8 @@ import { MatTableDataSource } from '@angular/material/table';
|
||||
|
||||
/** Custom Services */
|
||||
import { SystemService } from '../../system.service';
|
||||
import { PopoverService } from '../../../configuration-wizard/popover/popover.service';
|
||||
import { ConfigurationWizardService } from '../../../configuration-wizard/configuration-wizard.service';
|
||||
|
||||
/** Data Imports */
|
||||
import { appTableData, entitySubTypeData } from '../app-table-data';
|
||||
@@ -17,6 +19,9 @@ import { appTableData, entitySubTypeData } from '../app-table-data';
|
||||
import { ColumnDialogComponent } from '../column-dialog/column-dialog.component';
|
||||
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
|
||||
|
||||
/** Custom Dialog Component */
|
||||
import { ContinueSetupDialogComponent } from '../../../configuration-wizard/continue-setup-dialog/continue-setup-dialog.component';
|
||||
|
||||
/**
|
||||
* Create Data Table Component.
|
||||
*/
|
||||
@@ -25,7 +30,7 @@ import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.co
|
||||
templateUrl: './create-data-table.component.html',
|
||||
styleUrls: ['./create-data-table.component.scss']
|
||||
})
|
||||
export class CreateDataTableComponent implements OnInit {
|
||||
export class CreateDataTableComponent implements OnInit, AfterViewInit {
|
||||
|
||||
/** Data Table Form */
|
||||
dataTableForm: FormGroup;
|
||||
@@ -62,6 +67,11 @@ export class CreateDataTableComponent implements OnInit {
|
||||
/** Sorter for columns table. */
|
||||
@ViewChild(MatSort, { static: true }) sort: MatSort;
|
||||
|
||||
/* Reference of create datatables form */
|
||||
@ViewChild('dataTableFormRef') dataTableFormRef: ElementRef<any>;
|
||||
/* Template for popover on create datatables form */
|
||||
@ViewChild('templateDataTableFormRef') templateDataTableFormRef: TemplateRef<any>;
|
||||
|
||||
/**
|
||||
* Retrieves the column codes data from `resolve`.
|
||||
* @param {FormBuilder} formBuilder Form Builder.
|
||||
@@ -69,12 +79,16 @@ export class CreateDataTableComponent implements OnInit {
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
* @param {Router} router Router for navigation.
|
||||
* @param {MatDialog} dialog Dialog Reference.
|
||||
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
|
||||
* @param {PopoverService} popoverService PopoverService.
|
||||
*/
|
||||
constructor(private formBuilder: FormBuilder,
|
||||
private systemService: SystemService,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private dialog: MatDialog) {
|
||||
private dialog: MatDialog,
|
||||
private configurationWizardService: ConfigurationWizardService,
|
||||
private popoverService: PopoverService) {
|
||||
this.route.data.subscribe((data: { columnCodes: any }) => {
|
||||
this.dataForDialog.columnCodes = data.columnCodes;
|
||||
});
|
||||
@@ -189,9 +203,81 @@ export class CreateDataTableComponent implements OnInit {
|
||||
*/
|
||||
submit() {
|
||||
this.dataTableForm.value.columns = this.columnData;
|
||||
this.systemService.createDataTable(this.dataTableForm.value)
|
||||
.subscribe((response: any) => {
|
||||
this.systemService.createDataTable(this.dataTableForm.value).subscribe((response: any) => {
|
||||
if (this.configurationWizardService.showDatatablesForm === true) {
|
||||
this.configurationWizardService.showDatatablesForm = false;
|
||||
this.openDialog();
|
||||
} else {
|
||||
this.router.navigate(['../', response.resourceIdentifier], { relativeTo: this.route });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Popover function
|
||||
* @param template TemplateRef<any>.
|
||||
* @param target HTMLElement | ElementRef<any>.
|
||||
* @param position String.
|
||||
* @param backdrop Boolean.
|
||||
*/
|
||||
showPopover(template: TemplateRef<any>, target: HTMLElement | ElementRef<any>, position: string, backdrop: boolean): void {
|
||||
setTimeout(() => this.popoverService.open(template, target, position, backdrop, {}), 200);
|
||||
}
|
||||
|
||||
/**
|
||||
* To show popover.
|
||||
*/
|
||||
ngAfterViewInit() {
|
||||
if (this.configurationWizardService.showDatatablesForm === true) {
|
||||
setTimeout(() => {
|
||||
this.showPopover(this.templateDataTableFormRef, this.dataTableFormRef.nativeElement, 'bottom', true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Next Step (System Codes Page) Configuration Wizard.
|
||||
*/
|
||||
nextStep() {
|
||||
this.configurationWizardService.showDatatablesForm = false;
|
||||
this.configurationWizardService.showSystemCodes = true;
|
||||
this.router.navigate(['/system']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Previous Step (Manage Datatables Page) Configuration Wizard.
|
||||
*/
|
||||
previousStep() {
|
||||
this.configurationWizardService.showDatatablesForm = false;
|
||||
this.configurationWizardService.showDatatablesList = true;
|
||||
this.router.navigate(['/system/data-tables']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens dialog if the user wants to create more datatables Configuration Wizard.
|
||||
*/
|
||||
openDialog() {
|
||||
const continueSetupDialogRef = this.dialog.open(ContinueSetupDialogComponent, {
|
||||
data: {
|
||||
stepName: 'data table'
|
||||
},
|
||||
});
|
||||
continueSetupDialogRef.afterClosed().subscribe((response: { step: number }) => {
|
||||
if (response.step === 1) {
|
||||
this.configurationWizardService.showDatatablesForm = false;
|
||||
this.router.navigate(['../'], { relativeTo: this.route });
|
||||
} else if (response.step === 2) {
|
||||
this.configurationWizardService.showDatatablesForm = true;
|
||||
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
|
||||
this.router.onSameUrlNavigation = 'reload';
|
||||
this.router.navigate(['/organization/data-tables/create']);
|
||||
} else if (response.step === 3) {
|
||||
this.configurationWizardService.showDatatablesForm = false;
|
||||
this.configurationWizardService.showSystemCodes = true;
|
||||
this.router.navigate(['/system']);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user