Skip to content

Commit 026006b

Browse files
committed
fix: #145 use details-fields component on Time Clock page
1 parent 936b1c9 commit 026006b

File tree

8 files changed

+36
-61
lines changed

8 files changed

+36
-61
lines changed

src/app/modules/shared/components/details-fields/details-fields.component.html

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,9 @@
2424
<div class="input-group-prepend">
2525
<span class="input-group-text span-width" id="inputGroup-sizing-sm">Activity</span>
2626
</div>
27-
<input
28-
formControlName="activity"
29-
type="text"
30-
class="form-control"
31-
aria-label="Small"
32-
aria-describedby="inputGroup-sizing-sm"
33-
/>
27+
<select id="activitiesSelect" class="form-control">
28+
<option *ngFor="let activity of activities">{{ activity.name }}</option>
29+
</select>
3430
</div>
3531
<div class="input-group input-group-sm mb-3">
3632
<div class="input-group-prepend">
@@ -76,7 +72,7 @@
7672
</div>
7773
</div>
7874

79-
<div class="form-group">
75+
<div class="form-group text-left">
8076
<label for="NotesTextarea">Notes</label>
8177
<textarea formControlName="comments" class="form-control" id="NotesTextarea" rows="3"></textarea>
8278
</div>

src/app/modules/shared/components/details-fields/details-fields.component.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ describe('DetailsFieldsComponent', () => {
2727
technologyList: { items: [{ name: 'java' }] },
2828
isLoading: false,
2929
},
30+
activities: {
31+
data: [{ id: 'fc5fab41-a21e-4155-9d05-511b956ebd05', tenant_id: 'ioet', deleted: null, name: 'Training 2' }],
32+
isLoading: false,
33+
message: 'Data fetch successfully!',
34+
activityIdToEdit: '',
35+
},
3036
};
3137

