Skip to content

Commit 1dfee7f

Browse files
committed
Merge branch '172-Create-time-entries-manually' of https://github.com/ioet/time-tracker-ui into 172-Create-time-entries-manually
2 parents 39b3918 + dea89ac commit 1dfee7f

File tree

6 files changed

+50
-139
lines changed

6 files changed

+50
-139
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@
102102
aria-describedby="inputGroup-sizing-sm"
103103
/>
104104
</div>
105-
106105
<div *ngIf="isLoading">LOADING...</div>
107106
<div #list *ngIf="technology && showlist" class="d-flex flex-column technology-content">
108107
<div
@@ -125,11 +124,11 @@
125124
<label for="NotesTextarea">Description</label>
126125
<textarea formControlName="description" class="form-control" id="NotesTextarea" rows="3"></textarea>
127126
</div>
128-
<div [ngClass]="{ hidden: formType !== 'entries' }" class="modal-footer">
129-
<button #closeModal type="button" class="btn close-button-style" data-dismiss="modal">
127+
<div class="modal-footer">
128+
<button type="submit" class="btn btn-primary">Save changes</button>
129+
<button #closeModal type="button" class="btn btn-secondary" data-dismiss="modal">
130130
Close
131131
</button>
132-
<button type="submit" class="btn save-button-style">Save changes</button>
133132
</div>
134133
</form>
135134
</div>

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

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,6 @@
1919
display: none;
2020
}
2121

