forked from xurror/web-app
-
Notifications
You must be signed in to change notification settings - Fork 0
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 share product component (openMF#462)
- Add share product stepper components
- Add create share product component
- Add datepicker-base.ts
Fixes: #190
- Loading branch information
1 parent
5436c10
commit c3dcd48
Showing
44 changed files
with
1,691 additions
and
28 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
106 changes: 106 additions & 0 deletions
106
src/app/products/share-products/create-share-product/create-share-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,106 @@ | ||
<div class="container"> | ||
|
||
<mat-horizontal-stepper class="mat-elevation-z8" labelPosition="bottom" #shareProductStepper> | ||
|
||
<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]="shareProductDetailsForm"> | ||
|
||
<ng-template matStepLabel>DETAILS</ng-template> | ||
|
||
<mifosx-share-product-details-step></mifosx-share-product-details-step> | ||
|
||
</mat-step> | ||
|
||
<mat-step [stepControl]="shareProductCurrencyForm"> | ||
|
||
<ng-template matStepLabel>CURRENCY</ng-template> | ||
|
||
<mifosx-share-product-currency-step [shareProductsTemplate]="shareProductsTemplate"></mifosx-share-product-currency-step> | ||
|
||
</mat-step> | ||
|
||
<mat-step [stepControl]="shareProductTermsForm"> | ||
|
||
<ng-template matStepLabel>TERMS</ng-template> | ||
|
||
<mifosx-share-product-terms-step></mifosx-share-product-terms-step> | ||
|
||
</mat-step> | ||
|
||
<mat-step [stepControl]="shareProductSettingsForm"> | ||
|
||
<ng-template matStepLabel>SETTINGS</ng-template> | ||
|
||
<mifosx-share-product-settings-step [shareProductsTemplate]="shareProductsTemplate"></mifosx-share-product-settings-step> | ||
|
||
</mat-step> | ||
|
||
<mat-step> | ||
|
||
<ng-template matStepLabel>MARKET PRICE</ng-template> | ||
|
||
<mifosx-share-product-market-price-step></mifosx-share-product-market-price-step> | ||
|
||
</mat-step> | ||
|
||
<mat-step> | ||
|
||
<ng-template matStepLabel>CHARGES</ng-template> | ||
|
||
<mifosx-share-product-charges-step | ||
[shareProductsTemplate]="shareProductsTemplate" | ||
[currencyCode]="shareProductCurrencyForm.get('currencyCode')" | ||
> | ||
</mifosx-share-product-charges-step> | ||
|
||
</mat-step> | ||
|
||
<mat-step [stepControl]="shareProductAccountingForm"> | ||
|
||
<ng-template matStepLabel>ACCOUNTING</ng-template> | ||
|
||
<mifosx-share-product-accounting-step | ||
[shareProductsTemplate]="shareProductsTemplate" | ||
[accountingRuleData]="accountingRuleData" | ||
[shareProductFormValid]="shareProductFormValid" | ||
> | ||
</mifosx-share-product-accounting-step> | ||
|
||
</mat-step> | ||
|
||
<mat-step state="preview" *ngIf="shareProductFormValid" completed> | ||
|
||
<ng-template matStepLabel>PREVIEW</ng-template> | ||
|
||
<mifosx-share-product-preview-step | ||
[shareProductsTemplate]="shareProductsTemplate" | ||
[accountingRuleData]="accountingRuleData" | ||
[shareProduct]="shareProduct" | ||
(submit)="submit()" | ||
> | ||
</mifosx-share-product-preview-step> | ||
|
||
</mat-step> | ||
|
||
</mat-horizontal-stepper> | ||
|
||
</div> |
Empty file.
25 changes: 25 additions & 0 deletions
25
src/app/products/share-products/create-share-product/create-share-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 { CreateShareProductComponent } from './create-share-product.component'; | ||
|
||
describe('CreateShareProductComponent', () => { | ||
let component: CreateShareProductComponent; | ||
let fixture: ComponentFixture<CreateShareProductComponent>; | ||
|
||
beforeEach(async(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ CreateShareProductComponent ] | ||
}) | ||
.compileComponents(); | ||
})); | ||
|
||
beforeEach(() => { | ||
fixture = TestBed.createComponent(CreateShareProductComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
103 changes: 103 additions & 0 deletions
103
src/app/products/share-products/create-share-product/create-share-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,103 @@ | ||
import { Component, OnInit, ViewChild } from '@angular/core'; | ||
import { ActivatedRoute, Router } from '@angular/router'; | ||
|
||
import { ShareProductDetailsStepComponent } from '../share-product-stepper/share-product-details-step/share-product-details-step.component'; | ||
import { ShareProductCurrencyStepComponent } from '../share-product-stepper/share-product-currency-step/share-product-currency-step.component'; | ||
import { ShareProductTermsStepComponent } from '../share-product-stepper/share-product-terms-step/share-product-terms-step.component'; | ||
import { ShareProductSettingsStepComponent } from '../share-product-stepper/share-product-settings-step/share-product-settings-step.component'; | ||
import { ShareProductMarketPriceStepComponent } from '../share-product-stepper/share-product-market-price-step/share-product-market-price-step.component'; | ||
import { ShareProductChargesStepComponent } from '../share-product-stepper/share-product-charges-step/share-product-charges-step.component'; | ||
import { ShareProductAccountingStepComponent } from '../share-product-stepper/share-product-accounting-step/share-product-accounting-step.component'; | ||
|
||
import { ProductsService } from 'app/products/products.service'; | ||
|
||
@Component({ | ||
selector: 'mifosx-create-share-product', | ||
templateUrl: './create-share-product.component.html', | ||
styleUrls: ['./create-share-product.component.scss'] | ||
}) | ||
export class CreateShareProductComponent implements OnInit { | ||
|
||
@ViewChild(ShareProductDetailsStepComponent) shareProductDetailsStep: ShareProductDetailsStepComponent; | ||
@ViewChild(ShareProductCurrencyStepComponent) shareProductCurrencyStep: ShareProductCurrencyStepComponent; | ||
@ViewChild(ShareProductTermsStepComponent) shareProductTermsStep: ShareProductTermsStepComponent; | ||
@ViewChild(ShareProductSettingsStepComponent) shareProductSettingsStep: ShareProductSettingsStepComponent; | ||
@ViewChild(ShareProductMarketPriceStepComponent) shareProductMarketPriceStep: ShareProductMarketPriceStepComponent; | ||
@ViewChild(ShareProductChargesStepComponent) shareProductChargesStep: ShareProductChargesStepComponent; | ||
@ViewChild(ShareProductAccountingStepComponent) shareProductAccountingStep: ShareProductAccountingStepComponent; | ||
|
||
shareProductsTemplate: any; | ||
accountingRuleData = ['None', 'Cash']; | ||
|
||
constructor(private route: ActivatedRoute, | ||
private productsService: ProductsService, | ||
private router: Router) { | ||
this.route.data.subscribe((data: { shareProductsTemplate: any }) => { | ||
this.shareProductsTemplate = data.shareProductsTemplate; | ||
}); | ||
} | ||
|
||
ngOnInit() { | ||
} | ||
|
||
get shareProductDetailsForm() { | ||
return this.shareProductDetailsStep.shareProductDetailsForm; | ||
} | ||
|
||
get shareProductCurrencyForm() { | ||
return this.shareProductCurrencyStep.shareProductCurrencyForm; | ||
} | ||
|
||
get shareProductTermsForm() { | ||
return this.shareProductTermsStep.shareProductTermsForm; | ||
} | ||
|
||
get shareProductSettingsForm() { | ||
return this.shareProductSettingsStep.shareProductSettingsForm; | ||
} | ||
|
||
get shareProductMarketPriceForm() { | ||
return this.shareProductMarketPriceStep.shareProductMarketPriceForm; | ||
} | ||
|
||
get shareProductAccountingForm() { | ||
return this.shareProductAccountingStep.shareProductAccountingForm; | ||
} | ||
|
||
get shareProductFormValid() { | ||
return ( | ||
this.shareProductDetailsForm.valid && | ||
this.shareProductCurrencyForm.valid && | ||
this.shareProductTermsForm.valid && | ||
this.shareProductSettingsForm.valid && | ||
this.shareProductMarketPriceForm.valid && | ||
this.shareProductAccountingForm.valid | ||
); | ||
} | ||
|
||
get shareProduct() { | ||
return { | ||
...this.shareProductDetailsStep.shareProductDetails, | ||
...this.shareProductCurrencyStep.shareProductCurrency, | ||
...this.shareProductTermsStep.shareProductTerms, | ||
...this.shareProductSettingsStep.shareProductSettings, | ||
...this.shareProductMarketPriceStep.shareProductMarketPrice, | ||
...this.shareProductChargesStep.shareProductCharges, | ||
...this.shareProductAccountingStep.shareProductAccounting | ||
}; | ||
} | ||
|
||
submit() { | ||
// TODO: Update once language and date settings are setup | ||
const shareProduct = { | ||
...this.shareProduct, | ||
chargesSelected: this.shareProduct.chargesSelected.map((charge: any) => ({ id: charge.id })), | ||
locale: 'en' // locale required for digitsAfterDecimal | ||
}; | ||
this.productsService.createShareProduct(shareProduct) | ||
.subscribe((response: any) => { | ||
this.router.navigate(['../', response.resourceId], { relativeTo: this.route }); | ||
}); | ||
} | ||
|
||
} |
Oops, something went wrong.