Skip to content

Commit 5a54578

Browse files
author
Edgar Guaman
committed
fix: TT-336 Fix format Duration column
1 parent 13fd98a commit 5a54578

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/app/modules/reports/components/time-entries-table/time-entries-table.component.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { formatDate } from '@angular/common';
22
import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild} from '@angular/core';
33
import { select, Store } from '@ngrx/store';
44
import { DataTableDirective } from 'angular-datatables';
5+
import * as moment from 'moment';
56
import { Observable, Subject, Subscription } from 'rxjs';
67
import { Entry } from 'src/app/modules/shared/models';
78
import { DataSource } from 'src/app/modules/shared/models/data-source.model';
@@ -28,11 +29,29 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
2829
},
2930
{
3031
extend: 'excel',
32+
exportOptions: {
33+
format: {
34+
body: (data, row, column, node) => {
35+
return column === 3 ?
36+
moment.duration(data).asHours().toFixed(4).slice(0, -1) :
37+
data;
38+
},
39+
}
40+
},
3141
text: 'Excel',
3242
filename: `time-entries-${formatDate(new Date(), 'MM_dd_yyyy-HH_mm', 'en')}`
3343
},
3444
{
3545
extend: 'csv',
46+
exportOptions: {
47+
format: {
48+
body: (data, row, column, node) => {
49+
return column === 3 ?
50+
moment.duration(data).asHours().toFixed(4).slice(0, -1) :
51+
data;
52+
},
53+
}
54+
},
3655
text: 'CSV',
3756
filename: `time-entries-${formatDate(new Date(), 'MM_dd_yyyy-HH_mm', 'en')}`
3857
},

0 commit comments

Comments
 (0)