From 5dde42f2d5a1e2e47d5f60bc734d74200c425dea Mon Sep 17 00:00:00 2001 From: Snehal Kumbhar Date: Tue, 2 Mar 2021 13:35:46 +0100 Subject: [PATCH] refactor(project landing page): use metadata endpoint to get data from backend (DSP-1199) (#400) * feat(project landing page): displayed message if metadata is not available for selected project. * feat(project landing page): removed copyToClipboard option for license * refactor(project landing page): updated right side column for new metadata structure * refactor(project landing page): update project and terms tabs according to new metadata schema * refactor(project landing page): update dataset and attribution and contact page for new metadata schema Note: need to work on UI for person and organisation templates (mainly used in funder, grant, attribution and contact sections) * chore(project landing page): updated template for funder and grant * chore(project landing page): updated style * chore(project landing page): cleanup, removed hardcoded metadata * refactor(project landing page): updated error handler for project metadata endpoint * chore(project landing page): removed dataset-metadata interface * chore(project landing page): excluded some testcases until test data is ready * chore(project landing page): use service to get contact type --- .../address-template.component.ts | 21 +- .../attribution-tab-view.component.html | 29 +- .../attribution-tab-view.component.scss | 3 +- .../attribution-tab-view.component.ts | 26 +- src/app/project/board/board.component.html | 205 +++++----- src/app/project/board/board.component.scss | 147 ++++---- src/app/project/board/board.component.spec.ts | 1 + src/app/project/board/board.component.ts | 350 ++++-------------- .../contacts-tab-view.component.html | 22 +- .../contacts-tab-view.component.spec.ts | 5 +- .../contacts-tab-view.component.ts | 36 +- .../project/board/dataset-metadata.service.ts | 25 ++ src/app/project/board/dataset-metadata.ts | 111 ------ .../dataset-tab-view.component.html | 13 +- .../dataset-tab-view.component.spec.ts | 102 +---- .../dataset-tab-view.component.ts | 6 +- .../organisation-template.component.ts | 40 +- .../person-template.component.html | 56 ++- .../person-template.component.spec.ts | 23 +- .../person-template.component.ts | 31 +- .../project-tab-view.component.html | 97 ++++- .../project-tab-view.component.scss | 16 +- .../project-tab-view.component.spec.ts | 6 +- .../project-tab-view.component.ts | 107 +++++- .../terms-tab-view.component.html | 34 +- .../terms-tab-view.component.scss | 9 +- .../terms-tab-view.component.spec.ts | 2 +- 27 files changed, 732 insertions(+), 791 deletions(-) create mode 100644 src/app/project/board/dataset-metadata.service.ts delete mode 100644 src/app/project/board/dataset-metadata.ts diff --git a/src/app/project/board/address-template/address-template.component.ts b/src/app/project/board/address-template/address-template.component.ts index 5c5d0c76f3..4e7c3aa4aa 100644 --- a/src/app/project/board/address-template/address-template.component.ts +++ b/src/app/project/board/address-template/address-template.component.ts @@ -1,20 +1,19 @@ import { Component, Input } from '@angular/core'; -import { IAddress } from '../dataset-metadata'; +import { Address } from '@dasch-swiss/dsp-js'; @Component({ selector: 'app-address-template', template: ` -
-

Address:

-
-

{{ address.streetAddress }}

- {{ address.postalCode }} - {{ address.addressLocality }} -
+ - `, - styles: ['.postcode { margin-right: 6px; }'] + ` }) export class AddressTemplateComponent { - @Input() address: IAddress; + @Input() address: Address; } diff --git a/src/app/project/board/attribution-tab-view/attribution-tab-view.component.html b/src/app/project/board/attribution-tab-view/attribution-tab-view.component.html index ecec3cb85a..bf3f4c8cdb 100644 --- a/src/app/project/board/attribution-tab-view/attribution-tab-view.component.html +++ b/src/app/project/board/attribution-tab-view/attribution-tab-view.component.html @@ -1,21 +1,28 @@ -

Attribution

- -

The following people are involved in the creation of the dataset:

- - -

{{ attribution.role | titlecase }}

+

The following people are involved in the creation of the dataset:

-
- + + -
- +

Agent(s):

+
+
+
+ +
+
+ +
+
-
diff --git a/src/app/project/board/attribution-tab-view/attribution-tab-view.component.scss b/src/app/project/board/attribution-tab-view/attribution-tab-view.component.scss index ca0ffce2bf..bf913e52fc 100644 --- a/src/app/project/board/attribution-tab-view/attribution-tab-view.component.scss +++ b/src/app/project/board/attribution-tab-view/attribution-tab-view.component.scss @@ -1,5 +1,6 @@ .attribution-entry { - margin-top: 25px; + margin-top: 20px; + background-color: #fffdfd; .color-for-role { color: brown; diff --git a/src/app/project/board/attribution-tab-view/attribution-tab-view.component.ts b/src/app/project/board/attribution-tab-view/attribution-tab-view.component.ts index 88553f5b1a..b229edc450 100644 --- a/src/app/project/board/attribution-tab-view/attribution-tab-view.component.ts +++ b/src/app/project/board/attribution-tab-view/attribution-tab-view.component.ts @@ -1,5 +1,6 @@ import { Component, Input } from '@angular/core'; -import { IAttribution, IOrganisation, IPerson } from '../dataset-metadata'; +import { Attribution, IId, Organization, Person } from '@dasch-swiss/dsp-js'; +import { MetadataService } from '../dataset-metadata.service'; @Component({ selector: 'app-attribution-tab-view', @@ -8,15 +9,24 @@ import { IAttribution, IOrganisation, IPerson } from '../dataset-metadata'; }) export class AttributionTabViewComponent { // attribution input - @Input() attributions: IAttribution[]; + @Input() attributions: Attribution[]; + + @Input() subProperties: Object; + + currentAgent: Person | Organization | IId; + + constructor(private _metadataService: MetadataService) { + } // return the type of agent to use correct template to display it - getAgentType(agent: IPerson | IOrganisation) { - if (agent.hasOwnProperty('familyName')) { - return 'person'; - } - if (agent.hasOwnProperty('url')) { - return 'organisation'; + setAgent (agent: Person | Organization | IId): string { + let atype = this._metadataService.getContactType(agent); + if (atype) { + this.currentAgent = agent; + } else { + this.currentAgent = this.subProperties[agent.id]; + atype = this._metadataService.getContactType(this.currentAgent); } + return atype; } } diff --git a/src/app/project/board/board.component.html b/src/app/project/board/board.component.html index 9b142ad220..b027d085aa 100644 --- a/src/app/project/board/board.component.html +++ b/src/app/project/board/board.component.html @@ -1,23 +1,24 @@ - +
- - - Active - Deactivated + + + Active + Deactivated + + + + + - - - - -
@@ -28,7 +29,7 @@

- + Active Deactivated @@ -51,13 +52,17 @@

-
- +
-
-

Description

-
+
@@ -67,7 +72,7 @@

Description

perm_data_setting Project - + @@ -83,7 +88,7 @@

Description

assignment Attribution - +
@@ -93,106 +98,122 @@

Description

- portrait Contact - +
-
+ +