feat: add edit share product component (#470)
- Update share product stepper components to support editing - Add edit share product component Fixes: #464
This commit is contained in:
@@ -21,6 +21,7 @@ import { EditSavingProductComponent } from './saving-products/edit-saving-produc
|
|||||||
import { ShareProductsComponent } from './share-products/share-products.component';
|
import { ShareProductsComponent } from './share-products/share-products.component';
|
||||||
import { CreateShareProductComponent } from './share-products/create-share-product/create-share-product.component';
|
import { CreateShareProductComponent } from './share-products/create-share-product/create-share-product.component';
|
||||||
import { ViewShareProductComponent } from './share-products/view-share-product/view-share-product.component';
|
import { ViewShareProductComponent } from './share-products/view-share-product/view-share-product.component';
|
||||||
|
import { EditShareProductComponent } from './share-products/edit-share-product/edit-share-product.component';
|
||||||
import { ManageTaxConfigurationsComponent } from './manage-tax-configurations/manage-tax-configurations.component';
|
import { ManageTaxConfigurationsComponent } from './manage-tax-configurations/manage-tax-configurations.component';
|
||||||
import { RecurringDepositProductsComponent } from './recurring-deposit-products/recurring-deposit-products.component';
|
import { RecurringDepositProductsComponent } from './recurring-deposit-products/recurring-deposit-products.component';
|
||||||
import { ChargesComponent } from './charges/charges.component';
|
import { ChargesComponent } from './charges/charges.component';
|
||||||
@@ -40,6 +41,7 @@ import { SavingProductAndTemplateResolver } from './saving-products/edit-saving-
|
|||||||
import { ShareProductsResolver } from './share-products/share-products.resolver';
|
import { ShareProductsResolver } from './share-products/share-products.resolver';
|
||||||
import { ShareProductsTemplateResolver } from './share-products/share-products-template.resolver';
|
import { ShareProductsTemplateResolver } from './share-products/share-products-template.resolver';
|
||||||
import { ShareProductResolver } from './share-products/share-product-resolver';
|
import { ShareProductResolver } from './share-products/share-product-resolver';
|
||||||
|
import { ShareProductAndTemplateResolver } from './share-products/edit-share-product/share-product-and-template.resolver';
|
||||||
import { RecurringDepositProductsResolver } from './recurring-deposit-products/recurring-deposit-products.resolver';
|
import { RecurringDepositProductsResolver } from './recurring-deposit-products/recurring-deposit-products.resolver';
|
||||||
import { ChargesResolver } from './charges/charges.resolver';
|
import { ChargesResolver } from './charges/charges.resolver';
|
||||||
import { FixedDepositProductsResolver } from './fixed-deposit-products/fixed-deposit-products.resolver';
|
import { FixedDepositProductsResolver } from './fixed-deposit-products/fixed-deposit-products.resolver';
|
||||||
@@ -171,6 +173,14 @@ const routes: Routes = [
|
|||||||
shareProduct: ShareProductResolver
|
shareProduct: ShareProductResolver
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: 'edit',
|
||||||
|
component: EditShareProductComponent,
|
||||||
|
data: { title: extract('Edit Share Product'), breadcrumb: 'Edit', routeParamBreadcrumb: false },
|
||||||
|
resolve: {
|
||||||
|
shareProductAndTemplate: ShareProductAndTemplateResolver
|
||||||
|
}
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -250,6 +260,7 @@ const routes: Routes = [
|
|||||||
ShareProductsResolver,
|
ShareProductsResolver,
|
||||||
ShareProductsTemplateResolver,
|
ShareProductsTemplateResolver,
|
||||||
ShareProductResolver,
|
ShareProductResolver,
|
||||||
|
ShareProductAndTemplateResolver,
|
||||||
RecurringDepositProductsResolver,
|
RecurringDepositProductsResolver,
|
||||||
ChargesResolver,
|
ChargesResolver,
|
||||||
FixedDepositProductsResolver,
|
FixedDepositProductsResolver,
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import { ShareProductAccountingStepComponent } from './share-products/share-prod
|
|||||||
import { ShareProductPreviewStepComponent } from './share-products/share-product-stepper/share-product-preview-step/share-product-preview-step.component';
|
import { ShareProductPreviewStepComponent } from './share-products/share-product-stepper/share-product-preview-step/share-product-preview-step.component';
|
||||||
import { CreateShareProductComponent } from './share-products/create-share-product/create-share-product.component';
|
import { CreateShareProductComponent } from './share-products/create-share-product/create-share-product.component';
|
||||||
import { ViewShareProductComponent } from './share-products/view-share-product/view-share-product.component';
|
import { ViewShareProductComponent } from './share-products/view-share-product/view-share-product.component';
|
||||||
|
import { EditShareProductComponent } from './share-products/edit-share-product/edit-share-product.component';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Products Module
|
* Products Module
|
||||||
@@ -100,7 +101,8 @@ import { ViewShareProductComponent } from './share-products/view-share-product/v
|
|||||||
ShareProductAccountingStepComponent,
|
ShareProductAccountingStepComponent,
|
||||||
ShareProductPreviewStepComponent,
|
ShareProductPreviewStepComponent,
|
||||||
CreateShareProductComponent,
|
CreateShareProductComponent,
|
||||||
ViewShareProductComponent
|
ViewShareProductComponent,
|
||||||
|
EditShareProductComponent
|
||||||
],
|
],
|
||||||
entryComponents: [
|
entryComponents: [
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -81,8 +81,13 @@ export class ProductsService {
|
|||||||
return this.http.get('/products/share/template');
|
return this.http.get('/products/share/template');
|
||||||
}
|
}
|
||||||
|
|
||||||
getShareProduct(shareProductId: string): Observable<any> {
|
getShareProduct(shareProductId: string, template: boolean = false): Observable<any> {
|
||||||
return this.http.get(`/products/share/${shareProductId}`);
|
const httpParams = new HttpParams().set('template', template.toString());
|
||||||
|
return this.http.get(`/products/share/${shareProductId}`, { params: httpParams });
|
||||||
|
}
|
||||||
|
|
||||||
|
updateShareProduct(shareProductId: string, shareProduct: any): Observable<any> {
|
||||||
|
return this.http.put(`/products/share/${shareProductId}`, shareProduct);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-1
@@ -54,7 +54,7 @@
|
|||||||
|
|
||||||
</mat-step>
|
</mat-step>
|
||||||
|
|
||||||
<mat-step>
|
<mat-step [stepControl]="shareProductMarketPriceForm">
|
||||||
|
|
||||||
<ng-template matStepLabel>MARKET PRICE</ng-template>
|
<ng-template matStepLabel>MARKET PRICE</ng-template>
|
||||||
|
|
||||||
|
|||||||
@@ -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" completed>
|
||||||
|
|
||||||
|
<ng-template matStepLabel>DETAILS</ng-template>
|
||||||
|
|
||||||
|
<mifosx-share-product-details-step [shareProductsTemplate]="shareProductAndTemplate"></mifosx-share-product-details-step>
|
||||||
|
|
||||||
|
</mat-step>
|
||||||
|
|
||||||
|
<mat-step [stepControl]="shareProductCurrencyForm" completed>
|
||||||
|
|
||||||
|
<ng-template matStepLabel>CURRENCY</ng-template>
|
||||||
|
|
||||||
|
<mifosx-share-product-currency-step [shareProductsTemplate]="shareProductAndTemplate"></mifosx-share-product-currency-step>
|
||||||
|
|
||||||
|
</mat-step>
|
||||||
|
|
||||||
|
<mat-step [stepControl]="shareProductTermsForm" completed>
|
||||||
|
|
||||||
|
<ng-template matStepLabel>TERMS</ng-template>
|
||||||
|
|
||||||
|
<mifosx-share-product-terms-step [shareProductsTemplate]="shareProductAndTemplate"></mifosx-share-product-terms-step>
|
||||||
|
|
||||||
|
</mat-step>
|
||||||
|
|
||||||
|
<mat-step [stepControl]="shareProductSettingsForm" completed>
|
||||||
|
|
||||||
|
<ng-template matStepLabel>SETTINGS</ng-template>
|
||||||
|
|
||||||
|
<mifosx-share-product-settings-step [shareProductsTemplate]="shareProductAndTemplate"></mifosx-share-product-settings-step>
|
||||||
|
|
||||||
|
</mat-step>
|
||||||
|
|
||||||
|
<mat-step [stepControl]="shareProductMarketPriceForm" completed>
|
||||||
|
|
||||||
|
<ng-template matStepLabel>MARKET PRICE</ng-template>
|
||||||
|
|
||||||
|
<mifosx-share-product-market-price-step [shareProductsTemplate]="shareProductAndTemplate"></mifosx-share-product-market-price-step>
|
||||||
|
|
||||||
|
</mat-step>
|
||||||
|
|
||||||
|
<mat-step completed>
|
||||||
|
|
||||||
|
<ng-template matStepLabel>CHARGES</ng-template>
|
||||||
|
|
||||||
|
<mifosx-share-product-charges-step
|
||||||
|
[shareProductsTemplate]="shareProductAndTemplate"
|
||||||
|
[currencyCode]="shareProductCurrencyForm.get('currencyCode')"
|
||||||
|
>
|
||||||
|
</mifosx-share-product-charges-step>
|
||||||
|
|
||||||
|
</mat-step>
|
||||||
|
|
||||||
|
<mat-step [stepControl]="shareProductAccountingForm" completed>
|
||||||
|
|
||||||
|
<ng-template matStepLabel>ACCOUNTING</ng-template>
|
||||||
|
|
||||||
|
<mifosx-share-product-accounting-step
|
||||||
|
[shareProductsTemplate]="shareProductAndTemplate"
|
||||||
|
[accountingRuleData]="accountingRuleData"
|
||||||
|
[shareProductFormValid]="shareProductFormValidAndNotPristine"
|
||||||
|
>
|
||||||
|
</mifosx-share-product-accounting-step>
|
||||||
|
|
||||||
|
</mat-step>
|
||||||
|
|
||||||
|
<mat-step state="preview" *ngIf="shareProductFormValidAndNotPristine" completed>
|
||||||
|
|
||||||
|
<ng-template matStepLabel>PREVIEW</ng-template>
|
||||||
|
|
||||||
|
<mifosx-share-product-preview-step
|
||||||
|
[shareProductsTemplate]="shareProductAndTemplate"
|
||||||
|
[accountingRuleData]="accountingRuleData"
|
||||||
|
[shareProduct]="shareProduct"
|
||||||
|
(submit)="submit()"
|
||||||
|
>
|
||||||
|
</mifosx-share-product-preview-step>
|
||||||
|
|
||||||
|
</mat-step>
|
||||||
|
|
||||||
|
</mat-horizontal-stepper>
|
||||||
|
|
||||||
|
</div>
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { EditShareProductComponent } from './edit-share-product.component';
|
||||||
|
|
||||||
|
describe('EditShareProductComponent', () => {
|
||||||
|
let component: EditShareProductComponent;
|
||||||
|
let fixture: ComponentFixture<EditShareProductComponent>;
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
declarations: [ EditShareProductComponent ]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(EditShareProductComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
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-edit-share-product',
|
||||||
|
templateUrl: './edit-share-product.component.html',
|
||||||
|
styleUrls: ['./edit-share-product.component.scss']
|
||||||
|
})
|
||||||
|
export class EditShareProductComponent 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;
|
||||||
|
|
||||||
|
shareProductAndTemplate: any;
|
||||||
|
accountingRuleData = ['None', 'Cash'];
|
||||||
|
|
||||||
|
constructor(private route: ActivatedRoute,
|
||||||
|
private productsService: ProductsService,
|
||||||
|
private router: Router) {
|
||||||
|
this.route.data.subscribe((data: { shareProductAndTemplate: any }) => {
|
||||||
|
this.shareProductAndTemplate = data.shareProductAndTemplate;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
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 shareProductFormValidAndNotPristine() {
|
||||||
|
return (
|
||||||
|
this.shareProductDetailsForm.valid &&
|
||||||
|
this.shareProductCurrencyForm.valid &&
|
||||||
|
this.shareProductTermsForm.valid &&
|
||||||
|
this.shareProductSettingsForm.valid &&
|
||||||
|
this.shareProductMarketPriceForm.valid &&
|
||||||
|
this.shareProductAccountingForm.valid &&
|
||||||
|
(
|
||||||
|
!this.shareProductDetailsForm.pristine ||
|
||||||
|
!this.shareProductCurrencyForm.pristine ||
|
||||||
|
!this.shareProductTermsForm.pristine ||
|
||||||
|
!this.shareProductSettingsForm.pristine ||
|
||||||
|
!this.shareProductMarketPriceForm.pristine ||
|
||||||
|
!this.shareProductChargesStep.pristine ||
|
||||||
|
!this.shareProductAccountingForm.pristine
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
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.updateShareProduct(this.shareProductAndTemplate.id, shareProduct)
|
||||||
|
.subscribe((response: any) => {
|
||||||
|
this.router.navigate(['../../', response.resourceId], { relativeTo: this.route });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
/** Angular Imports */
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Resolve, ActivatedRouteSnapshot } from '@angular/router';
|
||||||
|
|
||||||
|
/** rxjs Imports */
|
||||||
|
import { Observable } from 'rxjs';
|
||||||
|
|
||||||
|
/** Custom Services */
|
||||||
|
import { ProductsService } from '../../products.service';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Share product and template data resolver.
|
||||||
|
*/
|
||||||
|
@Injectable()
|
||||||
|
export class ShareProductAndTemplateResolver implements Resolve<Object> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {ProductsService} productsService Products service.
|
||||||
|
*/
|
||||||
|
constructor(private productsService: ProductsService) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the share product and template data.
|
||||||
|
* @returns {Observable<any>}
|
||||||
|
*/
|
||||||
|
resolve(route: ActivatedRouteSnapshot): Observable<any> {
|
||||||
|
const shareProductId = route.paramMap.get('id');
|
||||||
|
return this.productsService.getShareProduct(shareProductId, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
+15
@@ -29,6 +29,21 @@ export class ShareProductAccountingStepComponent implements OnInit {
|
|||||||
this.incomeAccountData = this.shareProductsTemplate.accountingMappingOptions.incomeAccountOptions || [];
|
this.incomeAccountData = this.shareProductsTemplate.accountingMappingOptions.incomeAccountOptions || [];
|
||||||
this.equityAccountData = this.shareProductsTemplate.accountingMappingOptions.equityAccountOptions || [];
|
this.equityAccountData = this.shareProductsTemplate.accountingMappingOptions.equityAccountOptions || [];
|
||||||
this.liabilityAccountData = this.shareProductsTemplate.accountingMappingOptions.liabilityAccountOptions || [];
|
this.liabilityAccountData = this.shareProductsTemplate.accountingMappingOptions.liabilityAccountOptions || [];
|
||||||
|
|
||||||
|
if (this.shareProductsTemplate.accountingRule) {
|
||||||
|
this.shareProductAccountingForm.patchValue({
|
||||||
|
'accountingRule': this.shareProductsTemplate.accountingRule.id
|
||||||
|
});
|
||||||
|
|
||||||
|
if (this.shareProductsTemplate.accountingRule.id === 2) {
|
||||||
|
this.shareProductAccountingForm.patchValue({
|
||||||
|
'shareReferenceId': this.shareProductsTemplate.accountingMappings.shareReferenceId.id,
|
||||||
|
'shareSuspenseId': this.shareProductsTemplate.accountingMappings.shareSuspenseId.id,
|
||||||
|
'shareEquityId': this.shareProductsTemplate.accountingMappings.shareEquityId.id,
|
||||||
|
'incomeFromFeeAccountId': this.shareProductsTemplate.accountingMappings.incomeFromFeeAccountId.id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
createShareProductAccountingForm() {
|
createShareProductAccountingForm() {
|
||||||
|
|||||||
+6
-1
@@ -19,13 +19,16 @@ export class ShareProductChargesStepComponent implements OnInit {
|
|||||||
chargesDataSource: {}[];
|
chargesDataSource: {}[];
|
||||||
displayedColumns: string[] = ['name', 'chargeCalculationType', 'amount', 'chargeTimeType', 'action'];
|
displayedColumns: string[] = ['name', 'chargeCalculationType', 'amount', 'chargeTimeType', 'action'];
|
||||||
|
|
||||||
|
pristine = true;
|
||||||
|
|
||||||
constructor(public dialog: MatDialog) {
|
constructor(public dialog: MatDialog) {
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.chargeData = this.shareProductsTemplate.chargeOptions;
|
this.chargeData = this.shareProductsTemplate.chargeOptions;
|
||||||
|
|
||||||
this.chargesDataSource = [];
|
this.chargesDataSource = this.shareProductsTemplate.charges || [];
|
||||||
|
this.pristine = true;
|
||||||
|
|
||||||
this.currencyCode.valueChanges.subscribe(() => this.chargesDataSource = []);
|
this.currencyCode.valueChanges.subscribe(() => this.chargesDataSource = []);
|
||||||
}
|
}
|
||||||
@@ -33,6 +36,7 @@ export class ShareProductChargesStepComponent implements OnInit {
|
|||||||
addCharge(charge: any) {
|
addCharge(charge: any) {
|
||||||
this.chargesDataSource = this.chargesDataSource.concat([charge.value]);
|
this.chargesDataSource = this.chargesDataSource.concat([charge.value]);
|
||||||
charge.value = '';
|
charge.value = '';
|
||||||
|
this.pristine = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteCharge(charge: any) {
|
deleteCharge(charge: any) {
|
||||||
@@ -43,6 +47,7 @@ export class ShareProductChargesStepComponent implements OnInit {
|
|||||||
if (response.delete) {
|
if (response.delete) {
|
||||||
this.chargesDataSource.splice(this.chargesDataSource.indexOf(charge), 1);
|
this.chargesDataSource.splice(this.chargesDataSource.indexOf(charge), 1);
|
||||||
this.chargesDataSource = this.chargesDataSource.concat([]);
|
this.chargesDataSource = this.chargesDataSource.concat([]);
|
||||||
|
this.pristine = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-4
@@ -21,10 +21,18 @@ export class ShareProductCurrencyStepComponent implements OnInit {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.currencyData = this.shareProductsTemplate.currencyOptions;
|
this.currencyData = this.shareProductsTemplate.currencyOptions;
|
||||||
|
|
||||||
this.shareProductCurrencyForm.patchValue({
|
if (this.shareProductsTemplate.currency) {
|
||||||
'currencyCode': this.currencyData[0].code,
|
this.shareProductCurrencyForm.patchValue({
|
||||||
'digitsAfterDecimal': 2
|
'currencyCode': this.shareProductsTemplate.currency.code,
|
||||||
});
|
'digitsAfterDecimal': this.shareProductsTemplate.currency.decimalPlaces,
|
||||||
|
'inMultiplesOf': this.shareProductsTemplate.currency.inMultiplesOf
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.shareProductCurrencyForm.patchValue({
|
||||||
|
'currencyCode': this.currencyData[0].code,
|
||||||
|
'digitsAfterDecimal': 2
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
createShareProductCurrencyForm() {
|
createShareProductCurrencyForm() {
|
||||||
|
|||||||
+10
-1
@@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -8,6 +8,8 @@ import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
|||||||
})
|
})
|
||||||
export class ShareProductDetailsStepComponent implements OnInit {
|
export class ShareProductDetailsStepComponent implements OnInit {
|
||||||
|
|
||||||
|
@Input() shareProductsTemplate: any;
|
||||||
|
|
||||||
shareProductDetailsForm: FormGroup;
|
shareProductDetailsForm: FormGroup;
|
||||||
|
|
||||||
constructor(private formBuilder: FormBuilder) {
|
constructor(private formBuilder: FormBuilder) {
|
||||||
@@ -15,6 +17,13 @@ export class ShareProductDetailsStepComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
if (this.shareProductsTemplate) {
|
||||||
|
this.shareProductDetailsForm.patchValue({
|
||||||
|
'name': this.shareProductsTemplate.name,
|
||||||
|
'shortName': this.shareProductsTemplate.shortName,
|
||||||
|
'description': this.shareProductsTemplate.description
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
createShareProductDetailsForm() {
|
createShareProductDetailsForm() {
|
||||||
|
|||||||
+21
-7
@@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
import { DatePipe } from '@angular/common';
|
import { DatePipe } from '@angular/common';
|
||||||
import { FormGroup, FormBuilder, FormArray } from '@angular/forms';
|
import { FormGroup, FormBuilder, FormArray } from '@angular/forms';
|
||||||
import { MatDialog } from '@angular/material';
|
import { MatDialog } from '@angular/material';
|
||||||
@@ -17,6 +17,8 @@ import { InputBase } from 'app/shared/form-dialog/formfield/model/input-base';
|
|||||||
})
|
})
|
||||||
export class ShareProductMarketPriceStepComponent implements OnInit {
|
export class ShareProductMarketPriceStepComponent implements OnInit {
|
||||||
|
|
||||||
|
@Input() shareProductsTemplate: any;
|
||||||
|
|
||||||
shareProductMarketPriceForm: FormGroup;
|
shareProductMarketPriceForm: FormGroup;
|
||||||
|
|
||||||
displayedColumns: string[] = ['fromDate', 'shareValue', 'actions'];
|
displayedColumns: string[] = ['fromDate', 'shareValue', 'actions'];
|
||||||
@@ -28,6 +30,9 @@ export class ShareProductMarketPriceStepComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
if (this.shareProductsTemplate) {
|
||||||
|
this.shareProductMarketPriceForm.setControl('marketPricePeriods', this.formBuilder.array((this.shareProductsTemplate.marketPrice)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
createShareProductMarketPriceForm() {
|
createShareProductMarketPriceForm() {
|
||||||
@@ -40,33 +45,42 @@ export class ShareProductMarketPriceStepComponent implements OnInit {
|
|||||||
return this.shareProductMarketPriceForm.get('marketPricePeriods') as FormArray;
|
return this.shareProductMarketPriceForm.get('marketPricePeriods') as FormArray;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setShareProductMarketPriceFormDirty() {
|
||||||
|
if (this.shareProductMarketPriceForm.pristine) {
|
||||||
|
this.shareProductMarketPriceForm.markAsDirty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
addMarketPricePeriod() {
|
addMarketPricePeriod() {
|
||||||
const data = this.getData();
|
const data = this.getData();
|
||||||
const addVariationsForBorrowerCycleDialogRef = this.dialog.open(FormDialogComponent, { data });
|
const addMarketPricePeriodDialogRef = this.dialog.open(FormDialogComponent, { data });
|
||||||
addVariationsForBorrowerCycleDialogRef.afterClosed().subscribe((response: any) => {
|
addMarketPricePeriodDialogRef.afterClosed().subscribe((response: any) => {
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
this.marketPricePeriods.push(response.data);
|
this.marketPricePeriods.push(response.data);
|
||||||
|
this.setShareProductMarketPriceFormDirty();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
editMarketPricePeriod(index: number) {
|
editMarketPricePeriod(index: number) {
|
||||||
const data = { ...this.getData(this.marketPricePeriods.at(index).value), layout: { addButtonText: 'Edit' } };
|
const data = { ...this.getData(this.marketPricePeriods.at(index).value), layout: { addButtonText: 'Edit' } };
|
||||||
const addVariationsForBorrowerCycleDialogRef = this.dialog.open(FormDialogComponent, { data });
|
const addMarketPricePeriodDialogRef = this.dialog.open(FormDialogComponent, { data });
|
||||||
addVariationsForBorrowerCycleDialogRef.afterClosed().subscribe((response: any) => {
|
addMarketPricePeriodDialogRef.afterClosed().subscribe((response: any) => {
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
this.marketPricePeriods.at(index).patchValue(response.data.value);
|
this.marketPricePeriods.at(index).patchValue(response.data.value);
|
||||||
|
this.setShareProductMarketPriceFormDirty();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteMarketPricePeriod(index: number) {
|
deleteMarketPricePeriod(index: number) {
|
||||||
const deleteVariationsForBorrowerCycleDialogRef = this.dialog.open(DeleteDialogComponent, {
|
const deleteMarketPricePeriodDialogRef = this.dialog.open(DeleteDialogComponent, {
|
||||||
data: { deleteContext: `this` }
|
data: { deleteContext: `this` }
|
||||||
});
|
});
|
||||||
deleteVariationsForBorrowerCycleDialogRef.afterClosed().subscribe((response: any) => {
|
deleteMarketPricePeriodDialogRef.afterClosed().subscribe((response: any) => {
|
||||||
if (response.delete) {
|
if (response.delete) {
|
||||||
this.marketPricePeriods.removeAt(index);
|
this.marketPricePeriods.removeAt(index);
|
||||||
|
this.setShareProductMarketPriceFormDirty();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
+11
@@ -22,6 +22,17 @@ export class ShareProductSettingsStepComponent implements OnInit {
|
|||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.minimumActivePeriodFrequencyTypeData = this.shareProductsTemplate.minimumActivePeriodFrequencyTypeOptions;
|
this.minimumActivePeriodFrequencyTypeData = this.shareProductsTemplate.minimumActivePeriodFrequencyTypeOptions;
|
||||||
this.lockinPeriodFrequencyTypeData = this.shareProductsTemplate.lockinPeriodFrequencyTypeOptions;
|
this.lockinPeriodFrequencyTypeData = this.shareProductsTemplate.lockinPeriodFrequencyTypeOptions;
|
||||||
|
|
||||||
|
this.shareProductSettingsForm.patchValue({
|
||||||
|
'minimumShares': this.shareProductsTemplate.minimumShares,
|
||||||
|
'nominalShares': this.shareProductsTemplate.nominalShares,
|
||||||
|
'maximumShares': this.shareProductsTemplate.maximumShares,
|
||||||
|
'minimumActivePeriodForDividends': this.shareProductsTemplate.minimumActivePeriod,
|
||||||
|
'minimumactiveperiodFrequencyType': this.shareProductsTemplate.minimumActivePeriodForDividendsTypeEnum && this.shareProductsTemplate.minimumActivePeriodForDividendsTypeEnum.id,
|
||||||
|
'lockinPeriodFrequency': this.shareProductsTemplate.lockinPeriod,
|
||||||
|
'lockinPeriodFrequencyType': this.shareProductsTemplate.lockPeriodTypeEnum && this.shareProductsTemplate.lockPeriodTypeEnum.id,
|
||||||
|
'allowDividendCalculationForInactiveClients': this.shareProductsTemplate.allowDividendCalculationForInactiveClients
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
createShareProductSettingsForm() {
|
createShareProductSettingsForm() {
|
||||||
|
|||||||
+12
-1
@@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit } from '@angular/core';
|
import { Component, OnInit, Input } from '@angular/core';
|
||||||
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
import { FormGroup, FormBuilder, Validators } from '@angular/forms';
|
||||||
import { combineLatest } from 'rxjs';
|
import { combineLatest } from 'rxjs';
|
||||||
|
|
||||||
@@ -9,6 +9,8 @@ import { combineLatest } from 'rxjs';
|
|||||||
})
|
})
|
||||||
export class ShareProductTermsStepComponent implements OnInit {
|
export class ShareProductTermsStepComponent implements OnInit {
|
||||||
|
|
||||||
|
@Input() shareProductsTemplate: any;
|
||||||
|
|
||||||
shareProductTermsForm: FormGroup;
|
shareProductTermsForm: FormGroup;
|
||||||
|
|
||||||
constructor(private formBuilder: FormBuilder) {
|
constructor(private formBuilder: FormBuilder) {
|
||||||
@@ -22,6 +24,15 @@ export class ShareProductTermsStepComponent implements OnInit {
|
|||||||
]).subscribe(([sharesIssued, unitPrice]: number[]) => {
|
]).subscribe(([sharesIssued, unitPrice]: number[]) => {
|
||||||
this.shareProductTermsForm.get('shareCapital').setValue(sharesIssued * unitPrice);
|
this.shareProductTermsForm.get('shareCapital').setValue(sharesIssued * unitPrice);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.shareProductsTemplate) {
|
||||||
|
this.shareProductTermsForm.patchValue({
|
||||||
|
'totalShares': this.shareProductsTemplate.totalShares,
|
||||||
|
'sharesIssued': this.shareProductsTemplate.totalSharesIssued,
|
||||||
|
'unitPrice': this.shareProductsTemplate.unitPrice,
|
||||||
|
'shareCapital': this.shareProductsTemplate.shareCapital
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
createShareProductTermsForm() {
|
createShareProductTermsForm() {
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column" class="container m-b-20">
|
<div fxLayout="row" fxLayoutAlign="end" fxLayoutGap="2%" fxLayout.lt-md="column" class="container m-b-20">
|
||||||
<button mat-raised-button color="primary">
|
<button mat-raised-button color="primary" [routerLink]="['edit']">
|
||||||
<fa-icon icon="edit"></fa-icon>
|
<fa-icon icon="edit"></fa-icon>
|
||||||
Edit
|
Edit
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user