refactor: savings module (#1226)

See: #1196
This commit is contained in:
Karan Takalkar
2020-08-25 17:46:54 +05:30
committed by GitHub
parent f215e1aa96
commit efdd779aa9
30 changed files with 129 additions and 103 deletions
@@ -5,7 +5,6 @@ import { FormControl } from '@angular/forms';
import { DatePipe } from '@angular/common';
/** Custom Dialogs */
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
import { FormDialogComponent } from 'app/shared/form-dialog/form-dialog.component';
/** Custom Models */
@@ -180,15 +179,8 @@ export class SavingsAccountChargesStepComponent implements OnInit, OnChanges {
* @param {any} charge Charge
*/
deleteCharge(charge: any) {
const deleteChargeDialogRef = this.dialog.open(DeleteDialogComponent, {
data: { deleteContext: `charge ${charge.name}` }
});
deleteChargeDialogRef.afterClosed().subscribe((response: any) => {
if (response.delete) {
this.chargesDataSource.splice(this.chargesDataSource.indexOf(charge), 1);
this.chargesDataSource = this.chargesDataSource.concat([]);
}
});
this.chargesDataSource.splice(this.chargesDataSource.indexOf(charge), 1);
this.chargesDataSource = this.chargesDataSource.concat([]);
this.pristine = false;
}
@@ -74,9 +74,10 @@ export class SavingsAccountDetailsStepComponent implements OnInit {
* Fetches savings account product template on productId value changes
*/
buildDependencies() {
const clientId = this.savingsAccountTemplate.clientId;
const entityId = this.savingsAccountTemplate.clientId || this.savingsAccountTemplate.groupId;
this.savingsAccountDetailsForm.get('productId').valueChanges.subscribe((productId: string) => {
this.savingsService.getSavingsAccountTemplate(clientId, productId).subscribe((response: any) => {
this.savingsService.getSavingsAccountTemplate(entityId, productId, this.savingsAccountTemplate.groupId ? true : false)
.subscribe((response: any) => {
this.savingsAccountProductTemplate.emit(response);
this.fieldOfficerData = response.fieldOfficerOptions;
if (!this.isFieldOfficerPatched && this.savingsAccountTemplate.fieldOfficerId) {