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
@@ -6,8 +6,8 @@
<mat-card-content>
<div fxLayout="column">
<div #createEmployeeFormRef fxLayout="column">
<mat-form-field>
<mat-label>Office</mat-label>
<mat-select required formControlName="officeId">
@@ -19,7 +19,7 @@
Office is <strong>required</strong>
</mat-error>
</mat-form-field>
<mat-form-field>
<mat-label>First Name</mat-label>
<input matInput required formControlName="firstname">
@@ -75,3 +75,14 @@
</mat-card>
</div>
<ng-template #templateCreateEmployeeForm let-popover="popover">
<h2>Create Employee</h2>
<p class="mw400">Click to start filling the details. * mark fields are neccessary. <br> For more details click: <a href="https://mifosforge.jira.com/wiki/spaces/docs/pages/67141732/Manage+Employees" target="_blank">Manage Employees</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 Employee</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 } from '@angular/core';
import { Component, OnInit , TemplateRef, ElementRef, ViewChild, AfterViewInit } from '@angular/core';
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
import { Router, ActivatedRoute } from '@angular/router';
@@ -7,6 +7,12 @@ import { Router, ActivatedRoute } from '@angular/router';
import { OrganizationService } from '../../organization.service';
import { SettingsService } from 'app/settings/settings.service';
import { Dates } from 'app/core/utils/dates';
import { MatDialog } from '@angular/material/dialog';
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';
/**
* Create employee component.
@@ -16,7 +22,7 @@ import { Dates } from 'app/core/utils/dates';
templateUrl: './create-employee.component.html',
styleUrls: ['./create-employee.component.scss']
})
export class CreateEmployeeComponent implements OnInit {
export class CreateEmployeeComponent implements OnInit, AfterViewInit {
/** Minimum joining date allowed. */
minDate = new Date(2000, 0, 1);
@@ -27,6 +33,11 @@ export class CreateEmployeeComponent implements OnInit {
/** Office data. */
officeData: any;
/* Reference of employee form */
@ViewChild('createEmployeeFormRef') createEmployeeFormRef: ElementRef<any>;
/* Template for popover on employee form */
@ViewChild('templateCreateEmployeeForm') templateCreateEmployeeForm: TemplateRef<any>;
/**
* Retrieves the offices data from `resolve`.
* @param {FormBuilder} formBuilder Form Builder.
@@ -35,13 +46,19 @@ export class CreateEmployeeComponent implements OnInit {
* @param {ActivatedRoute} route Activated Route.
* @param {Router} router Router for navigation.
* @param {Dates} dateUtils Date Utils to format date.
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
* @param {PopoverService} popoverService PopoverService.
* @param {MatDialog} dialog MatDialog.
*/
constructor(private formBuilder: FormBuilder,
private organizationService: OrganizationService,
private settingsService: SettingsService,
private route: ActivatedRoute,
private router: Router,
private dateUtils: Dates) {
private dateUtils: Dates,
private configurationWizardService: ConfigurationWizardService,
private popoverService: PopoverService,
public dialog: MatDialog) {
this.route.data.subscribe((data: { offices: any }) => {
this.officeData = data.offices;
});
@@ -87,7 +104,78 @@ export class CreateEmployeeComponent implements OnInit {
locale
};
this.organizationService.createEmployee(data).subscribe((response: any) => {
this.router.navigate(['../'], { relativeTo: this.route });
if (this.configurationWizardService.showEmployeeForm === true) {
this.configurationWizardService.showEmployeeForm = false;
this.openDialog();
} else {
this.router.navigate(['../'], { 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.showEmployeeForm === true) {
setTimeout(() => {
this.showPopover(this.templateCreateEmployeeForm, this.createEmployeeFormRef.nativeElement, 'right', true);
});
}
}
/**
* Next Step (Define Working Days) Configuration Wizard.
*/
nextStep() {
this.configurationWizardService.showEmployeeForm = false;
this.configurationWizardService.showDefineWorkingDays = true;
this.router.navigate(['/organization']);
}
/**
* Previous Step (Employees Page) Configuration Wizard.
*/
previousStep() {
this.configurationWizardService.showEmployeeForm = false;
this.configurationWizardService.showEmployeeTable = true;
this.router.navigate(['/organization/employees']);
}
/**
* Opens dialog if the user wants to create more employees.
*/
openDialog() {
const continueSetupDialogRef = this.dialog.open(ContinueSetupDialogComponent, {
data: {
stepName: 'employee'
},
});
continueSetupDialogRef.afterClosed().subscribe((response: { step: number }) => {
if (response.step === 1) {
this.configurationWizardService.showEmployeeForm = false;
this.router.navigate(['../'], { relativeTo: this.route });
} else if (response.step === 2) {
this.configurationWizardService.showEmployeeForm = true;
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
this.router.onSameUrlNavigation = 'reload';
this.router.navigate(['/organization/employees/create']);
} else if (response.step === 3) {
this.configurationWizardService.showEmployeeForm = false;
this.configurationWizardService.showDefineWorkingDays = true;
this.router.navigate(['/organization']);
}
});
}
@@ -1,27 +1,30 @@
<div class="container m-b-20" fxLayout="row" fxLayoutAlign="end" fxLayoutGap="20px">
<div #buttonImportEmployees>
<button mat-raised-button color="primary" *mifosxHasPermission="'CREATE_STAFF'" [routerLink]="['/', 'organization', 'bulk-import', 'Employees']">
<fa-icon icon="upload"></fa-icon>&nbsp;&nbsp;
Import Employees
</button>
</div>
<div #buttonCreateEmployee>
<button mat-raised-button color="primary" [routerLink]="['create']" *mifosxHasPermission="'CREATE_STAFF'">
<fa-icon icon="plus"></fa-icon>&nbsp;&nbsp;
Create Employee
</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 #tableEmployees class="mat-elevation-z8">
<table mat-table [dataSource]="dataSource" matSort>
@@ -63,4 +66,42 @@
</div>
</div>
</div>
<ng-template #templateButtonImportEmployees let-data let-popover="popover">
<h2>Import Employees</h2>
<p class="mw300">This button is used to import employee details from your local device.</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(templateButtonCreateEmployee,buttonCreateEmployee,'bottom', true)">Next</button>
</div>
</ng-template>
<ng-template #templateButtonCreateEmployee let-popover="popover">
<h2>Create Employee</h2>
<p class="mw300">This option allows you to create new employees in your organization.</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();showPopover(templateButtonImportEmployees,buttonImportEmployees,'bottom', true)">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 employees.</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(templateButtonCreateEmployee,buttonCreateEmployee,'bottom', true)">Back</button>
<button mat-raised-button color="primary" (click)="popover.close();showPopover(templateTableEmployees,tableEmployees,'top', true)">Next</button>
</div>
</ng-template>
<ng-template #templateTableEmployees let-popover="popover">
<h4>List of employees in the organization.</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';
/**
* Employees component.
*/
@@ -16,7 +20,7 @@ import { of } from 'rxjs';
templateUrl: './employees.component.html',
styleUrls: ['./employees.component.scss']
})
export class EmployeesComponent implements OnInit {
export class EmployeesComponent implements OnInit, AfterViewInit {
/** Employees data. */
employeesData: any;
@@ -30,11 +34,26 @@ export class EmployeesComponent implements OnInit {
/** Sorter for employees table. */
@ViewChild(MatSort, { static: true }) sort: MatSort;
/* Reference of import employees button */
@ViewChild('buttonImportEmployees') buttonImportEmployees: ElementRef<any>;
/* Template for popover on import employees button */
@ViewChild('templateButtonImportEmployees') templateButtonImportEmployees: TemplateRef<any>;
/* Reference of employees table */
@ViewChild('tableEmployees') tableEmployees: ElementRef<any>;
/* Template for popover on employees table */
@ViewChild('templateTableEmployees') templateTableEmployees: TemplateRef<any>;
/**
* Retrieves the employees 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: { employees: any }) => {
this.employeesData = data.employees;
});
@@ -64,4 +83,51 @@ export class EmployeesComponent 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.showEmployeeList === true) {
setTimeout(() => {
this.showPopover(this.templateButtonImportEmployees, this.buttonImportEmployees.nativeElement, 'bottom', true);
});
}
if (this.configurationWizardService.showEmployeeTable === true) {
setTimeout(() => {
this.showPopover(this.templateTableEmployees, this.tableEmployees.nativeElement, 'top', true);
});
}
}
/**
* Next Step (Create Employee Page) Configuration Wizard.
*/
nextStep() {
this.configurationWizardService.showEmployeeList = false;
this.configurationWizardService.showEmployeeTable = false;
this.configurationWizardService.showEmployeeForm = true;
this.router.navigate(['/organization/employees/create']);
}
/**
* Previous Step (Manage Employees) Configuration Wizard.
*/
previousStep() {
this.configurationWizardService.showEmployeeList = false;
this.configurationWizardService.showEmployeeTable = false;
this.configurationWizardService.showCreateEmployee = true;
this.router.navigate(['/organization']);
}
}