3238
const initialData = {

src/app/modules/shared/components/details-fields/details-fields.component.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ import { Store, select } from '@ngrx/store';
1414
import * as actions from '../../store/technology.actions';
1515

1616
import { allTechnologies } from '../../store/technology.selectors';
17-
import { Technology, Project } from '../../models';
17+
import { Technology, Project, Activity } from '../../models';
1818

1919
import { ProjectState } from '../../../project-management/store/project.reducer';
2020
import { TechnologyState } from '../../store/technology.reducers';
21+
import { LoadActivities, ActivityState, allActivities } from '../../../activities-management/store';
2122
import { allProjects } from '../../../project-management/store/project.selectors';
2223
import * as projectActions from '../../../project-management/store/project.actions';
2324

24-
type Merged = TechnologyState & ProjectState;
25+
type Merged = TechnologyState & ProjectState & ActivityState;
2526

2627
@Component({
2728
selector: 'app-details-fields',
@@ -39,6 +40,7 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
3940
selectedTechnology: string[] = [];
4041
isLoading = false;
4142
listProjects: Project[] = [];
43+
activities: Activity[] = [];
4244
keyword = 'name';
4345
showlist: boolean;
4446

@@ -68,6 +70,12 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
6870
projects$.subscribe((response) => {
6971
this.listProjects = response.projectList;
7072
});
73+
74+
this.store.dispatch(new LoadActivities());
75+
const activities$ = this.store.pipe(select(allActivities));
76+
activities$.subscribe((response) => {
77+
this.activities = response;
78+
});
7179
}
7280

7381
ngOnChanges(): void {

src/app/modules/time-clock/components/project-list-hover/project-list-hover.component.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@
2323

2424
.autocomplete::ng-deep .autocomplete-container {
2525
border: 1px solid #ced4da;
26-
border-radius: 0.25rem;
26+
border-radius: 0 0.25rem 0.25rem 0;
2727
box-shadow: none;
28+
height: 2rem;
2829

2930
.input-container {
3031
height: 100%;

src/app/modules/time-clock/pages/time-clock.component.html

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</p>
1616
<h6 class="text-left"><strong>Totals</strong></h6>
1717
<hr />
18-
<div class="row">
18+
<div class="row pb-4">
1919
<div class="col-4">
2020
<h6>Current</h6>
2121
<h3>{{ hour | number: '2.0-2' }}:{{ minute | number: '2.0-2' }}:{{ seconds | number: '2.0-2' }}</h3>
@@ -29,33 +29,14 @@ <h6>Week</h6>
2929
<h3>14:00</h3>
3030
</div>
3131
</div>
32-
<div class="form-group row">
33-
<label for="activitiesSelect" class="col-sm-2 col-form-label text-center"><strong>Project</strong></label>
34-
<div class="col-sm-10">
35-
<app-project-list-hover (showFields)="setShowFields($event)"></app-project-list-hover>
32+
<div class="input-group input-group-sm mb-3 flex-nowrap">
33+
<div class="input-group-prepend">
34+
<span class="input-group-text span-width" id="inputGroup-sizing-sm">Project</span>
3635
</div>
36+
<app-project-list-hover class="w-100" (showFields)="setShowFields($event)"></app-project-list-hover>
3737
</div>
3838
<form *ngIf="!isClockIn || showFields">
39-
<div class="form-group row">
40-
<label for="activitiesSelect" class="col-sm-2 col-form-label text-center"><strong>Activity</strong></label>
41-
<div class="col-sm-10">
42-
<select id="activitiesSelect" class="form-control">
43-
<option *ngFor="let activity of activities">{{ activity.name }}</option>
44-
</select>
45-
</div>
46-
</div>
47-
<div class="form-group row">
48-
<label for="inputJiraTicket" class="col-sm-2 col-form-label text-center"><strong>Jira Ticket</strong></label>
49-
<div class="col-sm-10">
50-
<input type="text" class="form-control" />
51-
</div>
52-
</div>
53-
<div class="form-group row">
54-
<label for="inputTechnology" class="col-sm-2 col-form-label text-center"><strong>Technology</strong></label>
55-
<div class="col-sm-10">
56-
<input #data type="text" (keyup)="enterTechnology(data.value)" class="form-control" />
57-
</div>
58-
</div>
39+
<app-details-fields></app-details-fields>
5940
</form>
6041
<hr />
6142
<div class="container">

src/app/modules/time-clock/pages/time-clock.component.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,9 @@
1414
.text-clock-in-color {
1515
color: $modal-button-secondary;
1616
}
17+
18+
.span-width {
19+
width: 6rem;
20+
background-image: $background-pantone;
21+
color: white;
22+
}

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { LoadActivities } from '../../activities-management/store/activity-management.actions';
21
import { async, ComponentFixture, TestBed, inject } from '@angular/core/testing';
32
import { HttpClientTestingModule } from '@angular/common/http/testing';
43
import { provideMockStore, MockStore } from '@ngrx/store/testing';
@@ -50,14 +49,6 @@ describe('TimeClockComponent', () => {
5049
expect(component).toBeTruthy();
5150
});
5251

53-
it('onInit, LoadActivities action is dispatched', () => {
54-
spyOn(store, 'dispatch');
55-
56-
component.ngOnInit();
57-
58-
expect(store.dispatch).toHaveBeenCalledWith(new LoadActivities());
59-
});
60-
6152
it('Service injected via inject(...) and TestBed.get(...) should be the same instance', inject(
6253
[ProjectService],
6354
(injectService: ProjectService) => {

src/app/modules/time-clock/pages/time-clock.component.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
import { Component, OnInit } from '@angular/core';
2-
import { Store, select } from '@ngrx/store';
3-
4-
import { LoadActivities, ActivityState, allActivities } from '../../activities-management/store/';
5-
import { Activity } from 'src/app/modules/shared/models';
6-
72

83
@Component({
94
selector: 'app-time-clock',
@@ -30,9 +25,7 @@ export class TimeClockComponent implements OnInit {
3025
isClockInEnable = false;
3126
isHidenForm = true;
3227

33-
activities: Activity[] = [];
34-
35-
constructor(private store: Store<ActivityState>) {
28+
constructor() {
3629
this.isClockIn = true;
3730
this.isEnterTechnology = false;
3831
this.hourCounterRealTime = 0;
@@ -43,13 +36,7 @@ export class TimeClockComponent implements OnInit {
4336
this.seconds = 0;
4437
}
4538

46-
ngOnInit() {
47-
this.store.dispatch(new LoadActivities());
48-
const activities$ = this.store.pipe(select(allActivities));
49-
activities$.subscribe((response) => {
50-
this.activities = response;
51-
});
52-
}
39+
ngOnInit() {}
5340

5441
employeClockIn(): boolean {
5542
this.isClockInEnable = true;
@@ -133,5 +120,4 @@ export class TimeClockComponent implements OnInit {
133120
this.execOnlyOneTimeCounter = false;
134121
this.isClockInEnable = false;
135122
}
136-
137123
}

0 commit comments

Comments
 (0)