Skip to content

Commit 9711971

Browse files
wobravoscastillo-jp
authored andcommitted
fix: TT-178 Make URI clickable when possible
1 parent 597c66e commit 9711971

File tree

6 files changed

+43
-7
lines changed

6 files changed

+43
-7
lines changed

package-lock.json

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</thead>
2626
<app-loading-bar *ngIf="dataSource.isLoading"></app-loading-bar>
2727
<tbody *ngIf="!dataSource.isLoading">
28-
<tr class="d-flex" *ngFor="let entry of dataSource.data">
28+
<tr class="d-flex" *ngFor="let entry of dataSource.data" _nghost-c0 = "" >
2929
<td class="hidden-col">{{ entry.id }}</td>
3030
<td class="col md-col">{{ entry.owner_email }}</td>
3131
<td class="col sm-col">
@@ -41,7 +41,7 @@
4141
<td class="col md-col">{{ entry.customer_name }}</td>
4242
<td class="hidden-col">{{ entry.customer_id }}</td>
4343
<td class="col md-col">{{ entry.activity_name }}</td>
44-
<td class="col lg-col">{{ entry.uri }}</td>
44+
<td class="col lg-col" id="uri"><a (click)="isLinkExternal(entry.uri)" [ngStyle]="{'cursor':'pointer','color':entry.uri === ('http' || 'https') ? 'black' : 'blue' }">{{ entry.uri }}</a></td>
4545
<td class="col lg-col">{{ entry.description }}</td>
4646
<td class="col lg-col">{{ entry.technologies }}</td>
4747
</tr>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@
3131
overflow-x: scroll;
3232
width: 100%;
3333
display: grid;
34-
}
34+
}

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { MockStore, provideMockStore } from '@ngrx/store/testing';
33
import { Entry } from 'src/app/modules/shared/models';
44
import { SubstractDatePipe } from 'src/app/modules/shared/pipes/substract-date/substract-date.pipe';
55
import { getReportDataSource } from 'src/app/modules/time-clock/store/entry.selectors';
6-
import { EntryState } from '../../../time-clock/store/entry.reducer';
6+
import { entryReducer, EntryState } from '../../../time-clock/store/entry.reducer';
77
import { TimeEntriesTableComponent } from './time-entries-table.component';
88

99
describe('Reports Page', () => {
@@ -76,6 +76,15 @@ describe('Reports Page', () => {
7676
expect(component.dtTrigger.next).toHaveBeenCalled();
7777
});
7878

79+
fit('when the variable starts with http or https it should be url', () => {
80+
fixture.detectChanges();
81+
const initialUri = ('http' || 'https');
82+
const entryUri = fixture.debugElement.nativeElement.querySelector('[id=uri]');
83+
console.log(entryUri);
84+
85+
expect(entryUri.id).toEqual(initialUri);
86+
});
87+
7988
afterEach(() => {
8089
fixture.destroy();
8190
});

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { formatDate } from '@angular/common';
2-
import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
2+
import { AfterViewInit, Component, OnDestroy, OnInit, ViewChild, NgModule } from '@angular/core';
33
import { select, Store } from '@ngrx/store';
44
import { DataTableDirective } from 'angular-datatables';
55
import * as moment from 'moment';
6+
import { getMaxListeners } from 'process';
67
import { Observable, Subject } from 'rxjs';
78
import { Entry } from 'src/app/modules/shared/models';
89
import { DataSource } from 'src/app/modules/shared/models/data-source.model';
910

10-
import { EntryState } from '../../../time-clock/store/entry.reducer';
11+
import { entryReducer, EntryState } from '../../../time-clock/store/entry.reducer';
1112
import { getReportDataSource } from '../../../time-clock/store/entry.selectors';
1213

1314
@Component({
@@ -91,4 +92,10 @@ export class TimeEntriesTableComponent implements OnInit, OnDestroy, AfterViewIn
9192
this.dtTrigger.next();
9293
}
9394
}
95+
96+
isLinkExternal(uri: string) {
97+
const isValidUri = uri.startsWith('http' || 'https');
98+
return isValidUri ? window.open(uri, '_blank') : '';
99+
}
100+
94101
}

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,10 @@ export class TimeEntriesComponent implements OnInit, OnDestroy {
160160
this.selectedMonthAsText = moment().month(event.monthIndex).format('MMMM');
161161
this.store.dispatch(new entryActions.LoadEntries(this.selectedMonth, this.selectedYear));
162162
}
163+
163164
openModal(item: any) {
164165
this.idToDelete = item.id;
165166
this.message = `Are you sure you want to delete ${item.activity_name}?`;
166167
this.showModal = true;
167168
}
168-
}
169+
}

0 commit comments

Comments
 (0)