Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
fix: TT-26 resolve commets
  • Loading branch information
scastillo-jp committed Mar 22, 2021
commit 89a363a878ff377a5ca13c2cc2bc34bbbc248e83
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
formControlName="name"
placeholder="Customer name"
[class.is-invalid]="customerForm.invalid && customerForm.touched"
(input)="onSearchChanges($event.target.value)"
(input)="onInputChangeCustomer($event.target.value)"
required
/>
<span
Expand All @@ -24,7 +24,7 @@
rows="3"
formControlName="description"
placeholder="Customer description"
(input)="onSearchChanges($event.target.value)"
(input)="onInputChangeCustomer($event.target.value)"
></textarea>
</div>
<button type="submit" class="btn btn-primary" [disabled]="!customerForm.valid">Save</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,22 +141,22 @@ describe('CreateCustomerComponent', () => {
});

it('if detect changes in customer information, it should emit a true', () => {
component.haveChanges = true;
spyOn(component.isHaveChanges, 'emit');
component.hasChange = true;
spyOn(component.hasChangedEvent, 'emit');

component.onSearchChanges('changes text');
component.onInputChangeCustomer('changes text');

expect(component.haveChanges).toBe(true);
expect(component.isHaveChanges.emit).toHaveBeenCalledWith(component.haveChanges);
expect(component.hasChange).toBe(true);
expect(component.hasChangedEvent.emit).toHaveBeenCalledWith(component.hasChange);
});

