-
Notifications
You must be signed in to change notification settings - Fork 619
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add create saving product component (#455)
- Add saving product stepper components
- Add create saving product component
Fixes: #189
- Loading branch information
1 parent
0edfacf
commit dd1a116
Showing
37 changed files
with
2,091 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
99 changes: 99 additions & 0 deletions
99
src/app/products/saving-products/create-saving-product/create-saving-product.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<div class="container"> | ||
|
||
<mat-horizontal-stepper class="mat-elevation-z8" labelPosition="bottom" #savingProductStepper> | ||
|
||
<ng-template matStepperIcon="number"> | ||
<fa-icon icon="pencil-alt" size="sm"></fa-icon> | ||
</ng-template> | ||
|
||
<ng-template matStepperIcon="edit"> | ||
<fa-icon icon="pencil-alt" size="sm"></fa-icon> | ||
</ng-template> | ||
|
||
<ng-template matStepperIcon="done"> | ||
<fa-icon icon="check" size="sm"></fa-icon> | ||
</ng-template> | ||
|
||
<ng-template matStepperIcon="error"> | ||
<fa-icon icon="exclamation-triangle" size="lg"></fa-icon> | ||
</ng-template> | ||
|
||
<ng-template matStepperIcon="preview"> | ||
<fa-icon icon="eye" size="sm"></fa-icon> | ||
</ng-template> | ||
|
||
<mat-step [stepControl]="savingProductDetailsForm"> | ||
|
||
<ng-template matStepLabel>DETAILS</ng-template> | ||
|
||
<mifosx-saving-product-details-step></mifosx-saving-product-details-step> | ||
|
||
</mat-step> | ||
|
||
<mat-step [stepControl]="savingProductCurrencyForm"> | ||
|
||
<ng-template matStepLabel>CURRENCY</ng-template> | ||
|
||
<mifosx-saving-product-currency-step [savingProductsTemplate]="savingProductsTemplate"></mifosx-saving-product-currency-step> | ||
|
||
</mat-step> | ||
|
||
<mat-step [stepControl]="savingProductTermsForm"> | ||
|
||
<ng-template matStepLabel>TERMS</ng-template> | ||
|
||
<mifosx-saving-product-terms-step [savingProductsTemplate]="savingProductsTemplate"></mifosx-saving-product-terms-step> | ||
|
||
</mat-step> | ||
|
||
<mat-step [stepControl]="savingProductSettingsForm"> | ||
|
||
<ng-template matStepLabel>SETTINGS</ng-template> | ||
|
||
<mifosx-saving-product-settings-step [savingProductsTemplate]="savingProductsTemplate"></mifosx-saving-product-settings-step> | ||
|
||
</mat-step> | ||
|
||
<mat-step> | ||
|
||
<ng-template matStepLabel>CHARGES</ng-template> | ||
|
||
<mifosx-saving-product-charges-step | ||
[savingProductsTemplate]="savingProductsTemplate" | ||
[currencyCode]="savingProductCurrencyForm.get('currencyCode')" | ||
> | ||
</mifosx-saving-product-charges-step> | ||
|
||
</mat-step> | ||
|
||
<mat-step [stepControl]="savingProductAccountingForm"> | ||
|
||
<ng-template matStepLabel>ACCOUNTING</ng-template> | ||
|
||
<mifosx-saving-product-accounting-step | ||
[savingProductsTemplate]="savingProductsTemplate" | ||
[accountingRuleData]="accountingRuleData" | ||
[isDormancyTrackingActive]="savingProductSettingsForm.get('isDormancyTrackingActive')" | ||
[savingProductFormValid]="savingProductFormValid" | ||
> | ||
</mifosx-saving-product-accounting-step> | ||
|
||
</mat-step> | ||
|
||
<mat-step state="preview" *ngIf="savingProductFormValid" completed> | ||
|
||
<ng-template matStepLabel>PREVIEW</ng-template> | ||
|
||
<mifosx-saving-product-preview-step | ||
[savingProductsTemplate]="savingProductsTemplate" | ||
[accountingRuleData]="accountingRuleData" | ||
[savingProduct]="savingProduct" | ||
(submit)="submit()" | ||
> | ||
</mifosx-saving-product-preview-step> | ||
|
||
</mat-step> | ||
|
||
</mat-horizontal-stepper> | ||
|
||
</div> |
4 changes: 4 additions & 0 deletions
4
src/app/products/saving-products/create-saving-product/create-saving-product.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
fa-icon { | ||
position: relative; | ||
left: 5%; | ||
} |
25 changes: 25 additions & 0 deletions
25
...pp/products/saving-products/create-saving-product/create-saving-product.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { async, ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { CreateSavingProductComponent } from './create-saving-product.component'; | ||
|
||
describe('CreateSavingProductComponent', () => { | ||
let component: CreateSavingProductComponent; | ||
let fixture: ComponentFixture<CreateSavingProductComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ CreateSavingProductComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(CreateSavingProductComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
96 changes: 96 additions & 0 deletions
96
src/app/products/saving-products/create-saving-product/create-saving-product.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { Component, OnInit, ViewChild } from '@angular/core'; | ||
import { ActivatedRoute, Router } from '@angular/router'; | ||
|
||
import { SavingProductDetailsStepComponent } from '../saving-product-stepper/saving-product-details-step/saving-product-details-step.component'; | ||
import { SavingProductCurrencyStepComponent } from '../saving-product-stepper/saving-product-currency-step/saving-product-currency-step.component'; | ||
import { SavingProductTermsStepComponent } from '../saving-product-stepper/saving-product-terms-step/saving-product-terms-step.component'; | ||
import { SavingProductSettingsStepComponent } from '../saving-product-stepper/saving-product-settings-step/saving-product-settings-step.component'; | ||
import { SavingProductChargesStepComponent } from '../saving-product-stepper/saving-product-charges-step/saving-product-charges-step.component'; | ||
import { SavingProductAccountingStepComponent } from '../saving-product-stepper/saving-product-accounting-step/saving-product-accounting-step.component'; | ||
|
||
import { ProductsService } from 'app/products/products.service'; | ||
|
||
@Component({ | ||
selector: 'mifosx-create-saving-product', | ||
templateUrl: './create-saving-product.component.html', | ||
styleUrls: ['./create-saving-product.component.scss'] | ||
}) | ||
export class CreateSavingProductComponent implements OnInit { | ||
|
||
@ViewChild(SavingProductDetailsStepComponent) savingProductDetailsStep: SavingProductDetailsStepComponent; | ||
@ViewChild(SavingProductCurrencyStepComponent) savingProductCurrencyStep: SavingProductCurrencyStepComponent; | ||
@ViewChild(SavingProductTermsStepComponent) savingProductTermsStep: SavingProductTermsStepComponent; | ||
@ViewChild(SavingProductSettingsStepComponent) savingProductSettingsStep: SavingProductSettingsStepComponent; | ||
@ViewChild(SavingProductChargesStepComponent) savingProductChargesStep: SavingProductChargesStepComponent; | ||
@ViewChild(SavingProductAccountingStepComponent) savingProductAccountingStep: SavingProductAccountingStepComponent; | ||
|
||
savingProductsTemplate: any; | ||
accountingRuleData = ['None', 'Cash']; | ||
|
||
constructor(private route: ActivatedRoute, | ||
private productsService: ProductsService, | ||
private router: Router) { | ||
this.route.data.subscribe((data: { savingProductsTemplate: any }) => { | ||
this.savingProductsTemplate = data.savingProductsTemplate; | ||
}); | ||
} | ||
|
||
ngOnInit() { | ||
} | ||
|
||
get savingProductDetailsForm() { | ||
return this.savingProductDetailsStep.savingProductDetailsForm; | ||
} | ||
|
||
get savingProductCurrencyForm() { | ||
return this.savingProductCurrencyStep.savingProductCurrencyForm; | ||
} | ||
|
||
get savingProductTermsForm() { | ||
return this.savingProductTermsStep.savingProductTermsForm; | ||
} | ||
|
||
get savingProductSettingsForm() { | ||
return this.savingProductSettingsStep.savingProductSettingsForm; | ||
} | ||
|
||
get savingProductAccountingForm() { | ||
return this.savingProductAccountingStep.savingProductAccountingForm; | ||
} | ||
|
||
get savingProductFormValid() { | ||
return ( | ||
this.savingProductDetailsForm.valid && | ||
this.savingProductCurrencyForm.valid && | ||
this.savingProductTermsForm.valid && | ||
this.savingProductSettingsForm.valid && | ||
this.savingProductAccountingForm.valid | ||
); | ||
} | ||
|
||
get savingProduct() { | ||
return { | ||
...this.savingProductDetailsStep.savingProductDetails, | ||
...this.savingProductCurrencyStep.savingProductCurrency, | ||
...this.savingProductTermsStep.savingProductTerms, | ||
...this.savingProductSettingsStep.savingProductSettings, | ||
...this.savingProductChargesStep.savingProductCharges, | ||
...this.savingProductAccountingStep.savingProductAccounting | ||
}; | ||
} | ||
|
||
submit() { | ||
// TODO: Update once language and date settings are setup | ||
const savingProduct = { | ||
...this.savingProduct, | ||
charges: this.savingProduct.charges.map((charge: any) => ({ id: charge.id })), | ||
locale: 'en' // locale required for nominalAnnualInterestRate | ||
}; | ||
delete savingProduct.advancedAccountingRules; | ||
this.productsService.createSavingProduct(savingProduct) | ||
.subscribe((response: any) => { | ||
this.router.navigate(['../', response.resourceId], { relativeTo: this.route }); | ||
}); | ||
} | ||
|
||
} |
Oops, something went wrong.