From 43579df6590fd4b34831b131d236c1b4c74cf653 Mon Sep 17 00:00:00 2001
From: Jean Fernandez <55406257+jean-the-coder@users.noreply.github.com>
Date: Thu, 7 Mar 2024 18:17:40 -0500
Subject: [PATCH] Fix URL encoding issue for links (#446)
* Use [routerLink] with array instead of routerLink with interpolated string
* switch navigateByUrl to navigate with array format
* add some quick tests
---
.../common/table/table.component.html | 2 +-
.../common/table/table.component.spec.ts | 28 ++++++++++++++++++-
.../fhir-card/common/table/table.stories.ts | 18 ++++++------
.../allergy-intolerance.component.html | 2 +-
.../diagnostic-report.component.html | 2 +-
.../document-reference.component.html | 2 +-
.../encounter/encounter.component.html | 2 +-
.../immunization/immunization.component.html | 2 +-
.../location/location.component.html | 2 +-
.../resources/media/media.component.html | 2 +-
.../medication-request.component.html | 2 +-
.../medication/medication.component.html | 2 +-
.../observation/observation.component.html | 2 +-
.../organization/organization.component.html | 2 +-
.../practitioner/practitioner.component.html | 2 +-
.../procedure/procedure.component.html | 2 +-
.../fhir-datatable.component.ts | 2 +-
.../medical-sources-connected.component.html | 2 +-
.../report-labs-observation.component.html | 4 +--
...t-medical-history-condition.component.html | 8 +++---
...tory-explanation-of-benefit.component.html | 4 +--
...ical-history-timeline-panel.component.html | 8 +++---
.../pages/dashboard/dashboard.component.ts | 2 +-
.../app/pages/explore/explore.component.ts | 2 +-
.../resource-detail.component.html | 2 +-
.../source-detail.component.html | 2 +-
26 files changed, 67 insertions(+), 43 deletions(-)
diff --git a/frontend/src/app/components/fhir-card/common/table/table.component.html b/frontend/src/app/components/fhir-card/common/table/table.component.html
index edd749d8..751d44bc 100644
--- a/frontend/src/app/components/fhir-card/common/table/table.component.html
+++ b/frontend/src/app/components/fhir-card/common/table/table.component.html
@@ -23,7 +23,7 @@
- {{rowItem.data.display}}
+ {{rowItem.data.display}}
{{rowItem.data}}
diff --git a/frontend/src/app/components/fhir-card/common/table/table.component.spec.ts b/frontend/src/app/components/fhir-card/common/table/table.component.spec.ts
index 6a800b9b..dcbf1da2 100644
--- a/frontend/src/app/components/fhir-card/common/table/table.component.spec.ts
+++ b/frontend/src/app/components/fhir-card/common/table/table.component.spec.ts
@@ -1,6 +1,9 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { TableComponent } from './table.component';
+import { TableRowItemDataType } from './table-row-item';
+import { RouterTestingModule } from '@angular/router/testing';
+import { FastenDisplayModel } from 'src/lib/models/fasten/fasten-display-model';
describe('TableComponent', () => {
let component: TableComponent;
@@ -8,16 +11,39 @@ describe('TableComponent', () => {
beforeEach(async () => {
await TestBed.configureTestingModule({
- imports: [ TableComponent ]
+ imports: [ TableComponent, RouterTestingModule ]
})
.compileComponents();
fixture = TestBed.createComponent(TableComponent);
component = fixture.componentInstance;
+ component.displayModel = {
+ source_id: '123-456-789=',
+ } as FastenDisplayModel,
+ component.tableData = [
+ {
+ enabled: true,
+ label: 'hello',
+ data_type: TableRowItemDataType.Reference,
+ data: {
+ reference: 'aHR0cHM6Ly93d3cubWVyY3kubmV0L3NpdGVzL2RlZmF1bHQvZmlsZXMvZG9jdG9yX2ltYWdlcy9kZXNrdG9wLzE2NTk4ODYwNTktbS5qcGc=',
+ display: 'binary'
+ }
+ }
+ ]
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
+
+ it('encodes urls properly', () => {
+ spyOn(console, 'log').and.callThrough();
+ const link = fixture.debugElement.nativeElement.querySelector('a');
+ console.log(link);
+ expect(link.href).toContain(
+ '/explore/123-456-789%3D/resource/aHR0cHM6Ly93d3cubWVyY3kubmV0L3NpdGVzL2RlZmF1bHQvZmlsZXMvZG9jdG9yX2ltYWdlcy9kZXNrdG9wLzE2NTk4ODYwNTktbS5qcGc%3D'
+ );
+ });
});
diff --git a/frontend/src/app/components/fhir-card/common/table/table.stories.ts b/frontend/src/app/components/fhir-card/common/table/table.stories.ts
index 7a616fff..4834b2a0 100644
--- a/frontend/src/app/components/fhir-card/common/table/table.stories.ts
+++ b/frontend/src/app/components/fhir-card/common/table/table.stories.ts
@@ -1,19 +1,17 @@
-import type { Meta, StoryObj } from '@storybook/angular';
+import { moduleMetadata, type Meta, type StoryObj } from '@storybook/angular';
import {TableComponent} from "./table.component";
import {TableRowItem} from "./table-row-item";
import {FastenDisplayModel} from "../../../../../lib/models/fasten/fasten-display-model";
+import { RouterTestingModule } from '@angular/router/testing';
// More on how to set up stories at: https://storybook.js.org/docs/angular/writing-stories/introduction
const meta: Meta = {
title: 'Fhir Card/Common/Table',
component: TableComponent,
decorators: [
- // moduleMetadata({
- // imports: [AppModule]
- // })
- // applicationConfig({
- // providers: [importProvidersFrom(AppModule)],
- // }),
+ moduleMetadata({
+ imports: [RouterTestingModule]
+ })
],
tags: ['autodocs'],
render: (args: TableComponent) => ({
@@ -73,7 +71,7 @@ export const Ref: Story = {
label: 'hello',
data_type: 'reference',
data: {
- reference: 'Patient/123',
+ reference: 'Patient/123=',
display: 'John Doe'
}
},
@@ -82,8 +80,8 @@ export const Ref: Story = {
label: 'hello',
data_type: 'reference',
data: {
- reference: 'Patient/123',
- display: 'John Doe'
+ reference: 'aHR0cHM6Ly93d3cubWVyY3kubmV0L3NpdGVzL2RlZmF1bHQvZmlsZXMvZG9jdG9yX2ltYWdlcy9kZXNrdG9wLzE2NTk4ODYwNTktbS5qcGc=',
+ display: 'binary'
}
}
] as TableRowItem[]
diff --git a/frontend/src/app/components/fhir-card/resources/allergy-intolerance/allergy-intolerance.component.html b/frontend/src/app/components/fhir-card/resources/allergy-intolerance/allergy-intolerance.component.html
index 5dad97f0..95c69021 100644
--- a/frontend/src/app/components/fhir-card/resources/allergy-intolerance/allergy-intolerance.component.html
+++ b/frontend/src/app/components/fhir-card/resources/allergy-intolerance/allergy-intolerance.component.html
@@ -11,6 +11,6 @@
diff --git a/frontend/src/app/components/fhir-card/resources/diagnostic-report/diagnostic-report.component.html b/frontend/src/app/components/fhir-card/resources/diagnostic-report/diagnostic-report.component.html
index c1c7e3cf..676939e6 100644
--- a/frontend/src/app/components/fhir-card/resources/diagnostic-report/diagnostic-report.component.html
+++ b/frontend/src/app/components/fhir-card/resources/diagnostic-report/diagnostic-report.component.html
@@ -34,7 +34,7 @@
diff --git a/frontend/src/app/components/fhir-card/resources/document-reference/document-reference.component.html b/frontend/src/app/components/fhir-card/resources/document-reference/document-reference.component.html
index b3f1d1bd..c16f5993 100644
--- a/frontend/src/app/components/fhir-card/resources/document-reference/document-reference.component.html
+++ b/frontend/src/app/components/fhir-card/resources/document-reference/document-reference.component.html
@@ -34,6 +34,6 @@
diff --git a/frontend/src/app/components/fhir-card/resources/encounter/encounter.component.html b/frontend/src/app/components/fhir-card/resources/encounter/encounter.component.html
index ef29c725..d1d38068 100644
--- a/frontend/src/app/components/fhir-card/resources/encounter/encounter.component.html
+++ b/frontend/src/app/components/fhir-card/resources/encounter/encounter.component.html
@@ -14,6 +14,6 @@
diff --git a/frontend/src/app/components/fhir-card/resources/immunization/immunization.component.html b/frontend/src/app/components/fhir-card/resources/immunization/immunization.component.html
index a2e4b253..78765ea0 100644
--- a/frontend/src/app/components/fhir-card/resources/immunization/immunization.component.html
+++ b/frontend/src/app/components/fhir-card/resources/immunization/immunization.component.html
@@ -16,6 +16,6 @@
diff --git a/frontend/src/app/components/fhir-card/resources/location/location.component.html b/frontend/src/app/components/fhir-card/resources/location/location.component.html
index 2668b35e..ba86620a 100644
--- a/frontend/src/app/components/fhir-card/resources/location/location.component.html
+++ b/frontend/src/app/components/fhir-card/resources/location/location.component.html
@@ -15,6 +15,6 @@
diff --git a/frontend/src/app/components/fhir-card/resources/media/media.component.html b/frontend/src/app/components/fhir-card/resources/media/media.component.html
index e9dab111..a5154789 100644
--- a/frontend/src/app/components/fhir-card/resources/media/media.component.html
+++ b/frontend/src/app/components/fhir-card/resources/media/media.component.html
@@ -20,6 +20,6 @@
diff --git a/frontend/src/app/components/fhir-card/resources/medication-request/medication-request.component.html b/frontend/src/app/components/fhir-card/resources/medication-request/medication-request.component.html
index f792aca5..d418f52a 100644
--- a/frontend/src/app/components/fhir-card/resources/medication-request/medication-request.component.html
+++ b/frontend/src/app/components/fhir-card/resources/medication-request/medication-request.component.html
@@ -16,7 +16,7 @@
diff --git a/frontend/src/app/components/fhir-card/resources/medication/medication.component.html b/frontend/src/app/components/fhir-card/resources/medication/medication.component.html
index 558bf8de..01628a28 100644
--- a/frontend/src/app/components/fhir-card/resources/medication/medication.component.html
+++ b/frontend/src/app/components/fhir-card/resources/medication/medication.component.html
@@ -16,7 +16,7 @@
diff --git a/frontend/src/app/components/fhir-card/resources/observation/observation.component.html b/frontend/src/app/components/fhir-card/resources/observation/observation.component.html
index 636f4efd..48f33fe3 100644
--- a/frontend/src/app/components/fhir-card/resources/observation/observation.component.html
+++ b/frontend/src/app/components/fhir-card/resources/observation/observation.component.html
@@ -23,6 +23,6 @@
>
diff --git a/frontend/src/app/components/fhir-card/resources/organization/organization.component.html b/frontend/src/app/components/fhir-card/resources/organization/organization.component.html
index 4790e0b3..5cc8f292 100644
--- a/frontend/src/app/components/fhir-card/resources/organization/organization.component.html
+++ b/frontend/src/app/components/fhir-card/resources/organization/organization.component.html
@@ -10,6 +10,6 @@
diff --git a/frontend/src/app/components/fhir-card/resources/practitioner/practitioner.component.html b/frontend/src/app/components/fhir-card/resources/practitioner/practitioner.component.html
index f5c5f06e..8a2192ea 100644
--- a/frontend/src/app/components/fhir-card/resources/practitioner/practitioner.component.html
+++ b/frontend/src/app/components/fhir-card/resources/practitioner/practitioner.component.html
@@ -14,6 +14,6 @@
diff --git a/frontend/src/app/components/fhir-card/resources/procedure/procedure.component.html b/frontend/src/app/components/fhir-card/resources/procedure/procedure.component.html
index 09d240c5..b292f0a3 100644
--- a/frontend/src/app/components/fhir-card/resources/procedure/procedure.component.html
+++ b/frontend/src/app/components/fhir-card/resources/procedure/procedure.component.html
@@ -16,7 +16,7 @@
diff --git a/frontend/src/app/components/fhir-datatable/fhir-datatable/fhir-datatable.component.ts b/frontend/src/app/components/fhir-datatable/fhir-datatable/fhir-datatable.component.ts
index 15383f41..0cfcc1cc 100644
--- a/frontend/src/app/components/fhir-datatable/fhir-datatable/fhir-datatable.component.ts
+++ b/frontend/src/app/components/fhir-datatable/fhir-datatable/fhir-datatable.component.ts
@@ -79,7 +79,7 @@ export class FhirDatatableComponent implements OnInit, OnChanges {
}
componentRef.instance.selectionChanged.subscribe((selected: FastenDisplayModel) => {
- this.router.navigateByUrl(`/explore/${selected?.source_id}/resource/${selected?.source_resource_id}`);
+ this.router.navigate(['/explore', selected?.source_id, 'resource', selected?.source_resource_id]);
})
this.knownResourceType = (componentType != DatatableFallbackComponent)
}
diff --git a/frontend/src/app/components/medical-sources-connected/medical-sources-connected.component.html b/frontend/src/app/components/medical-sources-connected/medical-sources-connected.component.html
index ca48cb2b..4ec0dac6 100644
--- a/frontend/src/app/components/medical-sources-connected/medical-sources-connected.component.html
+++ b/frontend/src/app/components/medical-sources-connected/medical-sources-connected.component.html
@@ -40,7 +40,7 @@