Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(project landing page): add interfaces for metadata object (D…
…SP-1183) (#366) * refactor (project landing page): Add interfaces for metadata object and replace bracket notation with dot notation
- Loading branch information
Snehal Kumbhar
committed
Jan 21, 2021
1 parent
66931f0
commit 5e0a938
Showing
15 changed files
with
508 additions
and
353 deletions.
There are no files selected for viewing
26 changes: 14 additions & 12 deletions
26
src/app/project/board/address-template/address-template.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
import { Component, Input } from '@angular/core'; | ||
import { IAddress } from '../dataset-metadata'; | ||
|
||
@Component({ | ||
selector: 'app-address-template', | ||
template: ` | ||
<div class="sub-details"> | ||
<h4>Address:</h4> | ||
<address class="contents"> | ||
<p *ngIf="address['streetAddress']">{{ address['streetAddress'] }}</p> | ||
<span *ngIf="address['postalCode']" style="margin-right: 6px;">{{ address['postalCode'] }}</span> | ||
<span *ngIf="address['addressLocality']">{{ address['addressLocality'] }}</span> | ||
</address> | ||
</div> | ||
` | ||
selector: 'app-address-template', | ||
template: ` | ||
<div class="sub-details"> | ||
<h4>Address:</h4> | ||
<address class="contents"> | ||
<p>{{ address.streetAddress }}</p> | ||
<span class="postcode">{{ address.postalCode }}</span> | ||
<span>{{ address.addressLocality }}</span> | ||
</address> | ||
</div> | ||
`, | ||
styles: ['.postcode { margin-right: 6px; }'] | ||
}) | ||
export class AddressTemplateComponent { | ||
@Input() address: object; | ||
@Input() address: IAddress; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 12 additions & 72 deletions
84
src/app/project/board/attribution-tab-view/attribution-tab-view.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,22 @@ | ||
import { Component, Input, OnInit } from '@angular/core'; | ||
import { Component, Input } from '@angular/core'; | ||
import { IAttribution, IOrganisation, IPerson } from '../dataset-metadata'; | ||
|
||
@Component({ | ||
selector: 'app-attribution-tab-view', | ||
templateUrl: './attribution-tab-view.component.html', | ||
styleUrls: ['./attribution-tab-view.component.scss'] | ||
}) | ||
export class AttributionTabViewComponent implements OnInit{ | ||
|
||
export class AttributionTabViewComponent { | ||
// attribution input | ||
@Input() attribution: object; | ||
|
||
// hard-coded data to complete the functionality | ||
people = [{ | ||
'address': {'addressLocality': 'Basel', 'postalCode': '4000', 'streetAddress': 'Teststrasse'}, | ||
'email': 'benjamin.jones@test.ch', | ||
'familyName': 'Jones', | ||
'givenName': 'Benjamin', | ||
'jobTitle': 'Dr. des.', | ||
'organisation': { | ||
'address': {'addressLocality': 'Toronto', 'postalCode': '40000', 'streetAddress': 'University of Toronto Street'}, | ||
'email': 'info@universityoftoronto.ca', | ||
'name': 'University of Toronto', | ||
'url': 'http://www.utoronto.ca/' | ||
} | ||
}, { | ||
'address': {'addressLocality': 'Basel', 'postalCode': '4000', 'streetAddress': 'Teststrasse'}, | ||
'email': 'james.coleman@dasch.swiss', | ||
'familyName': 'Coleman', | ||
'givenName': 'James', | ||
'jobTitle': 'Dr. des.', | ||
'organisation': { | ||
'address': {'addressLocality': 'Toronto', 'postalCode': '40000', 'streetAddress': 'University of Toronto Street'}, | ||
'email': 'info@universityoftoronto.ca', | ||
'name': 'University of Toronto', | ||
} | ||
}, { | ||
'address': {'addressLocality': 'Basel', 'postalCode': '4000', 'streetAddress': 'Teststrasse'}, | ||
'email': 'lauren.berry@unibas.ch', | ||
'familyName': 'Berry', | ||
'givenName': 'Lauren', | ||
'jobTitle': 'Dr.', | ||
'organisation': { | ||
'address': {'addressLocality': 'Toronto', 'postalCode': '40000', 'streetAddress': 'University of Toronto Street'}, | ||
'email': 'info@universityoftoronto.ca', | ||
'name': 'University of Toronto', | ||
} | ||
}, { | ||
'address': {'addressLocality': 'Basel', 'postalCode': '4000', 'streetAddress': 'Teststrasse'}, | ||
'email': 'leonhard.hart@test.ch', | ||
'familyName': 'Hart', | ||
'givenName': 'Leonhard', | ||
'jobTitle': 'Prof.', | ||
'organisation': { | ||
'address': {'addressLocality': 'Toronto', 'postalCode': '40000', 'streetAddress': 'University of Toronto Street'}, | ||
'email': 'info@universityoftoronto.ca', | ||
'name': 'University of Toronto', | ||
} | ||
},{ | ||
'address': {'addressLocality': 'Basel', 'postalCode': '4000', 'streetAddress': 'Teststrasse'}, | ||
'email': 'lauren.berry@unibas.ch', | ||
'familyName': 'Berry', | ||
'givenName': 'Lauren', | ||
'jobTitle': 'Dr.', | ||
'organisation': { | ||
'address': {'addressLocality': 'Toronto', 'postalCode': '40000', 'streetAddress': 'University of Toronto Street'}, | ||
'email': 'info@universityoftoronto.ca', | ||
'name': 'University of Toronto', | ||
'url': 'http://www.utoronto.ca/' | ||
} | ||
}]; | ||
@Input() attributions: IAttribution[]; | ||
|
||
ngOnInit(): void { | ||
// reformat data | ||
for (let idx = 0; idx < this.people.length; idx++) { | ||
if (this.people[idx]['sameAs']) { | ||
this.people[idx]['sameAs'] = this.people[idx]['sameAs']['value']; | ||
} | ||
// 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'; | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.