Skip to content

Commit 18e26b1

Browse files
committed
fix: TT-178 Make URI clickable when possible
1 parent da18ee9 commit 18e26b1

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
datatable
55
[dtTrigger]="dtTrigger"
66
[dtOptions]="dtOptions"
7-
*ngIf="reportDataSource$ | async as dataSource">
7+
*ngIf="(reportDataSource$ | async) as dataSource">
88
<thead class="thead-blue">
99
<tr class="d-flex">
1010
<th class="hidden-col">ID</th>

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,19 +89,19 @@ describe('Reports Page', () => {
8989
});
9090

9191
it('when the uri starts without http or https it should return false and not navigate or open a new tab', () => {
92-
const uriExpected = timeEntry.uri;
92+
const url = timeEntry.uri;
9393
spyOn(component, 'isURL').and.returnValue(false);
9494

95-
expect(component.openURLInNewTab(uriExpected)).toEqual('');
95+
expect(component.openURLInNewTab(url)).toEqual('');
9696
});
9797

9898
const params = [
99-
{url: 'http://example.com', expected_value: true, with: 'with'},
100-
{url: 'https://example.com', expected_value: true, with: 'with'},
101-
{url: 'no-url-example', expected_value: false, with: 'without'}
99+
{url: 'http://example.com', expected_value: true},
100+
{url: 'https://example.com', expected_value: true},
101+
{url: 'no-url-example', expected_value: false}
102102
];
103103
params.map((param) => {
104-
it(`when the url starts ${param.with} http or https it should return ${param.expected_value}`, () => {
104+
it(`Given the url ${param.url}, the method isURL should return ${param.expected_value}`, () => {
105105

106106
expect(component.isURL(param.url)).toEqual(param.expected_value);
107107
});

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { formatDate } from '@angular/common';
2-
import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild, NgModule } from '@angular/core';
2+
import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild} from '@angular/core';
33
import { select, Store } from '@ngrx/store';
44
import { DataTableDirective } from 'angular-datatables';
55
import * as moment from 'moment';
@@ -30,7 +30,9 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
3030
exportOptions: {
3131
format: {
3232
body: (data, row, column, node) => {
33-
return column === 3 ? moment.duration(data).asHours().toFixed(4).slice(0, -1) : data;
33+
return column === 3 ?
34+
moment.duration(data).asHours().toFixed(4).slice(0, -1) :
35+
data;
3436
},
3537
},
3638
},
@@ -42,7 +44,9 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
4244
exportOptions: {
4345
format: {
4446
body: (data, row, column, node) => {
45-
return column === 3 ? moment.duration(data).asHours().toFixed(4).slice(0, -1) : data;
47+
return column === 3 ?
48+
moment.duration(data).asHours().toFixed(4).slice(0, -1) :
49+
data;
4650
},
4751
},
4852
},
@@ -92,6 +96,6 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
9296

9397
isURL(uri: string) {
9498
const regex = new RegExp('http*', 'g');
95-
return regex.test(uri) ? true : false;
99+
return regex.test(uri);
96100
}
97101
}

0 commit comments

Comments
 (0)