From 55e02fb618c019046abea420ee8e222cdf7dab25 Mon Sep 17 00:00:00 2001 From: Andrew Wilson Date: Fri, 31 Mar 2023 17:08:06 +0100 Subject: [PATCH] gh-308 - address pr feedback. --- docs/CONCEPTS.md | 6 ++--- src/app/app.component.ts | 4 +++- .../data-specification.service.spec.ts | 4 ++-- .../pages/dashboard/dashboard.component.ts | 2 +- ...data-specification-query.component.spec.ts | 12 +++++----- .../my-bookmarks.component.spec.ts | 10 ++++----- .../my-data-specifications.component.ts | 8 ++++--- ...ata-specification-detail.component.spec.ts | 4 ++-- ...late-data-specifications.component.spec.ts | 22 ++++++++++--------- ...element-in-data-specification.component.ts | 6 ++--- 10 files changed, 42 insertions(+), 36 deletions(-) diff --git a/docs/CONCEPTS.md b/docs/CONCEPTS.md index 0c0e3964..0796203c 100644 --- a/docs/CONCEPTS.md +++ b/docs/CONCEPTS.md @@ -44,7 +44,7 @@ The primary use case of the Mauro Data Explorer is to: 3. Submit this user data specification to the organisation running this instance to gain access to the real data sets owned by the organisation, based on the data elements specified. -The current implementation considers user data specification to be _data models_ in their own right - they are created under the access level of the user signed-in to the Mauro Data Explorer, then populated with data elements before they are submitted. The sections below go into further detail. +The current implementation considers user data specifications to be _data models_ in their own right - they are created under the access level of the user signed-in to the Mauro Data Explorer, then populated with data elements before they are submitted. The sections below go into further detail. ## Data Specifications Folder @@ -116,7 +116,7 @@ It is possible for a user to create a new version of a previously submitted data # Template Requests -Instead of creating User Data Specifications from scratch, it is possible to base a data specification off of a _template_. This is a pre-made data specification that is finalised and can be forked to make a copy from. +Instead of creating user data specifications from scratch, it is possible to base a data specification off of a _template_. This is a pre-made data specification that is finalised and can be forked to make a copy from. ## Templates Folder @@ -126,4 +126,4 @@ The `mdm-plugin-explorer` will automatically: 2. Secure this folder to only be read by the "Explorer Readers" user group. 3. Install the API property `explorer.config.root_-_template_folder` pointing to this folder. -This will be the root folder to store any finalised template data specifications. The Mauro Data Explorer `/templates` page route will list all available templates and allow the user to inspect them and copy from them. Copying involves forking the Data Model data specification to build the copy, which is then automatically moved to the current user's personal data specification folder. +This will be the root folder to store any finalised template data specifications. The Mauro Data Explorer `/templates` page route will list all available templates and allow the user to inspect them and copy from them. Copying involves forking the template data specification to build the copy, which is then automatically moved to the current user's personal data specification folder. diff --git a/src/app/app.component.ts b/src/app/app.component.ts index f510aa65..a8c77449 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -305,7 +305,9 @@ export class AppComponent implements OnInit, OnDestroy { return EMPTY; }), map((dataSpecifications) => { - return dataSpecifications.filter((req) => req.status === 'unsent').length; + return dataSpecifications.filter( + (specification) => specification.status === 'unsent' + ).length; }) ); } diff --git a/src/app/data-explorer/data-specification.service.spec.ts b/src/app/data-explorer/data-specification.service.spec.ts index d15ff1dd..b97203fc 100644 --- a/src/app/data-explorer/data-specification.service.spec.ts +++ b/src/app/data-explorer/data-specification.service.spec.ts @@ -327,8 +327,8 @@ describe('DataSpecificationService', () => { ], }; - dataModelsStub.getDataModelHierarchy.mockImplementationOnce((req) => { - expect(req).toBe(dataSpecification.id); + dataModelsStub.getDataModelHierarchy.mockImplementationOnce((specification) => { + expect(specification).toBe(dataSpecification.id); return cold('--a|', { a: hierarchy, }); diff --git a/src/app/pages/dashboard/dashboard.component.ts b/src/app/pages/dashboard/dashboard.component.ts index bacfb3de..d7dc5adb 100644 --- a/src/app/pages/dashboard/dashboard.component.ts +++ b/src/app/pages/dashboard/dashboard.component.ts @@ -71,7 +71,7 @@ export class DashboardComponent implements OnInit { return throwError(() => error); }), map((dataSpecifications) => - dataSpecifications.filter((req) => req.status === 'unsent') + dataSpecifications.filter((specification) => specification.status === 'unsent') ) ) .subscribe((dataSpecifications: DataSpecification[]) => { diff --git a/src/app/pages/data-specification-query/data-specification-query.component.spec.ts b/src/app/pages/data-specification-query/data-specification-query.component.spec.ts index a0782cef..4c7a1817 100644 --- a/src/app/pages/data-specification-query/data-specification-query.component.spec.ts +++ b/src/app/pages/data-specification-query/data-specification-query.component.spec.ts @@ -173,8 +173,8 @@ describe('DataSpecificationQueryComponent', () => { return of(dataSpecification); }); - dataSpecificationStub.listDataElements.mockImplementationOnce((req) => { - expect(req).toStrictEqual(dataSpecification); + dataSpecificationStub.listDataElements.mockImplementationOnce((specification) => { + expect(specification).toStrictEqual(dataSpecification); return of(dataElements); }); @@ -201,8 +201,8 @@ describe('DataSpecificationQueryComponent', () => { return of(dataSpecification); }); - dataSpecificationStub.listDataElements.mockImplementationOnce((req) => { - expect(req).toStrictEqual(dataSpecification); + dataSpecificationStub.listDataElements.mockImplementationOnce((specification) => { + expect(specification).toStrictEqual(dataSpecification); return of([]); }); @@ -229,8 +229,8 @@ describe('DataSpecificationQueryComponent', () => { return of(dataSpecification); }); - dataSpecificationStub.listDataElements.mockImplementationOnce((req) => { - expect(req).toStrictEqual(dataSpecification); + dataSpecificationStub.listDataElements.mockImplementationOnce((specification) => { + expect(specification).toStrictEqual(dataSpecification); return of(dataElements); }); diff --git a/src/app/pages/my-bookmarks/my-bookmarks.component.spec.ts b/src/app/pages/my-bookmarks/my-bookmarks.component.spec.ts index c9a7e3e0..4445b98f 100644 --- a/src/app/pages/my-bookmarks/my-bookmarks.component.spec.ts +++ b/src/app/pages/my-bookmarks/my-bookmarks.component.spec.ts @@ -57,12 +57,12 @@ describe('MyBookmarkComponent', () => { return { ...bm, isSelected: false }; }); const rootDataModel = { id: 'ID' } as DataModelDetail; - const dar1 = {} as DataModel; - const dar2 = {} as DataModel; + const dataSpecification1 = {} as DataModel; + const dataSpecification2 = {} as DataModel; const sti1 = {} as SourceTargetIntersection; const sti2 = {} as SourceTargetIntersection; const intersections: DataSpecificationSourceTargetIntersections = { - dataSpecifications: [dar1, dar2], + dataSpecifications: [dataSpecification1, dataSpecification2], sourceTargetIntersections: [sti1, sti2], }; @@ -137,10 +137,10 @@ describe('MyBookmarkComponent', () => { harness.component.sourceTargetIntersections.sourceTargetIntersections.length ).toBe(2); expect(harness.component.sourceTargetIntersections.dataSpecifications[0]).toBe( - dar1 + dataSpecification1 ); expect(harness.component.sourceTargetIntersections.dataSpecifications[1]).toBe( - dar2 + dataSpecification2 ); expect( harness.component.sourceTargetIntersections.sourceTargetIntersections[0] diff --git a/src/app/pages/my-data-specifications/my-data-specifications.component.ts b/src/app/pages/my-data-specifications/my-data-specifications.component.ts index 9140db41..bf75fbdb 100644 --- a/src/app/pages/my-data-specifications/my-data-specifications.component.ts +++ b/src/app/pages/my-data-specifications/my-data-specifications.component.ts @@ -61,7 +61,9 @@ export class MyDataSpecificationsComponent implements OnInit { ) {} get hasMultipleStatuses() { - const statuses = this.allDataSpecifications.map((req) => req.status); + const statuses = this.allDataSpecifications.map( + (specification) => specification.status + ); const distinct = new Set(statuses); return distinct.size > 1; } @@ -111,8 +113,8 @@ export class MyDataSpecificationsComponent implements OnInit { const filtered = this.statusFilters.length === 0 ? this.allDataSpecifications - : this.allDataSpecifications.filter((req) => - this.statusFilters.includes(req.status) + : this.allDataSpecifications.filter((specification) => + this.statusFilters.includes(specification.status) ); this.sortBy = sortBy ?? this.sortByDefaultOption; diff --git a/src/app/pages/template-data-specification-detail/template-data-specification-detail.component.spec.ts b/src/app/pages/template-data-specification-detail/template-data-specification-detail.component.spec.ts index 7484fe85..27ab074f 100644 --- a/src/app/pages/template-data-specification-detail/template-data-specification-detail.component.spec.ts +++ b/src/app/pages/template-data-specification-detail/template-data-specification-detail.component.spec.ts @@ -181,8 +181,8 @@ describe('TemplateDataSpecificationDetailComponent', () => { dataSpecificationStub.get.mockImplementationOnce(() => of(template)); - dataSchemaStub.loadDataSchemas.mockImplementationOnce((req) => { - expect(req).toBe(template); + dataSchemaStub.loadDataSchemas.mockImplementationOnce((specification) => { + expect(specification).toBe(template); expect(harness.component.state).toBe('loading'); return of(dataSchemas); }); diff --git a/src/app/pages/template-data-specifications/template-data-specifications.component.spec.ts b/src/app/pages/template-data-specifications/template-data-specifications.component.spec.ts index 8252cf2f..22c97a47 100644 --- a/src/app/pages/template-data-specifications/template-data-specifications.component.spec.ts +++ b/src/app/pages/template-data-specifications/template-data-specifications.component.spec.ts @@ -117,16 +117,18 @@ describe('TemplateDataSpecificationsComponent', () => { }); it('should copy a template to a new data specification', () => { - dataSpecificationStub.forkWithDialogs.mockImplementationOnce((req, options) => { - expect(req).toBe(dataSpecification); - expect(options?.targetFolder).toBe(dataSpecificationFolder); - return of({ - ...dataSpecification, - id: '3', - label: 'copied data specification', - status: 'unsent', - }); - }); + dataSpecificationStub.forkWithDialogs.mockImplementationOnce( + (specification, options) => { + expect(specification).toBe(dataSpecification); + expect(options?.targetFolder).toBe(dataSpecificationFolder); + return of({ + ...dataSpecification, + id: '3', + label: 'copied data specification', + status: 'unsent', + }); + } + ); harness.component.copy(dataSpecification); diff --git a/src/app/shared/data-element-in-data-specification/data-element-in-data-specification.component.ts b/src/app/shared/data-element-in-data-specification/data-element-in-data-specification.component.ts index b58ef7b1..6ad5dcd5 100644 --- a/src/app/shared/data-element-in-data-specification/data-element-in-data-specification.component.ts +++ b/src/app/shared/data-element-in-data-specification/data-element-in-data-specification.component.ts @@ -257,11 +257,11 @@ export class DataElementInDataSpecificationComponent implements OnInit, OnDestro .map((sti) => sti.targetDataModelId); this.dataSpecificationMenuItems = this.sourceTargetIntersections.dataSpecifications - .map((req) => { + .map((specification) => { return { - dataModel: req, + dataModel: specification, containsElement: idsOfDataSpecificationsContainingElement.includes( - req.id ?? '' + specification.id ?? '' ), }; })