it('if not detect changes in customer information, it should emit a false', () => {
component.haveChanges = false;
spyOn(component.isHaveChanges, 'emit');
component.hasChange = false;
spyOn(component.hasChangedEvent, 'emit');

component.onSearchChanges('');
component.onInputChangeCustomer('');

expect(component.haveChanges).toBe(false);
expect(component.isHaveChanges.emit).toHaveBeenCalledWith(component.haveChanges);
expect(component.hasChange).toBe(false);
expect(component.hasChangedEvent.emit).toHaveBeenCalledWith(component.hasChange);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import { LoadCustomerProjects, CleanCustomerProjects } from '../../../projects/c
export class CreateCustomerComponent implements OnInit, OnDestroy {
customerForm: FormGroup;
@Input() areTabsActive: boolean;
@Input() haveChanges: boolean;
@Output() isHaveChanges = new EventEmitter<boolean>();
@Input() hasChange: boolean;
@Output() hasChangedEvent = new EventEmitter<boolean>();
@Output() changeValueAreTabsActives = new EventEmitter<boolean>();
@Output() closeCustomerComponent = new EventEmitter<boolean>();
customerToEdit: Customer;
Expand Down Expand Up @@ -70,7 +70,7 @@ export class CreateCustomerComponent implements OnInit, OnDestroy {
this.store.dispatch(new LoadProjectTypes(customerData.id));
this.store.dispatch(new LoadCustomerProjects(customerData.id));
this.changeValueAreTabsActives.emit(true);
this.isHaveChanges.emit(this.haveChanges = false);
this.hasChangedEvent.emit(this.hasChange = false);
this.customerForm.setValue({
name: customerData.name,
description: customerData.description,
Expand Down Expand Up @@ -98,8 +98,8 @@ export class CreateCustomerComponent implements OnInit, OnDestroy {
this.closeCustomerComponent.emit(false);
}

onSearchChanges(searchValue: string): void {
return searchValue ? this.isHaveChanges.emit(this.haveChanges = true) :
this.isHaveChanges.emit(this.haveChanges = false);
onInputChangeCustomer(searchValue: string): void {
return searchValue ? this.hasChangedEvent.emit(this.hasChange = true) :
this.hasChangedEvent.emit(this.hasChange = false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('CustomerTableListComponent', () => {


it('Onclick Edit, if there are changes, the modal must be presented ', () => {
component.haveChanges = true;
component.hasChange = true;
const expectMessage = 'Do you have changes in a client, do you want to discard them?';

component.editCustomer('1');
Expand All @@ -70,7 +70,7 @@ describe('CustomerTableListComponent', () => {
});

it('onClick edit, if there are not have changes dispatch SetCustomerToEdit, enable customer form and hidden modal', () => {
component.haveChanges = false;
component.hasChange = false;

spyOn(store, 'dispatch');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { ResetProjectTypeToEdit } from '../../../projects-type/store';
})
export class CustomerListComponent implements OnInit, OnDestroy, AfterViewInit {
@Input() showCustomerForm: boolean;
@Input() haveChanges: boolean;
@Input() hasChange: boolean;
@Output() changeValueShowCustomerForm = new EventEmitter<boolean>();
@Input()
customers: Customer[] = [];
Expand Down Expand Up @@ -80,7 +80,7 @@ export class CustomerListComponent implements OnInit, OnDestroy, AfterViewInit {

editCustomer(customerId: string) {
this.idToEdit = customerId;
if (this.haveChanges === true) {
if (this.hasChange) {
this.message = 'Do you have changes in a client, do you want to discard them?';
this.showModal = true;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ <h4 class="navbar-brand nav-title">{{customerName}}</h4>
<app-create-customer
[areTabsActive]="areTabsActive"
(changeValueAreTabsActives)="activeTabs($event)"
(isHaveChanges)="getChanges($event)"
(hasChangedEvent)="getChanges($event)"
(closeCustomerComponent)="closeCustomer($event)"
></app-create-customer>
</div>
Expand All @@ -67,7 +67,7 @@ <h4 class="navbar-brand nav-title">{{customerName}}</h4>
aria-labelledby="projects-type-tab"
>
<div class="container">
<app-create-project-type (isHaveChanges)="getChanges($event)"></app-create-project-type>
<app-create-project-type (hasChangedEvent)="getChanges($event)"></app-create-project-type>
<app-project-type-list></app-project-type-list>
</div>
</div>
Expand All @@ -79,7 +79,7 @@ <h4 class="navbar-brand nav-title">{{customerName}}</h4>
aria-labelledby="projects-tab"
>
<div class="container mb-1">
<app-create-project (isHaveChanges)="getChanges($event)"></app-create-project>
<app-create-project (hasChangedEvent)="getChanges($event)"></app-create-project>
<app-project-list></app-project-list>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class ManagementCustomerProjectsComponent implements OnInit {
@Output() closeCustemerForm = new EventEmitter<boolean>();
@Output() sendChanges = new EventEmitter<boolean>();
areTabsActive: boolean;
haveChanges: boolean;
hasChanged: boolean;
activeTab: string;
customerName: string;

Expand Down Expand Up @@ -44,8 +44,8 @@ export class ManagementCustomerProjectsComponent implements OnInit {
this.activeTab = activeTab;
}

getChanges($haveChanges: boolean) {
this.haveChanges = $haveChanges;
this.sendChanges.emit($haveChanges);
getChanges($value: boolean) {
this.hasChanged = $value;
this.sendChanges.emit($value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
aria-describedby=""
[class.is-invalid]="name.invalid && name.touched"
required placeholder="Name"
(input)="onSearchChanges($event.target.value)"
(input)="onInputChangeProjectType($event.target.value)"
/>
<div class="text-danger" *ngIf="(name.dirty || name.touched) && name.invalid && name.errors.required">
Name is required.
Expand All @@ -19,7 +19,7 @@
rows="3"
placeholder="Description"
formControlName="description"
(input)="onSearchChanges($event.target.value)"
(input)="onInputChangeProjectType($event.target.value)"
></textarea>
</div>
<button type="submit" class="btn btn-primary" [disabled]="!projectTypeForm.valid">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,22 +168,22 @@ describe('InputProjectTypeComponent', () => {
});

it('if detect changes in create project type , it should emit a true', () => {
component.haveChanges = true;
spyOn(component.isHaveChanges, 'emit');
component.hasChange = true;
spyOn(component.hasChangedEvent, 'emit');

component.onSearchChanges('name project');
component.onInputChangeProjectType('name project');

expect(component.haveChanges).toBe(true);
expect(component.isHaveChanges.emit).toHaveBeenCalledWith(true);
expect(component.hasChange).toBe(true);
expect(component.hasChangedEvent.emit).toHaveBeenCalledWith(true);
});

it('if not detect changes in create project type, it should emit a false', () => {
component.haveChanges = false;
spyOn(component.isHaveChanges, 'emit');
component.hasChange = false;
spyOn(component.hasChangedEvent, 'emit');

component.onSearchChanges('');
component.onInputChangeProjectType('');

expect(component.haveChanges).toBe(false);
expect(component.isHaveChanges.emit).toHaveBeenCalledWith(false);
expect(component.hasChange).toBe(false);
expect(component.hasChangedEvent.emit).toHaveBeenCalledWith(false);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { Subscription } from 'rxjs';
styleUrls: ['./create-project-type.component.scss'],
})
export class CreateProjectTypeComponent implements OnInit, OnDestroy {
@Input() haveChanges: boolean;
@Output() isHaveChanges = new EventEmitter<boolean>();
@Input() hasChange: boolean;
@Output() hasChangedEvent = new EventEmitter<boolean>();
projectTypeForm: FormGroup;
projectTypeToEdit: ProjectType;
customerId: string;
Expand Down Expand Up @@ -65,11 +65,10 @@ export class CreateProjectTypeComponent implements OnInit, OnDestroy {
id: this.projectTypeToEdit.id,
};
this.store.dispatch(new UpdateProjectType(projectType));
this.isHaveChanges.emit(this.haveChanges = false);
this.hasChangedEvent.emit(this.hasChange = false);
} else {
this.store.dispatch(new CreateProjectType({ ...projectTypeData, customer_id: this.customerId }));
this.projectTypeForm.get('description').setValue('');
this.isHaveChanges.emit(this.haveChanges = false);
}
}

Expand All @@ -81,8 +80,8 @@ export class CreateProjectTypeComponent implements OnInit, OnDestroy {
this.getCustomerIdSubscription.unsubscribe();
}

onSearchChanges(searchValue: string): void {
return searchValue ? this.isHaveChanges.emit(this.haveChanges = true) :
this.isHaveChanges.emit(this.haveChanges = false);
onInputChangeProjectType(searchValue: string): void {
return searchValue ? this.hasChangedEvent.emit(this.hasChange = true) :
this.hasChangedEvent.emit(this.hasChange = false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
placeholder="Project name"
formControlName="name"
[class.is-invalid]="name.invalid && name.touched"
(input)="onSearchChanges($event.target.value)"
(input)="onInputChangeProject($event.target.value)"
/>
<div class="text-danger" *ngIf="(name.dirty || name.touched) && name.invalid && name.errors.required">
Project name is required.
Expand All @@ -17,7 +17,7 @@
rows="3"
formControlName="description"
placeholder="Description"
(input)="onSearchChanges($event.target.value)"
(input)="onInputChangeProject($event.target.value)"
></textarea>
<div class="form-group">
<select class="custom-select custom-select-sm mt-2" formControlName="project_type_id">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,22 +248,22 @@ describe('InputProjectComponent', () => {
});

it('if detect changes in create project , it should emit a true', () => {
component.haveChanges = true;
spyOn(component.isHaveChanges, 'emit');
component.hasChange = true;
spyOn(component.hasChangedEvent, 'emit');

component.onSearchChanges('name project');
component.onInputChangeProject('name project');

expect(component.haveChanges).toBe(true);
expect(component.isHaveChanges.emit).toHaveBeenCalledWith(true);
expect(component.hasChange).toBe(true);
expect(component.hasChangedEvent.emit).toHaveBeenCalledWith(true);
});

it('if not detect changes in create project, it should emit a false', () => {
component.haveChanges = false;
spyOn(component.isHaveChanges, 'emit');
component.hasChange = false;
spyOn(component.hasChangedEvent, 'emit');

component.onSearchChanges('');
component.onInputChangeProject('');

expect(component.haveChanges).toBe(false);
expect(component.isHaveChanges.emit).toHaveBeenCalledWith(false);
expect(component.hasChange).toBe(false);
expect(component.hasChangedEvent.emit).toHaveBeenCalledWith(false);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ import { getCustomerId } from 'src/app/modules/customer-management/store/custome
styleUrls: ['./create-project.component.scss'],
})
export class CreateProjectComponent implements OnInit, OnDestroy {
@Input() haveChanges: boolean;
@Output() isHaveChanges = new EventEmitter<boolean>();
@Input() hasChange: boolean;
@Output() hasChangedEvent = new EventEmitter<boolean>();
projectForm;
projectToEdit: Project;
projectsTypes: ProjectType[] = [];
Expand Down Expand Up @@ -110,8 +110,8 @@ export class CreateProjectComponent implements OnInit, OnDestroy {
});
}

onSearchChanges(searchValue: string): void {
return searchValue ? this.isHaveChanges.emit(this.haveChanges = true) :
this.isHaveChanges.emit(this.haveChanges = false);
onInputChangeProject(searchValue: string): void {
return searchValue ? this.hasChangedEvent.emit(this.hasChange = true) :
this.hasChangedEvent.emit(this.hasChange = false);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
</div>
<app-customer-list
[showCustomerForm]="showCustomerForm"
[haveChanges]="haveChanges"
[hasChange]="hasChangeComponent"
(changeValueShowCustomerForm)="showCustomerForm = $event"
></app-customer-list>
<div class="row" *ngIf="showCustomerForm">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ describe('CustomerComponent', () => {
it('should call get changes inputs function', () => {
component.getChangesInputs(true);

expect(component.haveChanges).toBe(true);
expect(component.hasChangeComponent).toBe(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Component } from '@angular/core';
})
export class CustomerComponent {
showCustomerForm = false;
haveChanges = false;
hasChangeComponent = false;

activityName: string;

Expand All @@ -26,6 +26,6 @@ export class CustomerComponent {
}

getChangesInputs(event) {
this.haveChanges = event;
this.hasChangeComponent = event;
}
}