Skip to content

Commit 89a363a

Browse files
committed
fix: TT-26 resolve commets
1 parent 6d8b0b5 commit 89a363a

File tree

16 files changed

+68
-69
lines changed

16 files changed

+68
-69
lines changed

src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
formControlName="name"
99
placeholder="Customer name"
1010
[class.is-invalid]="customerForm.invalid && customerForm.touched"
11-
(input)="onSearchChanges($event.target.value)"
11+
(input)="onInputChangeCustomer($event.target.value)"
1212
required
1313
/>
1414
<span
@@ -24,7 +24,7 @@
2424
rows="3"
2525
formControlName="description"
2626
placeholder="Customer description"
27-
(input)="onSearchChanges($event.target.value)"
27+
(input)="onInputChangeCustomer($event.target.value)"
2828
></textarea>
2929
</div>
3030
<button type="submit" class="btn btn-primary" [disabled]="!customerForm.valid">Save</button>

src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,22 +141,22 @@ describe('CreateCustomerComponent', () => {
141141
});
142142

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

147-
component.onSearchChanges('changes text');
147+
component.onInputChangeCustomer('changes text');
148148

149-
expect(component.haveChanges).toBe(true);
150-
expect(component.isHaveChanges.emit).toHaveBeenCalledWith(component.haveChanges);
149+
expect(component.hasChange).toBe(true);
150+
expect(component.hasChangedEvent.emit).toHaveBeenCalledWith(component.hasChange);
151151
});
152152

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

157-
component.onSearchChanges('');
157+
component.onInputChangeCustomer('');
158158

159-
expect(component.haveChanges).toBe(false);
160-
expect(component.isHaveChanges.emit).toHaveBeenCalledWith(component.haveChanges);
159+
expect(component.hasChange).toBe(false);
160+
expect(component.hasChangedEvent.emit).toHaveBeenCalledWith(component.hasChange);
161161
});
162162
});

