diff --git a/src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.spec.ts b/src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.spec.ts index dc760cc26..2ba63c9c5 100644 --- a/src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.spec.ts +++ b/src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.spec.ts @@ -66,10 +66,12 @@ describe('CreateCustomerComponent', () => { it('should call resetCustomerForm', () => { spyOn(component.customerForm, 'reset'); + spyOn(component.closeCustomerComponent, 'emit'); component.resetCustomerForm(); expect(component.customerForm.reset).toHaveBeenCalled(); + expect(component.closeCustomerComponent.emit).toHaveBeenCalledWith(false); }); it('onSubmit, dispatch CreateCustomer and LoadCustomers actions', () => { @@ -84,12 +86,14 @@ describe('CreateCustomerComponent', () => { it('should call resetCustomerForm', () => { spyOn(component.customerForm, 'reset'); spyOn(store, 'dispatch'); + spyOn(component.closeCustomerComponent, 'emit'); component.resetCustomerForm(); expect(store.dispatch).toHaveBeenCalledTimes(1); expect(store.dispatch).toHaveBeenCalledWith(new ResetCustomerToEdit()); expect(component.customerForm.reset).toHaveBeenCalled(); + expect(component.closeCustomerComponent.emit).toHaveBeenCalledWith(false); }); it('should be enable tabs and show message Customer created successfully! ', () => { diff --git a/src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.ts b/src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.ts index 6aa352af2..80bf45285 100644 --- a/src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.ts +++ b/src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.ts @@ -24,6 +24,7 @@ export class CreateCustomerComponent implements OnInit, OnDestroy { customerForm: FormGroup; @Input() areTabsActive: boolean; @Output() changeValueAreTabsActives = new EventEmitter(); + @Output() closeCustomerComponent = new EventEmitter(); customerToEdit: Customer; editSubscription: Subscription; @@ -88,5 +89,6 @@ export class CreateCustomerComponent implements OnInit, OnDestroy { resetCustomerForm() { this.customerForm.reset(); this.store.dispatch(new ResetCustomerToEdit()); + this.closeCustomerComponent.emit(false); } } diff --git a/src/app/modules/customer-management/components/management-customer-projects/management-customer-projects.component.html b/src/app/modules/customer-management/components/management-customer-projects/management-customer-projects.component.html index f9578d3c6..f2ccd97be 100644 --- a/src/app/modules/customer-management/components/management-customer-projects/management-customer-projects.component.html +++ b/src/app/modules/customer-management/components/management-customer-projects/management-customer-projects.component.html @@ -51,6 +51,7 @@
{ component.showTab('projects'); expect(component.activeTab).toEqual('projects'); }); + it('should call close customer function', () => { + spyOn(component.closeCustemerForm, 'emit'); + component.closeCustomer(false); + expect(component.closeCustemerForm.emit).toHaveBeenCalledWith(false); + }); }); diff --git a/src/app/modules/customer-management/components/management-customer-projects/management-customer-projects.component.ts b/src/app/modules/customer-management/components/management-customer-projects/management-customer-projects.component.ts index b70ec3658..b1fd07b4e 100644 --- a/src/app/modules/customer-management/components/management-customer-projects/management-customer-projects.component.ts +++ b/src/app/modules/customer-management/components/management-customer-projects/management-customer-projects.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { Component, Output, EventEmitter } from '@angular/core'; @Component({ selector: 'app-management-customer-projects', @@ -6,6 +6,7 @@ import { Component } from '@angular/core'; styleUrls: ['./management-customer-projects.component.scss'], }) export class ManagementCustomerProjectsComponent { + @Output() closeCustemerForm = new EventEmitter(); areTabsActive: boolean; activeTab: string; constructor() {} @@ -17,6 +18,10 @@ export class ManagementCustomerProjectsComponent { }, 1); } + closeCustomer(event) { + this.closeCustemerForm.emit(event); + } + showTab(activeTab: string) { this.activeTab = activeTab; } diff --git a/src/app/modules/customer-management/pages/customer.component.html b/src/app/modules/customer-management/pages/customer.component.html index 7b9b98898..28a99bb04 100644 --- a/src/app/modules/customer-management/pages/customer.component.html +++ b/src/app/modules/customer-management/pages/customer.component.html @@ -10,7 +10,7 @@ >
- +
diff --git a/src/app/modules/customer-management/pages/customer.component.spec.ts b/src/app/modules/customer-management/pages/customer.component.spec.ts index e161dcb5a..6b42b904e 100644 --- a/src/app/modules/customer-management/pages/customer.component.spec.ts +++ b/src/app/modules/customer-management/pages/customer.component.spec.ts @@ -27,4 +27,8 @@ describe('CustomerComponent', () => { component.activateCustomerForm(); expect(component.showCustomerForm).toBeTruthy(); }); + it('should call close customer function', () => { + component.closeCustomerForm(false); + expect(component.showCustomerForm).toBe(false); + }); }); diff --git a/src/app/modules/customer-management/pages/customer.component.ts b/src/app/modules/customer-management/pages/customer.component.ts index b681e7cf3..f70f9412c 100644 --- a/src/app/modules/customer-management/pages/customer.component.ts +++ b/src/app/modules/customer-management/pages/customer.component.ts @@ -6,10 +6,12 @@ import { Component } from '@angular/core'; styleUrls: ['./customer.component.scss'], }) export class CustomerComponent { - showCustomerForm = false; activateCustomerForm() { this.showCustomerForm = true; } + closeCustomerForm(event) { + this.showCustomerForm = event; + } }