refactor (df/locale): account transfers module (#1223)

See: #1213
This commit is contained in:
Muskan Khedia
2020-08-24 00:01:58 +05:30
committed by GitHub
parent a77e50f948
commit 755e079f28
7 changed files with 68 additions and 22 deletions
@@ -95,11 +95,11 @@ export class AccountTransfersService {
}
getStandingInstructionsTransactions(standingInstructionsId: any) {
getStandingInstructionsTransactions(standingInstructionsId: any, dateFormat: any, locale: any) {
const httpParams = new HttpParams().set('associations', 'transactions')
.set('dateFormat', 'dd MMMM yyyy')
.set('dateFormat', dateFormat)
.set('limit', '14')
.set('locale', 'en')
.set('locale', locale)
.set('offset', '0');
return this.http.get(`/standinginstructions/${standingInstructionsId}`, { params: httpParams });
}
@@ -7,6 +7,7 @@ import { Observable } from 'rxjs';
/** Custom Services */
import { AccountTransfersService } from '../account-transfers.service';
import { SettingsService } from 'app/settings/settings.service';
/**
* View Standing Instructions resolver.
@@ -15,9 +16,11 @@ import { AccountTransfersService } from '../account-transfers.service';
export class ListTransactionsResolver implements Resolve<Object> {
/**
* @param {accountTransfersService} AccountTransfersService Account Transfers service.
* @param {AccountTransfersService} accountTransfersService Account Transfers service.
* @param {SettingsService} settingsService Settings Service.
*/
constructor(private accountTransfersService: AccountTransfersService) { }
constructor(private accountTransfersService: AccountTransfersService,
private settingsService: SettingsService) { }
/**
* Returns the Standing Instructions Data.
@@ -26,6 +29,8 @@ export class ListTransactionsResolver implements Resolve<Object> {
*/
resolve(route: ActivatedRouteSnapshot): Observable<any> {
const id = route.parent.paramMap.get('standingInstructionsId');
return this.accountTransfersService.getStandingInstructionsTransactions(id);
const dateFormat = this.settingsService.dateFormat;
const locale = this.settingsService.language.code;
return this.accountTransfersService.getStandingInstructionsTransactions(id, dateFormat, locale);
}
}
@@ -1,9 +1,16 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { AccountTransfersService } from '../account-transfers.service';
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
import { DatePipe } from '@angular/common';
/** Custom Services */
import { AccountTransfersService } from '../account-transfers.service';
import { SettingsService } from 'app/settings/settings.service';
/**
* Create Standing Instructions
*/
@Component({
selector: 'mifosx-create-standing-instructions',
templateUrl: './create-standing-instructions.component.html',
@@ -62,12 +69,14 @@ export class CreateStandingInstructionsComponent implements OnInit {
* @param {FormBuilder} formBuilder Form Builder
* @param {Router} router Router
* @param {AccountTransfersService} accountTransfersService Account Transfers Service
* @param {SettingsService} settingsService Settings Service
* @param {DatePipe} datePipe Date Pipe
*/
constructor(private formBuilder: FormBuilder,
private route: ActivatedRoute,
private router: Router,
private accountTransfersService: AccountTransfersService,
private settingsService: SettingsService,
private datePipe: DatePipe) {
this.route.data.subscribe((data: { standingIntructionsTemplate: any }) => {
this.standingIntructionsTemplate = data.standingIntructionsTemplate;
@@ -75,6 +84,7 @@ export class CreateStandingInstructionsComponent implements OnInit {
this.setOptions();
});
}
/** Sets the value from the URL */
setParams() {
this.officeId = this.route.snapshot.queryParams['officeId'];
@@ -202,11 +212,12 @@ export class CreateStandingInstructionsComponent implements OnInit {
* Submits the standing instructions form
*/
submit() {
const dateFormat = 'dd MMMM yyyy';
const dateFormat = this.settingsService.dateFormat;
const locale = this.settingsService.language.code;
const standingInstructionData = {
... this.createStandingInstructionsForm.value,
dateFormat: dateFormat,
locale: 'en',
dateFormat,
locale,
monthDayFormat: 'dd MMMM',
fromClientId: this.clientId,
fromOfficeId: this.officeId,
@@ -159,7 +159,7 @@
</mat-card-content>
<mat-card-actions fxLayout="row" fxLayout.xs="column" fxLayoutAlign="center" fxLayoutGap="5px">
<button type="button" mat-raised-button [routerLink]="['../']">Cancel</button>
<button type="button" mat-raised-button [routerLink]="['../view']">Cancel</button>
<button mat-raised-button color="primary" [disabled]="!editStandingInstructionsForm.valid"
(click)="submit()" *mifosxHasPermission="'UPDATE_STANDINGINSTRUCTION'">Submit</button>
</mat-card-actions>
@@ -1,9 +1,16 @@
/** Angular Imports */
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { AccountTransfersService } from '../account-transfers.service';
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
import { DatePipe } from '@angular/common';
/** Custom Services */
import { AccountTransfersService } from '../account-transfers.service';
import { SettingsService } from 'app/settings/settings.service';
/**
* Edit Standing Instructions
*/
@Component({
selector: 'mifosx-edit-standing-instructions',
templateUrl: './edit-standing-instructions.component.html',
@@ -35,13 +42,19 @@ export class EditStandingInstructionsComponent implements OnInit {
maxDate = new Date();
/**
* Retrieves the standing instructions data from `resolve`.
* Retrieves the standing instructions template from `resolve`.
* @param {ActivatedRoute} route Activated Route.
* @param {FormBuilder} formBuilder Form Builder
* @param {Router} router Router
* @param {AccountTransfersService} accountTransfersService Account Transfers Service
* @param {SettingsService} settingsService Settings Service
* @param {DatePipe} datePipe Date Pipe
*/
constructor(private formBuilder: FormBuilder,
private route: ActivatedRoute,
private router: Router,
private accountTransfersService: AccountTransfersService,
private settingsService: SettingsService,
private datePipe: DatePipe) {
this.route.data.subscribe((data: { standingInstructionsDataAndTemplate: any }) => {
this.standingInstructionsData = data.standingInstructionsDataAndTemplate;
@@ -127,12 +140,13 @@ export class EditStandingInstructionsComponent implements OnInit {
* Submits the standing instructions form
*/
submit() {
const dateFormat = 'dd MMMM yyyy';
const dateFormat = this.settingsService.dateFormat;
const locale = this.settingsService.language.code;
const standingInstructionData = {
amount: this.editStandingInstructionsForm.value.amount,
dateFormat: dateFormat,
dateFormat,
instructionType: this.editStandingInstructionsForm.value.instructionType,
locale: 'en',
locale,
monthDayFormat: 'dd MMMM',
priority: this.editStandingInstructionsForm.value.priority,
recurrenceFrequency: this.editStandingInstructionsForm.value.recurrenceFrequency,
@@ -144,7 +158,7 @@ export class EditStandingInstructionsComponent implements OnInit {
validTill: this.datePipe.transform(this.editStandingInstructionsForm.value.validTill, dateFormat)
};
this.accountTransfersService.updateStandingInstructionsData(this.standingInstructionsId, standingInstructionData).subscribe((response: any) => {
this.router.navigate(['../../'], { relativeTo: this.route });
this.router.navigate(['../view'], { relativeTo: this.route });
});
}
@@ -11,6 +11,7 @@ import { AccountTransfersService } from '../account-transfers.service';
/** Dialog Components */
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
import { SettingsService } from 'app/settings/settings.service';
/**
* Lists all the standing intructions of particular ID
@@ -61,10 +62,12 @@ export class ListStandingInstructionsComponent implements OnInit {
* Retrieves Standing Instructions Data from `resolve`.
* @param {ActivatedRoute} route Activated Route.
* @param {MatDialog} route Mat Dialog
* @param {SettingsService} settingsService Settings Service
* @param {AccountTransfersService} accountTransfersService Account Transfers Service
*/
constructor(private route: ActivatedRoute,
private accountTransfersService: AccountTransfersService,
private settingsService: SettingsService,
private dialog: MatDialog) {
this.route.data.subscribe((data: { standingIntructionsTemplate: any }) => {
this.standingIntructionsTemplateData = data.standingIntructionsTemplate;
@@ -103,11 +106,13 @@ export class ListStandingInstructionsComponent implements OnInit {
* Retrieves standing instructions and initializes instructions table.
*/
getStandingInstructions() {
const dateFormat = this.settingsService.dateFormat;
const locale = this.settingsService.language.code;
const searchData = {
clientId : this.standingIntructionsTemplateData.fromClient.id || this.fromClientId.value,
clientName: this.standingIntructionsTemplateData.fromClient.displayName || this.clientNameControl.value,
locale : 'en',
dateFormat : 'dd MMMM yyyy',
locale,
dateFormat,
limit: 14,
offset: 0,
fromAccountType: this.accountTypeId,
@@ -1,10 +1,18 @@
/** Angular Imports */
import { Component, OnInit, AfterViewInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { AccountTransfersService } from '../account-transfers.service';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { DatePipe } from '@angular/common';
/** Custom Services */
import { AccountTransfersService } from '../account-transfers.service';
import { SettingsService } from 'app/settings/settings.service';
import { ClientsService } from 'app/clients/clients.service';
/**
* Create account transfers
*/
@Component({
selector: 'mifosx-make-account-transfers',
templateUrl: './make-account-transfers.component.html',
@@ -44,12 +52,15 @@ export class MakeAccountTransfersComponent implements OnInit, AfterViewInit {
* @param {Router} router Router
* @param {AccountTransfersService} accountTransfersService Account Transfers Service
* @param {DatePipe} datePipe Date Pipe
* @param {SettingsService} settingsService Settings Service
* @param {ClientsService} clientsService Clients Service
*/
constructor(private formBuilder: FormBuilder,
private route: ActivatedRoute,
private router: Router,
private accountTransfersService: AccountTransfersService,
private datePipe: DatePipe,
private settingsService: SettingsService,
private clientsService: ClientsService) {
this.route.data.subscribe((data: { accountTransferTemplate: any }) => {
this.accountTransferTemplateData = data.accountTransferTemplate;
@@ -161,8 +172,8 @@ export class MakeAccountTransfersComponent implements OnInit, AfterViewInit {
* Submits the standing instructions form
*/
submit() {
const dateFormat = 'dd MMMM yyyy';
const locale = 'en';
const dateFormat = this.settingsService.dateFormat;
const locale = this.settingsService.language.code;
const makeAccountTransferData = {
... this.makeAccountTransferForm.value,
transferDate: this.datePipe.transform(this.makeAccountTransferForm.value.transferDate, dateFormat),