Skip to content

Commit 1d2465f

Browse files
committed
fix: #184 Mark Customer information tab as active on customer edition
1 parent 3a241c3 commit 1d2465f

File tree

4 files changed

+58
-14
lines changed

4 files changed

+58
-14
lines changed

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

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,48 @@
22
<ul class="nav nav-tabs mt-2" id="myTab" role="tablist">
33
<li class="nav-item">
44
<a
5-
class="nav-link active nav-active text-black font-weight-bold"
5+
class="nav-link nav-active text-black font-weight-bold"
6+
[ngClass]="{ active: activeTab === 'customer-information' }"
67
id="customer-information-tab"
78
data-toggle="tab"
89
href="#customer-information"
910
role="tab"
1011
aria-controls="customer-information"
12+
(click)="showTab('customer-information')"
1113
>Customer information</a
1214
>
1315
</li>
1416
<li class="nav-item">
1517
<a
1618
class="nav-link text-black font-weight-bold"
17-
[ngClass]="{ 'nav-active': areTabsActive, disabled: !areTabsActive }"
19+
[ngClass]="{ 'nav-active': areTabsActive, disabled: !areTabsActive, active: activeTab === 'projects-type' }"
1820
id="projects-type-tab"
1921
data-toggle="tab"
2022
href="#projectsType"
2123
role="tab"
2224
aria-controls="projects-type"
25+
(click)="showTab('projects-type')"
2326
>Project types</a
2427
>
2528
</li>
2629
<li class="nav-item">
2730
<a
2831
class="nav-link text-black font-weight-bold"
29-
[ngClass]="{ 'nav-active': areTabsActive, disabled: !areTabsActive }"
32+
[ngClass]="{ 'nav-active': areTabsActive, disabled: !areTabsActive, active: activeTab === 'projects' }"
3033
id="projects-tab"
3134
data-toggle="tab"
3235
href="#projects"
3336
role="tab"
3437
aria-controls="projects"
38+
(click)="showTab('projects')"
3539
>Projects</a
3640
>
3741
</li>
3842
</ul>
3943
<div class="tab-content" id="myTabContent">
4044
<div
41-
class="tab-pane fade show active mt-3"
45+
class="tab-pane fade mt-3"
46+
[ngClass]="{ 'show active': activeTab === 'customer-information' }"
4247
id="customer-information"
4348
role="tabpanel"
4449
aria-labelledby="customer-information-tab"
@@ -48,17 +53,29 @@
4853
(changeValueAreTabsActives)="activeTabs($event)"
4954
></app-create-customer>
5055
</div>
51-
<div class="tab-pane fade mt-3" id="projects" role="tabpanel" aria-labelledby="projects-tab">
52-
<div class="container mb-1">
53-
<app-create-project></app-create-project>
54-
<app-project-list></app-project-list>
55-
</div>
56-
</div>
57-
<div class="tab-pane fade mt-3" id="projectsType" role="tabpanel" aria-labelledby="projects-type-tab">
56+
<div
57+
class="tab-pane fade mt-3"
58+
[ngClass]="{ 'show active': activeTab === 'projects-type' }"
59+
id="projectsType"
60+
role="tabpanel"
61+
aria-labelledby="projects-type-tab"
62+
>
5863
<div class="container">
5964
<app-create-project-type></app-create-project-type>
6065
<app-project-type-list></app-project-type-list>
6166
</div>
6267
</div>
68+
<div
69+
class="tab-pane fade mt-3"
70+
[ngClass]="{ 'show active': activeTab === 'projects' }"
71+
id="projects"
72+
role="tabpanel"
73+
aria-labelledby="projects-tab"
74+
>
75+
<div class="container mb-1">
76+
<app-create-project></app-create-project>
77+
<app-project-list></app-project-list>
78+
</div>
79+
</div>
6380
</div>
6481
</div>

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,25 @@ describe('ManagmentCustomerProjectsComponent', () => {
2727
component.activeTabs(true);
2828
setTimeout(() => {
2929
expect(component.areTabsActive).toBeTrue();
30+
expect(component.activeTab).toEqual('customer-information');
3031
}, 1);
3132
});
33+
34+
it('should show customer-information tab', () => {
35+
component.areTabsActive = true;
36+
component.showTab('customer-information');
37+
expect(component.activeTab).toEqual('customer-information');
38+
});
39+
40+
it('should show projects-type tab', () => {
41+
component.areTabsActive = true;
42+
component.showTab('projects-type');
43+
expect(component.activeTab).toEqual('projects-type');
44+
});
45+
46+
it('should show projects tab', () => {
47+
component.areTabsActive = true;
48+
component.showTab('projects');
49+
expect(component.activeTab).toEqual('projects');
50+
});
3251
});

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,18 @@ import { Component } from '@angular/core';
77
})
88
export class ManagementCustomerProjectsComponent {
99
areTabsActive: boolean;
10-
10+
activeTab: string;
1111
constructor() {}
1212

1313
activeTabs($areTabsActive: boolean) {
14-
setTimeout(() => this.areTabsActive = $areTabsActive, 1);
14+
setTimeout(() => {
15+
this.areTabsActive = $areTabsActive;
16+
this.activeTab = 'customer-information';
17+
}, 1);
18+
}
19+
20+
showTab(activeTab: string) {
21+
this.activeTab = activeTab;
1522
}
23+
1624
}

src/app/modules/time-entries/pages/time-entries.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe('TimeEntriesComponent', () => {
8383

8484
it('should call dataByMonth in ngOnInit()', async(() => {
8585
component.ngOnInit();
86-
expect(component.dataByMonth.length).toEqual(1);
86+
expect(component.dataByMonth.length).toEqual(0);
8787
}));
8888

8989
it('should open Delete Modal', () => {

0 commit comments

Comments
 (0)