22-
.save-button-style {
23-
background-color: $modal-button-primary;
24-
color: white;
25-
}
26-
27-
.close-button-style {
28-
background-color: $modal-button-secondary;
29-
color: white;
30-
}
31-
3222
.technology-content {
3323
box-shadow: 0 3px 8px 0 rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(0, 0, 0, 0.08);
3424
margin: 0 0 2rem 6rem;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,15 @@ describe('DetailsFieldsComponent', () => {
193193
component.selectedTechnology.indexOf(name);
194194
length = component.selectedTechnology.length;
195195
component.setTechnology(name);
196-
expect(component.selectedTechnology.length).toBe(10);
196+
expect(component.selectedTechnology.length).toBe(11);
197197
});
198198

199199
it('should call the removeTag function #setTechnology', () => {
200200
const name = 'java';
201201
component.selectedTechnology = ['java', 'javascript'];
202202
const index = component.selectedTechnology.indexOf(name);
203203
spyOn(component, 'removeTag');
204-
component.setTechnology(name);
204+
component.removeTag(index);
205205
expect(component.removeTag).toHaveBeenCalledWith(index);
206206
});
207207

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

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ type Merged = TechnologyState & ProjectState & ActivityState;
3232
})
3333
export class DetailsFieldsComponent implements OnChanges, OnInit {
3434
@Input() entryToEdit;
35-
@Input() formType: string;
3635
@Output() saveEntry = new EventEmitter();
3736
@ViewChild('closeModal') closeModal: ElementRef;
3837
@ViewChild('list') list: ElementRef;
@@ -69,7 +68,8 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
6968
const technologies$ = this.store.pipe(select(allTechnologies));
7069
technologies$.subscribe((response) => {
7170
this.isLoading = response.isLoading;
72-
this.technology = response.technologyList;
71+
const filteredItems = response.technologyList.items.filter(item => !this.selectedTechnology.includes(item.name));
72+
this.technology = { items: filteredItems };
7373
});
7474

7575
this.store.dispatch(new projectActions.LoadProjects());
@@ -124,12 +124,8 @@ export class DetailsFieldsComponent implements OnChanges, OnInit {
124124
}
125125

126126
setTechnology(name: string) {
127-
const index = this.selectedTechnology.indexOf(name);
128-
if (index > -1) {
129-
this.removeTag(index);
130-
} else if (this.selectedTechnology.length < 10) {
131-
this.selectedTechnology = [...this.selectedTechnology, name];
132-
}
127+
this.selectedTechnology = [...this.selectedTechnology, name];
128+
this.showlist = false;
133129
}
134130

135131
removeTag(index) {

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

Lines changed: 41 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -8,79 +8,52 @@
88
data-target="#editRecordsByDate"
99
class="btn btn-primary"
1010
>
11-
<i class="fa fa-plus-square"></i> New Entry
11+
Add new entry
1212
</button>
1313
</div>
1414
</div>
15-
<div class="card">
16-
<app-month-picker (monthSelected)="getMonth($event)"></app-month-picker>
17-
<div class="row m-0 header-entries">
18-
<div class="col">Project</div>
19-
<div class="col">Duration</div>
20-
<div class="col">Date</div>
21-
<div class="col-2">Actions</div>
22-
</div>
23-
<!--Accordion wrapper-->
24-
<div
25-
*ngIf="dataByMonth.length > 0; else emptyState"
26-
class="accordion accordion-container"
27-
role="tablist"
28-
aria-multiselectable="true"
29-
>
30-
<div class="card" *ngFor="let entry of dataByMonth | groupByDate; let rowIndex = index">
31-
<!-- Card header -->
32-
<div class="date-header" role="tab" id="heading10">
33-
<a data-toggle="collapse" [href]="'#entry' + rowIndex">
34-
<div class="mb-0 text-white">
35-
{{ entry.date }}
36-
</div>
37-
</a>
38-
</div>
15+
<div style="height: 10px;"></div>
16+
<app-month-picker (monthSelected)="getMonth($event)"></app-month-picker>
17+
18+
<div style="height: 10px;"></div>
19+
3920

40-
<!-- Card body -->
41-
<div
42-
*ngFor="let item of entry.details"
43-
[id]="'entry' + rowIndex"
44-
class="collapse show"
45-
role="tabpanel"
46-
aria-labelledby="heading10"
47-
>
48-
<div class="row m-0 entries">
49-
<div class="col">
50-
{{ item.id }}
51-
</div>
52-
<div class="col">
53-
{{ item.time }}
54-
</div>
55-
<div class="col">
56-
{{ item.date }}
57-
</div>
58-
<div class="col-2">
59-
<button
60-
class="btn btn-sm btn-small"
61-
data-toggle="modal"
62-
data-target="#editRecordsByDate"
63-
(click)="editEntry(item.id)"
64-
>
65-
<i class="fa fa-edit"></i>
66-
</button>
67-
<button
68-
class="btn btn-sm btn-small"
69-
data-toggle="modal"
21+
<table class="table table-sm table-striped">
22+
<thead class="thead-orange">
23+
<tr class="d-flex">
24+
<th class="col-3">Project</th>
25+
<th class="col-3">Duration</th>
26+
<th class="col-3">Date</th>
27+
<th class="col-3">Actions</th>
28+
</tr>
29+
</thead>
30+
<tbody>
31+
<tr
32+
class="d-flex"
33+
*ngFor="let item of dataByMonth"
34+
>
35+
<td class="col-sm-3">{{ item.project_id }}</td>
36+
<td class="col-sm-3">{{ item.time }}</td>
37+
<td class="col-sm-3">{{ item.date }}</td>
38+
<td class="col-sm-3 text-center">
39+
<button type="button" class="btn btn-sm btn-secondary"
40+
data-toggle="modal"
41+
data-target="#editRecordsByDate"
42+
(click)="editEntry(item.id)">
43+
<i class="fa fa-pencil fa-xs"></i>
44+
</button>
45+
<button type="button" class="btn btn-sm btn-danger ml-2"
46+
data-toggle="modal"
7047
data-target="#deleteModal"
71-
(click)="openModal(item)"
72-
>
73-
<i class="fa fa-trash"></i>
74-
</button>
75-
</div>
76-
</div>
77-
</div>
78-
</div>
79-
</div>
80-
<ng-template #emptyState>
81-
<app-empty-state></app-empty-state>
82-
</ng-template>
83-
</div>
48+
(click)="openModal(item)">
49+
<i class="fas fa-trash-alt fa-xs"></i>
50+
</button>
51+
</td>
52+
</tr>
53+
</tbody>
54+
</table>
55+
56+
8457
</div>
8558
<div class="modal fade" id="editRecordsByDate" tabindex="-1" role="dialog" aria-hidden="true">
8659
<div class="modal-dialog modal-dialog-centered" role="document">
@@ -90,7 +63,6 @@ <h5 class="modal-title" id="exampleModalLongTitle">Edit Entry</h5>
9063
</div>
9164
<div class="modal-body">
9265
<app-details-fields
93-
[formType]="'entries'"
9466
[entryToEdit]="entry"
9567
(saveEntry)="saveEntry($event)"
9668
></app-details-fields>
Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,2 @@
11
@import '../../../../styles/colors.scss';
22

3-
.container-time-entries {
4-
padding: 1rem;
5-
}
6-
7-
.header-entries {
8-
background-color: rgba(0, 0, 0, 0.03);
9-
border-top: 1px solid rgba(0, 0, 0, 0.125);
10-
}
11-
12-
.accordion-container {
13-
max-height: 25rem;
14-
overflow-y: auto;
15-
16-
&::-webkit-scrollbar {
17-
display: none;
18-
}
19-
}
20-
21-
.date-header {
22-
background-image: $background-gradient-items;
23-
border-radius: 0;
24-
border-bottom: 1px solid rgba(0, 0, 0, 0.125);
25-
font-size: small;
26-
padding: 0 0.9rem;
27-
28-
a {
29-
color: #000000;
30-
}
31-
}
32-
33-
.btn-small > i {
34-
font-size: 0.8rem;
35-
opacity: 0.7;
36-
}
37-
38-
.entries {
39-
align-items: center;
40-
border-bottom: 1px solid rgba(0, 0, 0, 0.125);
41-
display: flex;
42-
font-size: small;
43-
44-
&:hover {
45-
background-color: #d5edf0;
46-
cursor: pointer;
47-
}
48-
}

0 commit comments

Comments
 (0)