src/app/modules/customer-management/components/customer-info/components/create-customer/create-customer.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import { LoadCustomerProjects, CleanCustomerProjects } from '../../../projects/c
2323
export class CreateCustomerComponent implements OnInit, OnDestroy {
2424
customerForm: FormGroup;
2525
@Input() areTabsActive: boolean;
26-
@Input() haveChanges: boolean;
27-
@Output() isHaveChanges = new EventEmitter<boolean>();
26+
@Input() hasChange: boolean;
27+
@Output() hasChangedEvent = new EventEmitter<boolean>();
2828
@Output() changeValueAreTabsActives = new EventEmitter<boolean>();
2929
@Output() closeCustomerComponent = new EventEmitter<boolean>();
3030
customerToEdit: Customer;
@@ -70,7 +70,7 @@ export class CreateCustomerComponent implements OnInit, OnDestroy {
7070
this.store.dispatch(new LoadProjectTypes(customerData.id));
7171
this.store.dispatch(new LoadCustomerProjects(customerData.id));
7272
this.changeValueAreTabsActives.emit(true);
73-
this.isHaveChanges.emit(this.haveChanges = false);
73+
this.hasChangedEvent.emit(this.hasChange = false);
7474
this.customerForm.setValue({
7575
name: customerData.name,
7676
description: customerData.description,
@@ -98,8 +98,8 @@ export class CreateCustomerComponent implements OnInit, OnDestroy {
9898
this.closeCustomerComponent.emit(false);
9999
}
100100

101-
onSearchChanges(searchValue: string): void {
102-
return searchValue ? this.isHaveChanges.emit(this.haveChanges = true) :
103-
this.isHaveChanges.emit(this.haveChanges = false);
101+
onInputChangeCustomer(searchValue: string): void {
102+
return searchValue ? this.hasChangedEvent.emit(this.hasChange = true) :
103+
this.hasChangedEvent.emit(this.hasChange = false);
104104
}
105105
}

src/app/modules/customer-management/components/customer-info/components/customer-list/customer-list.component.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ describe('CustomerTableListComponent', () => {
6060

6161

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

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

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

7575
spyOn(store, 'dispatch');
7676

src/app/modules/customer-management/components/customer-info/components/customer-list/customer-list.component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { ResetProjectTypeToEdit } from '../../../projects-type/store';
2020
})
2121
export class CustomerListComponent implements OnInit, OnDestroy, AfterViewInit {
2222
@Input() showCustomerForm: boolean;
23-
@Input() haveChanges: boolean;
23+
@Input() hasChange: boolean;
2424
@Output() changeValueShowCustomerForm = new EventEmitter<boolean>();
2525
@Input()
2626
customers: Customer[] = [];
@@ -80,7 +80,7 @@ export class CustomerListComponent implements OnInit, OnDestroy, AfterViewInit {
8080

8181
editCustomer(customerId: string) {
8282
this.idToEdit = customerId;
83-
if (this.haveChanges === true) {
83+
if (this.hasChange) {
8484
this.message = 'Do you have changes in a client, do you want to discard them?';
8585
this.showModal = true;
8686
} else {

src/app/modules/customer-management/components/management-customer-projects/management-customer-projects.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ <h4 class="navbar-brand nav-title">{{customerName}}</h4>
5555
<app-create-customer
5656
[areTabsActive]="areTabsActive"
5757
(changeValueAreTabsActives)="activeTabs($event)"
58-
(isHaveChanges)="getChanges($event)"
58+
(hasChangedEvent)="getChanges($event)"
5959
(closeCustomerComponent)="closeCustomer($event)"
6060
></app-create-customer>
6161
</div>
@@ -67,7 +67,7 @@ <h4 class="navbar-brand nav-title">{{customerName}}</h4>
6767
aria-labelledby="projects-type-tab"
6868
>
6969
<div class="container">
70-
<app-create-project-type (isHaveChanges)="getChanges($event)"></app-create-project-type>
70+
<app-create-project-type (hasChangedEvent)="getChanges($event)"></app-create-project-type>
7171
<app-project-type-list></app-project-type-list>
7272
</div>
7373
</div>
@@ -79,7 +79,7 @@ <h4 class="navbar-brand nav-title">{{customerName}}</h4>
7979
aria-labelledby="projects-tab"
8080
>
8181
<div class="container mb-1">
82-
<app-create-project (isHaveChanges)="getChanges($event)"></app-create-project>
82+
<app-create-project (hasChangedEvent)="getChanges($event)"></app-create-project>
8383
<app-project-list></app-project-list>
8484
</div>
8585
</div>

src/app/modules/customer-management/components/management-customer-projects/management-customer-projects.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export class ManagementCustomerProjectsComponent implements OnInit {
1212
@Output() closeCustemerForm = new EventEmitter<boolean>();
1313
@Output() sendChanges = new EventEmitter<boolean>();
1414
areTabsActive: boolean;
15-
haveChanges: boolean;
15+
hasChanged: boolean;
1616
activeTab: string;
1717
customerName: string;
1818

@@ -44,8 +44,8 @@ export class ManagementCustomerProjectsComponent implements OnInit {
4444
this.activeTab = activeTab;
4545
}
4646

47-
getChanges($haveChanges: boolean) {
48-
this.haveChanges = $haveChanges;
49-
this.sendChanges.emit($haveChanges);
47+
getChanges($value: boolean) {
48+
this.hasChanged = $value;
49+
this.sendChanges.emit($value);
5050
}
5151
}

src/app/modules/customer-management/components/projects-type/components/create-project-type/create-project-type.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
aria-describedby=""
77
[class.is-invalid]="name.invalid && name.touched"
88
required placeholder="Name"
9-
(input)="onSearchChanges($event.target.value)"
9+
(input)="onInputChangeProjectType($event.target.value)"
1010
/>
1111
<div class="text-danger" *ngIf="(name.dirty || name.touched) && name.invalid && name.errors.required">
1212
Name is required.
@@ -19,7 +19,7 @@
1919
rows="3"
2020
placeholder="Description"
2121
formControlName="description"
22-
(input)="onSearchChanges($event.target.value)"
22+
(input)="onInputChangeProjectType($event.target.value)"
2323
></textarea>
2424
</div>
2525
<button type="submit" class="btn btn-primary" [disabled]="!projectTypeForm.valid">

src/app/modules/customer-management/components/projects-type/components/create-project-type/create-project-type.component.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -168,22 +168,22 @@ describe('InputProjectTypeComponent', () => {
168168
});
169169

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

174-
component.onSearchChanges('name project');
174+
component.onInputChangeProjectType('name project');
175175

176-
expect(component.haveChanges).toBe(true);
177-
expect(component.isHaveChanges.emit).toHaveBeenCalledWith(true);
176+
expect(component.hasChange).toBe(true);
177+
expect(component.hasChangedEvent.emit).toHaveBeenCalledWith(true);
178178
});
179179

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

184-
component.onSearchChanges('');
184+
component.onInputChangeProjectType('');
185185

186-
expect(component.haveChanges).toBe(false);
187-
expect(component.isHaveChanges.emit).toHaveBeenCalledWith(false);
186+
expect(component.hasChange).toBe(false);
187+
expect(component.hasChangedEvent.emit).toHaveBeenCalledWith(false);
188188
});
189189
});

src/app/modules/customer-management/components/projects-type/components/create-project-type/create-project-type.component.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import { Subscription } from 'rxjs';
1414
styleUrls: ['./create-project-type.component.scss'],
1515
})
1616
export class CreateProjectTypeComponent implements OnInit, OnDestroy {
17-
@Input() haveChanges: boolean;
18-
@Output() isHaveChanges = new EventEmitter<boolean>();
17+
@Input() hasChange: boolean;
18+
@Output() hasChangedEvent = new EventEmitter<boolean>();
1919
projectTypeForm: FormGroup;
2020
projectTypeToEdit: ProjectType;
2121
customerId: string;
@@ -65,11 +65,10 @@ export class CreateProjectTypeComponent implements OnInit, OnDestroy {
6565
id: this.projectTypeToEdit.id,
6666
};
6767
this.store.dispatch(new UpdateProjectType(projectType));
68-
this.isHaveChanges.emit(this.haveChanges = false);
68+
this.hasChangedEvent.emit(this.hasChange = false);
6969
} else {
7070
this.store.dispatch(new CreateProjectType({ ...projectTypeData, customer_id: this.customerId }));
7171
this.projectTypeForm.get('description').setValue('');
72-
this.isHaveChanges.emit(this.haveChanges = false);
7372
}
7473
}
7574

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

84-
onSearchChanges(searchValue: string): void {
85-
return searchValue ? this.isHaveChanges.emit(this.haveChanges = true) :
86-
this.isHaveChanges.emit(this.haveChanges = false);
83+
onInputChangeProjectType(searchValue: string): void {
84+
return searchValue ? this.hasChangedEvent.emit(this.hasChange = true) :
85+
this.hasChangedEvent.emit(this.hasChange = false);
8786
}
8887
}

0 commit comments

Comments
 (0)