Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: TT-178 Make URI clickable when possible
  • Loading branch information
wobravo committed Mar 19, 2021
commit 18e26b154bc9668c6c0044e633fc00d3ad862f8a
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
datatable
[dtTrigger]="dtTrigger"
[dtOptions]="dtOptions"
*ngIf="reportDataSource$ | async as dataSource">
*ngIf="(reportDataSource$ | async) as dataSource">
<thead class="thead-blue">
<tr class="d-flex">
<th class="hidden-col">ID</th>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,19 +89,19 @@ describe('Reports Page', () => {
});

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

expect(component.openURLInNewTab(uriExpected)).toEqual('');
expect(component.openURLInNewTab(url)).toEqual('');
});

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

expect(component.isURL(param.url)).toEqual(param.expected_value);
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { formatDate } from '@angular/common';
import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild, NgModule } from '@angular/core';
import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild} from '@angular/core';
import { select, Store } from '@ngrx/store';
import { DataTableDirective } from 'angular-datatables';
import * as moment from 'moment';
Expand Down Expand Up @@ -30,7 +30,9 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
exportOptions: {
format: {
body: (data, row, column, node) => {
return column === 3 ? moment.duration(data).asHours().toFixed(4).slice(0, -1) : data;
return column === 3 ?
moment.duration(data).asHours().toFixed(4).slice(0, -1) :
data;
},
},
},
Expand All @@ -42,7 +44,9 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
exportOptions: {
format: {
body: (data, row, column, node) => {
return column === 3 ? moment.duration(data).asHours().toFixed(4).slice(0, -1) : data;
return column === 3 ?
moment.duration(data).asHours().toFixed(4).slice(0, -1) :
data;
},
},
},
Expand Down Expand Up @@ -92,6 +96,6 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn

isURL(uri: string) {
const regex = new RegExp('http*', 'g');
return regex.test(uri) ? true : false;
return regex.test(uri);
}
}