Move out DatePipe to use in one place Dates
This commit is contained in:
+5
-5
@@ -2,7 +2,6 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { FormBuilder, FormGroup, Validators, FormArray } from '@angular/forms';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
@@ -15,6 +14,7 @@ import { SettingsService } from 'app/settings/settings.service';
|
||||
/** Custom Components */
|
||||
import { FloatingRatePeriodDialogComponent } from '../floating-rate-period-dialog/floating-rate-period-dialog.component';
|
||||
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
|
||||
import { Dates } from 'app/core/utils/dates';
|
||||
|
||||
/**
|
||||
* Create Floating Rate Component.
|
||||
@@ -49,7 +49,7 @@ export class CreateFloatingRateComponent implements OnInit {
|
||||
* @param {FormBuilder} formBuilder Form Builder.
|
||||
* @param {ProductsService} productsService Product Service.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
* @param {DatePipe} datePipe Date Utils.
|
||||
* @param {Dates} dateUtils Date Utils.
|
||||
* @param {MatDialog} dialog Dialog reference.
|
||||
* @param {SettingsService} settingsService Settings Service.
|
||||
*/
|
||||
@@ -57,7 +57,7 @@ export class CreateFloatingRateComponent implements OnInit {
|
||||
private formBuilder: FormBuilder,
|
||||
private productsService: ProductsService,
|
||||
private route: ActivatedRoute,
|
||||
private datePipe: DatePipe,
|
||||
private dateUtils: Dates,
|
||||
private dialog: MatDialog,
|
||||
private settingsService: SettingsService) { }
|
||||
|
||||
@@ -111,7 +111,7 @@ export class CreateFloatingRateComponent implements OnInit {
|
||||
floatingRatePeriodDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response) {
|
||||
this.floatingRatePeriodsData.push({
|
||||
fromDate: this.datePipe.transform(response.fromDate, this.dateFormat),
|
||||
fromDate: this.dateUtils.formatDate(response.fromDate, this.dateFormat),
|
||||
interestRate: response.interestRate,
|
||||
isDifferentialToBaseLendingRate: response.isDifferentialToBaseLendingRate,
|
||||
locale: this.settingsService.language.code,
|
||||
@@ -137,7 +137,7 @@ export class CreateFloatingRateComponent implements OnInit {
|
||||
editFloatingRatePeriodDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response) {
|
||||
this.floatingRatePeriodsData[this.floatingRatePeriodsData.indexOf(ratePeriod)] = {
|
||||
fromDate: this.datePipe.transform(response.fromDate, this.dateFormat),
|
||||
fromDate: this.dateUtils.formatDate(response.fromDate, this.dateFormat),
|
||||
interestRate: response.interestRate,
|
||||
isDifferentialToBaseLendingRate: response.isDifferentialToBaseLendingRate,
|
||||
locale: this.settingsService.language.code,
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
import { Component, OnInit, ViewChild } from '@angular/core';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { FormBuilder, FormGroup, Validators, FormArray } from '@angular/forms';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { MatPaginator } from '@angular/material/paginator';
|
||||
import { MatSort } from '@angular/material/sort';
|
||||
@@ -15,6 +14,7 @@ import { SettingsService } from 'app/settings/settings.service';
|
||||
/** Custom Components */
|
||||
import { FloatingRatePeriodDialogComponent } from '../floating-rate-period-dialog/floating-rate-period-dialog.component';
|
||||
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
|
||||
import { Dates } from 'app/core/utils/dates';
|
||||
|
||||
/**
|
||||
* Edit Floating Rate Component.
|
||||
@@ -54,7 +54,7 @@ export class EditFloatingRateComponent implements OnInit {
|
||||
* @param {FormBuilder} formBuilder Form Builder.
|
||||
* @param {ProductsService} productsService Product Service.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
* @param {DatePipe} datePipe Date Utils.
|
||||
* @param {Dates} dateUtils Date Utils.
|
||||
* @param {MatDialog} dialog Dialog reference.
|
||||
* @param {SettingsService} settingsService Settings Service.
|
||||
*/
|
||||
@@ -62,7 +62,7 @@ export class EditFloatingRateComponent implements OnInit {
|
||||
private formBuilder: FormBuilder,
|
||||
private productsService: ProductsService,
|
||||
private route: ActivatedRoute,
|
||||
private datePipe: DatePipe,
|
||||
private dateUtils: Dates,
|
||||
private dialog: MatDialog,
|
||||
private settingsService: SettingsService) {
|
||||
this.route.data.subscribe((data: { floatingRate: any }) => {
|
||||
@@ -109,7 +109,7 @@ export class EditFloatingRateComponent implements OnInit {
|
||||
floatingRatePeriodDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response) {
|
||||
this.floatingRatePeriodsData.push({
|
||||
fromDate: this.datePipe.transform(response.fromDate, this.dateFormat),
|
||||
fromDate: this.dateUtils.formatDate(response.fromDate, this.dateFormat),
|
||||
interestRate: response.interestRate,
|
||||
isDifferentialToBaseLendingRate: response.isDifferentialToBaseLendingRate,
|
||||
locale: this.settingsService.language.code,
|
||||
@@ -136,7 +136,7 @@ export class EditFloatingRateComponent implements OnInit {
|
||||
editFloatingRatePeriodDialogRef.afterClosed().subscribe((response: any) => {
|
||||
if (response) {
|
||||
this.floatingRatePeriodsData[this.floatingRatePeriodsData.indexOf(ratePeriod)] = {
|
||||
fromDate: this.datePipe.transform(response.fromDate, this.dateFormat),
|
||||
fromDate: this.dateUtils.formatDate(response.fromDate, this.dateFormat),
|
||||
interestRate: response.interestRate,
|
||||
isDifferentialToBaseLendingRate: response.isDifferentialToBaseLendingRate,
|
||||
locale: this.settingsService.language.code,
|
||||
@@ -179,7 +179,7 @@ export class EditFloatingRateComponent implements OnInit {
|
||||
floatingRatePeriod.isActive = undefined;
|
||||
floatingRatePeriod.locale = this.settingsService.language.code;
|
||||
floatingRatePeriod.dateFormat = this.dateFormat;
|
||||
floatingRatePeriod.fromDate = this.datePipe.transform(floatingRatePeriod.fromDate, this.dateFormat);
|
||||
floatingRatePeriod.fromDate = this.dateUtils.formatDate(floatingRatePeriod.fromDate, this.dateFormat);
|
||||
});
|
||||
this.floatingRateForm.value.ratePeriods = this.floatingRatePeriodsData.length > 0 ? this.floatingRatePeriodsData : undefined;
|
||||
this.productsService.updateFloatingRate(this.route.snapshot.paramMap.get('id'), this.floatingRateForm.value)
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormGroup, FormBuilder, Validators, FormControl, FormArray } from '@angular/forms';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
|
||||
/** Custom Services */
|
||||
@@ -15,6 +14,7 @@ import { SelectBase } from 'app/shared/form-dialog/formfield/model/select-base';
|
||||
import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicker-base';
|
||||
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
|
||||
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
|
||||
import { Dates } from 'app/core/utils/dates';
|
||||
|
||||
/**
|
||||
* Create Tax Group component.
|
||||
@@ -48,7 +48,7 @@ export class CreateTaxGroupComponent implements OnInit {
|
||||
* @param {ProductsService} productsService Products Service.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
* @param {Router} router Router for navigation.
|
||||
* @param {DatePipe} datePipe Date Utils to format date.
|
||||
* @param {Dates} dateUtils Date Utils to format date.
|
||||
* @param {MatDialog} dialog Dialog reference.
|
||||
* @param {SettingsService} settingsService Settings Service.
|
||||
*/
|
||||
@@ -56,7 +56,7 @@ export class CreateTaxGroupComponent implements OnInit {
|
||||
private productsService: ProductsService,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private datePipe: DatePipe,
|
||||
private dateUtils: Dates,
|
||||
public dialog: MatDialog,
|
||||
private settingsService: SettingsService) {
|
||||
this.route.data.subscribe((data: { taxGroupTemplate: any }) => {
|
||||
@@ -176,7 +176,7 @@ export class CreateTaxGroupComponent implements OnInit {
|
||||
locale
|
||||
};
|
||||
for (const taxComponent of taxGroup.taxComponents) {
|
||||
taxComponent.startDate = this.datePipe.transform(taxComponent.startDate, dateFormat) || '';
|
||||
taxComponent.startDate = this.dateUtils.formatDate(taxComponent.startDate, dateFormat) || '';
|
||||
}
|
||||
this.productsService.createTaxGroup(taxGroup).subscribe((response: any) => {
|
||||
this.router.navigate(['../', response.resourceId], { relativeTo: this.route });
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormGroup, FormBuilder, Validators, FormControl, FormArray } from '@angular/forms';
|
||||
import { Router, ActivatedRoute } from '@angular/router';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
|
||||
/** Custom Services */
|
||||
@@ -15,6 +14,7 @@ import { SelectBase } from 'app/shared/form-dialog/formfield/model/select-base';
|
||||
import { DatepickerBase } from 'app/shared/form-dialog/formfield/model/datepicker-base';
|
||||
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
|
||||
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
|
||||
import { Dates } from 'app/core/utils/dates';
|
||||
|
||||
/**
|
||||
* Edit Tax Group component.
|
||||
@@ -48,7 +48,7 @@ export class EditTaxGroupComponent implements OnInit {
|
||||
* @param {ProductsService} productsService Products Service.
|
||||
* @param {ActivatedRoute} route Activated Route.
|
||||
* @param {Router} router Router for navigation.
|
||||
* @param {DatePipe} datePipe Date Utils to format date.
|
||||
* @param {Dates} dateUtils Date Utils to format date.
|
||||
* @param {MatDialog} dialog Dialog reference.
|
||||
* @param {SettingsService} settingsService Settings Service.
|
||||
*/
|
||||
@@ -56,7 +56,7 @@ export class EditTaxGroupComponent implements OnInit {
|
||||
private productsService: ProductsService,
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private datePipe: DatePipe,
|
||||
private dateUtils: Dates,
|
||||
public dialog: MatDialog,
|
||||
private settingsService: SettingsService) {
|
||||
this.route.data.subscribe((data: { taxGroup: any }) => {
|
||||
@@ -206,10 +206,10 @@ export class EditTaxGroupComponent implements OnInit {
|
||||
locale
|
||||
};
|
||||
for (const taxComponent of taxGroup.taxComponents) {
|
||||
taxComponent.startDate = this.datePipe.transform(taxComponent.startDate, dateFormat) || '';
|
||||
taxComponent.startDate = this.dateUtils.formatDate(taxComponent.startDate, dateFormat) || '';
|
||||
if (taxComponent.endDate) {
|
||||
delete taxComponent.startDate;
|
||||
taxComponent.endDate = this.datePipe.transform(taxComponent.endDate, dateFormat) || '';
|
||||
taxComponent.endDate = this.dateUtils.formatDate(taxComponent.endDate, dateFormat) || '';
|
||||
}
|
||||
delete taxComponent.isNew;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
/** Angular Imports */
|
||||
import { NgModule } from '@angular/core';
|
||||
import { DatePipe, CommonModule } from '@angular/common';
|
||||
import { MatOptionModule } from '@angular/material/core';
|
||||
import { MatFormFieldModule } from '@angular/material/form-field';
|
||||
import { MatSelectModule } from '@angular/material/select';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
|
||||
/** Custom Modules */
|
||||
import { SharedModule } from '../shared/shared.module';
|
||||
@@ -200,6 +195,6 @@ import { EditFixedDepositProductComponent } from './fixed-deposit-products/edit-
|
||||
CreateChargeComponent,
|
||||
EditFixedDepositProductComponent
|
||||
],
|
||||
providers: [DatePipe]
|
||||
providers: [ ]
|
||||
})
|
||||
export class ProductsModule { }
|
||||
|
||||
+4
-5
@@ -1,6 +1,5 @@
|
||||
/** Angular Imports */
|
||||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { FormGroup, FormBuilder, FormArray } from '@angular/forms';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
|
||||
@@ -13,6 +12,7 @@ import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base';
|
||||
|
||||
/** Custom Services */
|
||||
import { SettingsService } from 'app/settings/settings.service';
|
||||
import { Dates } from 'app/core/utils/dates';
|
||||
|
||||
@Component({
|
||||
selector: 'mifosx-share-product-market-price-step',
|
||||
@@ -30,14 +30,13 @@ export class ShareProductMarketPriceStepComponent implements OnInit {
|
||||
|
||||
/**
|
||||
* @param {FormBuilder} formBuilder Form Builder.
|
||||
* @param {DatePipe} datePipe Date Utils to format date.
|
||||
* @param {DatePipe} datePipe Date Utils to format date.
|
||||
* @param {Dates} dateUtils Date Utils to format date.
|
||||
* @param {SettingsService} settingsService Settings Service
|
||||
*/
|
||||
|
||||
constructor(private formBuilder: FormBuilder,
|
||||
public dialog: MatDialog,
|
||||
private datePipe: DatePipe,
|
||||
private dateUtils: Dates,
|
||||
private settingsService: SettingsService) {
|
||||
this.createShareProductMarketPriceForm();
|
||||
}
|
||||
@@ -132,7 +131,7 @@ export class ShareProductMarketPriceStepComponent implements OnInit {
|
||||
for (const marketPricePeriod of this.marketPricePeriods.value) {
|
||||
marketPricePeriods.push({
|
||||
...marketPricePeriod,
|
||||
fromDate: this.datePipe.transform(marketPricePeriod.fromDate, dateFormat),
|
||||
fromDate: this.dateUtils.formatDate(marketPricePeriod.fromDate, dateFormat),
|
||||
dateFormat,
|
||||
locale
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user