feat: tour integration

Tour Integration
This commit is contained in:
Ramveer
2022-09-02 17:03:13 +05:30
committed by GitHub
parent 52b7a3274e
commit f1be9ab5b1
119 changed files with 6360 additions and 456 deletions
@@ -2,7 +2,7 @@
<mat-card>
<form [formGroup]="dataTableForm" (ngSubmit)="submit()">
<form #dataTableFormRef [formGroup]="dataTableForm" (ngSubmit)="submit()">
<mat-card-content>
@@ -116,3 +116,14 @@
</mat-card>
</div>
<ng-template #templateDataTableFormRef let-popover="popover">
<h2>Create Datatable</h2>
<p class="mw400">Click to start filling the details. * mark fields are neccessary. For more details click: <a href="https://mifosforge.jira.com/wiki/spaces/docs/pages/52592760/Manage+Data+Tables" target="_blank">Manage Datatables</a></p>
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column">
<button mat-raised-button color="warn" (click)="popover.close();configurationWizardService.closeConfigWizard()">Close</button>
<button mat-raised-button color="primary" (click)="popover.close();">Create Datatable</button>
<button mat-raised-button color="primary" (click)="popover.close();previousStep()">Back</button>
<button mat-raised-button color="primary" (click)="popover.close();nextStep()">Next</button>
</div>
</ng-template>
@@ -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']);
}
});
}
}
@@ -1,20 +1,22 @@
<div class="container m-b-20" fxLayout="row" fxLayoutAlign="end" fxLayoutGap="20px">
<button mat-raised-button color="primary" [routerLink]="['create']" *mifosxHasPermission="'CREATE_DATATABLE'">
<fa-icon icon="plus"></fa-icon>&nbsp;&nbsp;
Create Data Table
</button>
<div #createDatatableRef class="in-block">
<button mat-raised-button color="primary" [routerLink]="['create']" *mifosxHasPermission="'CREATE_DATATABLE'">
<fa-icon icon="plus"></fa-icon>&nbsp;&nbsp;
Create Data Table
</button>
</div>
</div>
<div class="container">
<div fxLayout="row" fxLayoutGap="20px">
<div #filter fxLayout="row" fxLayoutGap="20px">
<mat-form-field fxFlex>
<mat-label>Filter</mat-label>
<input matInput (keyup)="applyFilter($event.target.value)">
</mat-form-field>
</div>
<div class="mat-elevation-z8">
<div #datatablesList class="mat-elevation-z8">
<table mat-table [dataSource]="dataSource" matSort>
@@ -38,3 +40,31 @@
</div>
</div>
<ng-template #templateCreateDatatableRef let-popover="popover">
<h2>Create Data Table</h2>
<p class="mw300">This will launch a page that will allow you to create a new data table.</p>
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column">
<button mat-raised-button color="warn" (click)="popover.close();configurationWizardService.closeConfigWizard()">Close</button>
<button mat-raised-button color="primary" (click)="popover.close();previousStep();">Back</button>
<button mat-raised-button color="primary" (click)="popover.close();showPopover(templateFilter,filter,'bottom', true);">Next</button>
</div>
</ng-template>
<ng-template #templateFilter let-popover="popover">
<h4>Search bar to filter datatables.</h4>
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column">
<button mat-raised-button color="warn" (click)="popover.close();configurationWizardService.closeConfigWizard()">Close</button>
<button mat-raised-button color="primary" (click)="popover.close();showPopover(templateCreateDatatableRef,createDatatableRef,'bottom', true);">Back</button>
<button mat-raised-button color="primary" (click)="popover.close();showPopover(templateDatatablesList,datatablesList,'top', true);">Next</button>
</div>
</ng-template>
<ng-template #templateDatatablesList let-popover="popover">
<h4>List of all currently available data tables.</h4>
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column">
<button mat-raised-button color="warn" (click)="popover.close();configurationWizardService.closeConfigWizard()">Close</button>
<button mat-raised-button color="primary" (click)="popover.close();showPopover(templateFilter,filter,'bottom', true);">Back</button>
<button mat-raised-button color="primary" (click)="popover.close();nextStep();">Next</button>
</div>
</ng-template>
@@ -1,13 +1,17 @@
/** Angular Imports */
import { Component, OnInit, ViewChild } from '@angular/core';
import { Component, OnInit, TemplateRef, ElementRef, ViewChild, AfterViewInit } from '@angular/core';
import { MatPaginator } from '@angular/material/paginator';
import { MatSort } from '@angular/material/sort';
import { MatTableDataSource } from '@angular/material/table';
import { ActivatedRoute } from '@angular/router';
import { ActivatedRoute, Router } from '@angular/router';
/** rxjs Imports */
import { of } from 'rxjs';
/** Custom Services */
import { PopoverService } from '../../configuration-wizard/popover/popover.service';
import { ConfigurationWizardService } from '../../configuration-wizard/configuration-wizard.service';
/**
* Manage Data Tables component.
*/
@@ -16,7 +20,7 @@ import { of } from 'rxjs';
templateUrl: './manage-data-tables.component.html',
styleUrls: ['./manage-data-tables.component.scss']
})
export class ManageDataTablesComponent implements OnInit {
export class ManageDataTablesComponent implements OnInit, AfterViewInit {
/** Data table data. */
dataTableData: any;
@@ -30,11 +34,26 @@ export class ManageDataTablesComponent implements OnInit {
/** Sorter for manage data tables table. */
@ViewChild(MatSort, { static: true }) sort: MatSort;
/* Reference of create datatables button */
@ViewChild('createDatatableRef') createDatatableRef: ElementRef<any>;
/* Template for popover on create datatables button */
@ViewChild('templateCreateDatatableRef') templateCreateDatatableRef: TemplateRef<any>;
/* Reference of list of datatables */
@ViewChild('datatablesList') datatablesList: ElementRef<any>;
/* Template for popover on list of datatables */
@ViewChild('templateDatatablesList') templateDatatablesList: TemplateRef<any>;
/**
* Retrieves the data tables data from `resolve`.
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router.
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
* @param {PopoverService} popoverService PopoverService.
*/
constructor(private route: ActivatedRoute) {
constructor(private route: ActivatedRoute,
private router: Router,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService) {
this.route.data.subscribe(( data: { dataTables: any }) => {
this.dataTableData = data.dataTables;
});
@@ -64,4 +83,50 @@ export class ManageDataTablesComponent implements OnInit {
this.dataSource.sort = this.sort;
}
/**
* 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.showDatatablesPage === true) {
setTimeout(() => {
this.showPopover(this.templateCreateDatatableRef, this.createDatatableRef.nativeElement, 'bottom', true);
});
}
if (this.configurationWizardService.showDatatablesList === true) {
setTimeout(() => {
this.showPopover(this.templateDatatablesList, this.datatablesList.nativeElement, 'top', true);
});
}
}
/**
* Next Step (Create data tables Page) Configuration Wizard.
*/
nextStep() {
this.configurationWizardService.showDatatablesPage = false;
this.configurationWizardService.showDatatablesList = false;
this.configurationWizardService.showDatatablesForm = true;
this.router.navigate(['/system/data-tables/create']);
}
/**
* Previous Step (Manage Datables system Page) Configuration Wizard.
*/
previousStep() {
this.configurationWizardService.showDatatablesPage = false;
this.configurationWizardService.showDatatablesList = false;
this.configurationWizardService.showDatatables = true;
this.router.navigate(['/system']);
}
}