diff --git a/src/app/products/manage-tax-groups/create-tax-group/create-tax-group.component.ts b/src/app/products/manage-tax-groups/create-tax-group/create-tax-group.component.ts
index b93ae6b9c..7028b3f27 100644
--- a/src/app/products/manage-tax-groups/create-tax-group/create-tax-group.component.ts
+++ b/src/app/products/manage-tax-groups/create-tax-group/create-tax-group.component.ts
@@ -99,13 +99,10 @@ export class CreateTaxGroupComponent implements OnInit {
layout: { addButtonText: 'Add' },
formfields: formfields
};
- const memberAttendanceDialogRef = this.dialog.open(FormDialogComponent, { data });
- memberAttendanceDialogRef.afterClosed().subscribe((response: any) => {
+ const taxComponentDialogRef = this.dialog.open(FormDialogComponent, { data });
+ taxComponentDialogRef.afterClosed().subscribe((response: any) => {
if (response.data) {
- // this.taxComponents.push(response.data.value);
this.taxComponentsDataSource = this.taxComponentsDataSource.concat(response.data.value);
-
- console.log('tjos.taxComponents: ', this.taxComponentsDataSource);
}
});
}
@@ -136,15 +133,12 @@ export class CreateTaxGroupComponent implements OnInit {
layout: { addButtonText: 'Submit' },
formfields: formfields
};
- const memberAttendanceDialogRef = this.dialog.open(FormDialogComponent, { data });
- memberAttendanceDialogRef.afterClosed().subscribe((response: any) => {
+ const taxComponentDialogRef = this.dialog.open(FormDialogComponent, { data });
+ taxComponentDialogRef.afterClosed().subscribe((response: any) => {
if (response.data) {
- // this.taxComponents.push(response.data.value);
- // this.taxComponentsDataSource = this.taxComponentsDataSource.concat(response.data.value);
const updatedMemeber = { ...taxComponent, ...response.data.value };
this.taxComponentsDataSource.splice(this.taxComponentsDataSource.indexOf(taxComponent), 1, updatedMemeber);
this.taxComponentsDataSource = this.taxComponentsDataSource.concat([]);
- console.log('tjos.taxComponents: ', this.taxComponentsDataSource);
}
});
}
@@ -177,8 +171,6 @@ export class CreateTaxGroupComponent implements OnInit {
dateFormat,
locale
};
- console.log(taxGroup);
-
for (const taxComponent of taxGroup.taxComponents) {
taxComponent.startDate = this.datePipe.transform(taxComponent.startDate, dateFormat) || '';
}
diff --git a/src/app/products/products-mix/create-product-mix/create-product-mix.component.html b/src/app/products/products-mix/create-product-mix/create-product-mix.component.html
new file mode 100644
index 000000000..74db66535
--- /dev/null
+++ b/src/app/products/products-mix/create-product-mix/create-product-mix.component.html
@@ -0,0 +1,47 @@
+
diff --git a/src/app/products/products-mix/create-product-mix/create-product-mix.component.scss b/src/app/products/products-mix/create-product-mix/create-product-mix.component.scss
new file mode 100644
index 000000000..d774f68da
--- /dev/null
+++ b/src/app/products/products-mix/create-product-mix/create-product-mix.component.scss
@@ -0,0 +1,3 @@
+.container {
+ max-width: 37rem;
+}
diff --git a/src/app/products/products-mix/create-product-mix/create-product-mix.component.spec.ts b/src/app/products/products-mix/create-product-mix/create-product-mix.component.spec.ts
new file mode 100644
index 000000000..ab855a62a
--- /dev/null
+++ b/src/app/products/products-mix/create-product-mix/create-product-mix.component.spec.ts
@@ -0,0 +1,25 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { CreateProductMixComponent } from './create-product-mix.component';
+
+describe('CreateProductMixComponent', () => {
+ let component: CreateProductMixComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ CreateProductMixComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(CreateProductMixComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/products/products-mix/create-product-mix/create-product-mix.component.ts b/src/app/products/products-mix/create-product-mix/create-product-mix.component.ts
new file mode 100644
index 000000000..8528f59e4
--- /dev/null
+++ b/src/app/products/products-mix/create-product-mix/create-product-mix.component.ts
@@ -0,0 +1,92 @@
+/** Angular Imports */
+import { Component, OnInit } from '@angular/core';
+import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
+import { Router, ActivatedRoute } from '@angular/router';
+
+/** Custom Services */
+import { ProductsService } from '../../products.service';
+
+/**
+ * Create Product mix component.
+ */
+@Component({
+ selector: 'mifosx-create-product-mix',
+ templateUrl: './create-product-mix.component.html',
+ styleUrls: ['./create-product-mix.component.scss']
+})
+export class CreateProductMixComponent implements OnInit {
+
+ /** Product mix form. */
+ productMixForm: FormGroup;
+ /** Products mix template data. */
+ productsMixTemplateData: any;
+ /** Product option data. */
+ productOptionData: any;
+ /** Product data. */
+ productData: any;
+
+ /**
+ * Retrieves the Products mix template data from `resolve`.
+ * @param {FormBuilder} formBuilder Form Builder.
+ * @param {ProductsService} productsService Products Service.
+ * @param {ActivatedRoute} route Activated Route.
+ * @param {Router} router Router for navigation.
+ */
+ constructor(private formBuilder: FormBuilder,
+ private productsService: ProductsService,
+ private route: ActivatedRoute,
+ private router: Router) {
+ this.route.data.subscribe(( data: { productsMixTemplate: any }) => {
+ this.productsMixTemplateData = data.productsMixTemplate;
+ });
+ }
+
+ /**
+ * Creates the product mix form and conditional controls of the product mix form.
+ */
+ ngOnInit() {
+ this.createProductMixForm();
+ this.setConditionalControls();
+ }
+
+ /**
+ * Creates the product mix form
+ */
+ createProductMixForm() {
+ this.productOptionData = this.productsMixTemplateData.productOptions;
+ this.productMixForm = this.formBuilder.group({
+ 'productId': ['', Validators.required],
+ 'restrictedProducts': ['', Validators.required]
+ });
+ }
+
+ /**
+ * Sets the conditional controls of the product mix form.
+ */
+ setConditionalControls() {
+ this.productMixForm.get('productId').valueChanges.subscribe(productId => {
+ this.productData = undefined;
+ this.productMixForm.get('restrictedProducts').reset();
+ this.productsService.getProductMixTemplate(productId).subscribe((productMixTemplateData: any) => {
+ const restrictedProductsData = productMixTemplateData.restrictedProducts;
+ this.productData = [...restrictedProductsData, ...productMixTemplateData.allowedProducts];
+ this.productMixForm.get('restrictedProducts').setValue([...restrictedProductsData.map((restrictedProduct: any) => restrictedProduct.id)]);
+ }
+ );
+ });
+ }
+
+ /**
+ * Submits the product mix form and creates product mix,
+ * if successful redirects to products mix.
+ */
+ submit() {
+ const productMix = {
+ restrictedProducts: this.productMixForm.value.restrictedProducts
+ };
+ const productMixId = this.productMixForm.value.productId;
+ this.productsService.createProductMix(productMix, productMixId).subscribe((response: any) => {
+ this.router.navigate(['../', response.resourceId], { relativeTo: this.route });
+ });
+ }
+}
diff --git a/src/app/products/products-mix/edit-product-mix/edit-product-mix.component.html b/src/app/products/products-mix/edit-product-mix/edit-product-mix.component.html
new file mode 100644
index 000000000..171aff0f5
--- /dev/null
+++ b/src/app/products/products-mix/edit-product-mix/edit-product-mix.component.html
@@ -0,0 +1,40 @@
+
diff --git a/src/app/products/products-mix/edit-product-mix/edit-product-mix.component.scss b/src/app/products/products-mix/edit-product-mix/edit-product-mix.component.scss
new file mode 100644
index 000000000..d774f68da
--- /dev/null
+++ b/src/app/products/products-mix/edit-product-mix/edit-product-mix.component.scss
@@ -0,0 +1,3 @@
+.container {
+ max-width: 37rem;
+}
diff --git a/src/app/products/products-mix/edit-product-mix/edit-product-mix.component.spec.ts b/src/app/products/products-mix/edit-product-mix/edit-product-mix.component.spec.ts
new file mode 100644
index 000000000..8339ac61e
--- /dev/null
+++ b/src/app/products/products-mix/edit-product-mix/edit-product-mix.component.spec.ts
@@ -0,0 +1,25 @@
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
+
+import { EditProductMixComponent } from './edit-product-mix.component';
+
+describe('EditProductMixComponent', () => {
+ let component: EditProductMixComponent;
+ let fixture: ComponentFixture;
+
+ beforeEach(async(() => {
+ TestBed.configureTestingModule({
+ declarations: [ EditProductMixComponent ]
+ })
+ .compileComponents();
+ }));
+
+ beforeEach(() => {
+ fixture = TestBed.createComponent(EditProductMixComponent);
+ component = fixture.componentInstance;
+ fixture.detectChanges();
+ });
+
+ it('should create', () => {
+ expect(component).toBeTruthy();
+ });
+});
diff --git a/src/app/products/products-mix/edit-product-mix/edit-product-mix.component.ts b/src/app/products/products-mix/edit-product-mix/edit-product-mix.component.ts
new file mode 100644
index 000000000..8cc77ff27
--- /dev/null
+++ b/src/app/products/products-mix/edit-product-mix/edit-product-mix.component.ts
@@ -0,0 +1,84 @@
+/** Angular Imports */
+import { Component, OnInit } from '@angular/core';
+import { FormGroup, FormBuilder, Validators, FormControl } from '@angular/forms';
+import { Router, ActivatedRoute } from '@angular/router';
+
+/** Custom Services */
+import { ProductsService } from '../../products.service';
+
+/**
+ * Edit Product mix component.
+ */
+@Component({
+ selector: 'mifosx-edit-product-mix',
+ templateUrl: './edit-product-mix.component.html',
+ styleUrls: ['./edit-product-mix.component.scss']
+})
+export class EditProductMixComponent implements OnInit {
+
+ /** Product mix form. */
+ productMixForm: FormGroup;
+ /** Products mix template data. */
+ productMixData: any;
+ /** Product option data. */
+ productOptionData: any;
+ /** Product data. */
+ productData: any;
+
+ /**
+ * Retrieves the Products mix template data from `resolve`.
+ * @param {FormBuilder} formBuilder Form Builder.
+ * @param {ProductsService} productsService Products Service.
+ * @param {ActivatedRoute} route Activated Route.
+ * @param {Router} router Router for navigation.
+ */
+ constructor(private formBuilder: FormBuilder,
+ private productsService: ProductsService,
+ private route: ActivatedRoute,
+ private router: Router) {
+ this.route.data.subscribe((data: { productMix: any }) => {
+ this.productMixData = data.productMix;
+ });
+ }
+
+ /**
+ * Creates the product mix form and sets data of the product mix form.
+ */
+ ngOnInit() {
+ this.createProductMixForm();
+ this.setFormData();
+ }
+
+ /**
+ * Creates the product mix form
+ */
+ createProductMixForm() {
+ this.productMixForm = this.formBuilder.group({
+ 'productId': [{ value: this.productMixData.productName, disabled: true}],
+ 'restrictedProducts': ['', Validators.required]
+ });
+ }
+
+ /**
+ * Sets the conditional controls of the product mix form.
+ */
+ setFormData() {
+ const restrictedProductsData: {}[] = this.productMixData.restrictedProducts;
+ this.productData = [...restrictedProductsData, ...this.productMixData.allowedProducts];
+ this.productMixForm.get('restrictedProducts').setValue([...restrictedProductsData.map((restrictedProduct: any) => restrictedProduct.id)]);
+ }
+
+ /**
+ * Submits the product mix form and edits product mix,
+ * if successful redirects to products mix.
+ */
+ submit() {
+ const productMix = {
+ restrictedProducts: this.productMixForm.value.restrictedProducts
+ };
+ const productMixId = this.productMixData.productId;
+ this.productsService.updateProductMix(productMix, productMixId).subscribe((response: any) => {
+ this.router.navigate(['../'], { relativeTo: this.route });
+ });
+ }
+}
diff --git a/src/app/products/products-mix/products-mix-template.resolver.ts b/src/app/products/products-mix/products-mix-template.resolver.ts
new file mode 100644
index 000000000..614de5bd2
--- /dev/null
+++ b/src/app/products/products-mix/products-mix-template.resolver.ts
@@ -0,0 +1,30 @@
+/** Angular Imports */
+import { Injectable } from '@angular/core';
+import { Resolve } from '@angular/router';
+
+/** rxjs Imports */
+import { Observable } from 'rxjs';
+
+/** Custom Services */
+import { ProductsService } from '../products.service';
+
+/**
+ * Products mix template data resolver.
+ */
+@Injectable()
+export class ProductsMixTemplateResolver implements Resolve