feat: tour integration
Tour Integration
This commit is contained in:
+12
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
<mat-card>
|
||||
|
||||
<form [formGroup]="glAccountForm" (ngSubmit)="submit()">
|
||||
<form #accountFormRef [formGroup]="glAccountForm" (ngSubmit)="submit()">
|
||||
|
||||
<mat-card-content>
|
||||
|
||||
@@ -91,3 +91,14 @@
|
||||
</mat-card>
|
||||
|
||||
</div>
|
||||
|
||||
<ng-template #templateAccountFormRef let-popover="popover">
|
||||
<h2>Create GL account</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/67141745/Chart+of+Accounts+-+General+Ledger+Setup" target="_blank">Chart of Accounts</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 GL Account</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>
|
||||
|
||||
+91
-4
@@ -1,10 +1,16 @@
|
||||
/** 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';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
|
||||
/** Custom Services */
|
||||
import { AccountingService } from '../../accounting.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';
|
||||
|
||||
/**
|
||||
* Create gl account component.
|
||||
@@ -14,7 +20,7 @@ import { AccountingService } from '../../accounting.service';
|
||||
templateUrl: './create-gl-account.component.html',
|
||||
styleUrls: ['./create-gl-account.component.scss']
|
||||
})
|
||||
export class CreateGlAccountComponent implements OnInit {
|
||||
export class CreateGlAccountComponent implements OnInit, AfterViewInit {
|
||||
|
||||
/** GL account form. */
|
||||
glAccountForm: FormGroup;
|
||||
@@ -35,17 +41,28 @@ export class CreateGlAccountComponent implements OnInit {
|
||||
/** Cancel route. (depending on creation of gl account or sub-ledger account) */
|
||||
cancelRoute = '../../';
|
||||
|
||||
/* Reference of accounts form */
|
||||
@ViewChild('accountFormRef') accountFormRef: ElementRef<any>;
|
||||
/* Template for popover on accounts form */
|
||||
@ViewChild('templateAccountFormRef') templateAccountFormRef: TemplateRef<any>;
|
||||
|
||||
/**
|
||||
* Retrieves the chart of accounts data from `resolve`.
|
||||
* @param {FormBuilder} formBuilder Form Builder.
|
||||
* @param {AccountingService} accountingService Accounting Service.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
* @param {Router} router Router for navigation.
|
||||
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
|
||||
* @param {PopoverService} popoverService PopoverService.
|
||||
* @param {Matdialog} dialog Matdialog.
|
||||
*/
|
||||
constructor(private formBuilder: FormBuilder,
|
||||
private accountingService: AccountingService,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router) {
|
||||
private router: Router,
|
||||
private configurationWizardService: ConfigurationWizardService,
|
||||
private popoverService: PopoverService,
|
||||
public dialog: MatDialog) {
|
||||
this.route.queryParamMap.subscribe(params => {
|
||||
this.accountTypeId = Number(params.get('accountType'));
|
||||
this.parentId = Number(params.get('parent'));
|
||||
@@ -118,8 +135,78 @@ export class CreateGlAccountComponent implements OnInit {
|
||||
*/
|
||||
submit() {
|
||||
this.accountingService.createGlAccount(this.glAccountForm.value).subscribe((response: any) => {
|
||||
this.router.navigate(['../view', response.resourceId], { relativeTo: this.route });
|
||||
if (this.configurationWizardService.showChartofAccounts === true) {
|
||||
this.configurationWizardService.showChartofAccounts = false;
|
||||
this.openDialog();
|
||||
} else {
|
||||
this.router.navigate(['../view', response.resourceId], { 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.showChartofAccountsForm === true) {
|
||||
setTimeout(() => {
|
||||
this.showPopover(this.templateAccountFormRef, this.accountFormRef.nativeElement, 'bottom', true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Next Step (Accounts Linked Accounting Page) Configuration Wizard.
|
||||
*/
|
||||
nextStep() {
|
||||
this.configurationWizardService.showChartofAccountsForm = false;
|
||||
this.configurationWizardService.showAccountsLinked = true;
|
||||
this.router.navigate(['/accounting']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Previous Step (Charts of Accounts Page) Configuration Wizard.
|
||||
*/
|
||||
previousStep() {
|
||||
this.configurationWizardService.showChartofAccountsForm = false;
|
||||
this.configurationWizardService.showChartofAccountsList = true;
|
||||
this.router.navigate(['/accounting/chart-of-accounts']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens dialog if the user wants to create more accounts.
|
||||
*/
|
||||
openDialog() {
|
||||
const continueSetupDialogRef = this.dialog.open(ContinueSetupDialogComponent, {
|
||||
data: {
|
||||
stepName: 'GL account'
|
||||
},
|
||||
});
|
||||
continueSetupDialogRef.afterClosed().subscribe((response: { step: number }) => {
|
||||
if (response.step === 1) {
|
||||
this.configurationWizardService.showChartofAccountsForm = false;
|
||||
this.router.navigate(['../'], { relativeTo: this.route });
|
||||
} else if (response.step === 2) {
|
||||
this.configurationWizardService.showChartofAccountsForm = true;
|
||||
this.router.routeReuseStrategy.shouldReuseRoute = () => false;
|
||||
this.router.onSameUrlNavigation = 'reload';
|
||||
this.router.navigate(['/accounting/chart-of-accounts/gl-accounts/create']);
|
||||
} else if (response.step === 3) {
|
||||
this.configurationWizardService.showChartofAccountsForm = false;
|
||||
this.configurationWizardService.showAccountsLinked = true;
|
||||
this.router.navigate(['/accounting']);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user