Skip to content

Commit 63c9206

Browse files
authored
Merge pull request #995 from microting/feat/calendar-task-list-startdate
feat(calendar): add Start date column to task list
2 parents f94e802 + 6c38b90 commit 63c9206

3 files changed

Lines changed: 36 additions & 1 deletion

File tree

eform-client/src/app/plugins/modules/backend-configuration-pn/modules/calendar-task-list/components/calendar-task-list-page/calendar-task-list-page.component.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export class CalendarTaskListPageComponent implements OnInit {
174174

175175
exportCsv() {
176176
const headers = ['Id', 'Property', 'Board', 'Report headline', 'Task name', 'eForm',
177-
'Assigned to', 'Tags', 'Repeat', 'Active', 'Compliance']
177+
'Assigned to', 'Tags', 'Start date', 'Repeat', 'Active', 'Compliance']
178178
.map(h => this.translate.instant(h));
179179
const rows = this.tasks.map(t => [
180180
t.id,
@@ -186,6 +186,7 @@ export class CalendarTaskListPageComponent implements OnInit {
186186
this.eforms.find(e => e.id === t.eformId)?.label ?? '',
187187
(t.workerNames ?? []).join(', '),
188188
(t.tags ?? []).join(', '),
189+
this.formatStartDate(t.taskDate),
189190
this.repeatTextForCsv(t),
190191
this.translate.instant(t.status ? 'Yes' : 'No'),
191192
this.translate.instant(t.complianceEnabled ? 'Yes' : 'No'),
@@ -206,4 +207,13 @@ export class CalendarTaskListPageComponent implements OnInit {
206207
private repeatTextForCsv(t: CalendarTaskModel): string {
207208
return formatRepeatText(this.repeatService, this.translate, t);
208209
}
210+
211+
// "yyyy-MM-dd" -> "dd-MM-yyyy" (split-and-reorder; no timezone-sensitive Date parsing).
212+
private formatStartDate(value: string): string {
213+
if (!value) {
214+
return '';
215+
}
216+
const [y, m, d] = value.split('-');
217+
return d && m && y ? `${d}-${m}-${y}` : '';
218+
}
209219
}

eform-client/src/app/plugins/modules/backend-configuration-pn/modules/calendar-task-list/components/calendar-task-list-table/calendar-task-list-table.component.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,17 @@ describe('CalendarTaskListTableComponent', () => {
120120
});
121121
});
122122

123+
describe('formatStartDate', () => {
124+
it('reorders "yyyy-MM-dd" to "dd-MM-yyyy"', () => {
125+
expect(component.formatStartDate('2026-06-09')).toBe('09-06-2026');
126+
});
127+
128+
it('returns empty string for empty or malformed input', () => {
129+
expect(component.formatStartDate('')).toBe('');
130+
expect(component.formatStartDate(undefined as unknown as string)).toBe('');
131+
});
132+
});
133+
123134
describe('onEdit', () => {
124135
it('emits editTask on row click', () => {
125136
const task = makeTask({id: 42});

eform-client/src/app/plugins/modules/backend-configuration-pn/modules/calendar-task-list/components/calendar-task-list-table/calendar-task-list-table.component.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,16 @@ export class CalendarTaskListTableComponent {
4242
return formatRepeatText(this.repeatService, this.translate, task);
4343
}
4444

45+
// Converts the row's `taskDate` ("yyyy-MM-dd") to "dd-MM-yyyy" by splitting
46+
// and reordering (no `new Date()` parsing, which could shift across timezones).
47+
formatStartDate(value: string): string {
48+
if (!value) {
49+
return '';
50+
}
51+
const [y, m, d] = value.split('-');
52+
return d && m && y ? `${d}-${m}-${y}` : '';
53+
}
54+
4555
columns: MtxGridColumn[] = [
4656
{
4757
field: 'id', header: this.translate.stream('Id'), sortable: true, sortProp: {id: 'Id'},
@@ -70,6 +80,10 @@ export class CalendarTaskListTableComponent {
7080
field: 'tags', header: this.translate.stream('Tags'),
7181
formatter: (t: CalendarTaskModel) => (t.tags ?? []).join(', '),
7282
},
83+
{
84+
field: 'taskDate', header: this.translate.stream('Start date'), sortable: true,
85+
formatter: (t: CalendarTaskModel) => this.formatStartDate(t.taskDate),
86+
},
7387
{
7488
field: 'repeat', header: this.translate.stream('Repeat'),
7589
formatter: (t: CalendarTaskModel) => this.repeatText(t),

0 commit comments

Comments
 (0)