[Library | new-theme]: Do not show provenance value if no provenance vocabulary or if no label for this provenance value.
1. fundedBy.component.ts: Added local field "provenancesCalculated" to check for each provenance label only once and do not show provenance if no vocabulary or if not label for this value. 2. result-preview.component.ts: Do not show provenance if no vocabulary or if no label for this value. 3. HelperFunctions.class.ts: In method "getVocabularyLabel()" added parameter "returnIfNotFound: boolean = true" to return null if no vocabulary or if no label for this value, when it is false.
This commit is contained in:
parent
fa919431d3
commit
656a3634e2
|
@ -58,10 +58,10 @@ import {HelperFunctions} from '../../utils/HelperFunctions.class';
|
|||
<span class="uk-text-meta">Funding stream: </span>{{item.funding}}
|
||||
</li>
|
||||
</ul>
|
||||
<div *ngIf="item.provenanceAction || item.validated" class="uk-text-meta">
|
||||
<div *ngIf="getVocabularyLabel(item, provenanceActionVocabulary, i) || item.validated" class="uk-text-meta">
|
||||
<span *ngIf="item.validated">Validated by funder</span>
|
||||
<span *ngIf="item.provenanceAction && item.validated"> | </span>
|
||||
<span *ngIf="item.provenanceAction">{{getVocabularyLabel(item.provenanceAction, provenanceActionVocabulary)}}</span>
|
||||
<span *ngIf="item.provenanceAction">{{item.provenanceAction}}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -80,6 +80,7 @@ export class FundedByComponent {
|
|||
public url = properties.searchLinkToProject.split('?')[0];
|
||||
public title: string = "Funded by";
|
||||
@Input() provenanceActionVocabulary = null;
|
||||
public provenancesCalculated: boolean[] = [];
|
||||
|
||||
public viewAllClick() {
|
||||
if(this.fundedByProjects.length <= this.threshold*2) {
|
||||
|
@ -96,7 +97,11 @@ export class FundedByComponent {
|
|||
this.viewAllClicked.emit("");
|
||||
}
|
||||
|
||||
public getVocabularyLabel(value: any, vocabulary: any) {
|
||||
return HelperFunctions.getVocabularyLabel(value, vocabulary);
|
||||
public getVocabularyLabel(item: any, vocabulary: any, index: number) {
|
||||
if(!this.provenancesCalculated[index]) {
|
||||
this.provenancesCalculated[index] = true;
|
||||
item.provenanceAction = HelperFunctions.getVocabularyLabel(item.provenanceAction, vocabulary, false);
|
||||
}
|
||||
return item.provenanceAction;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -72,12 +72,18 @@ export class HelperFunctions {
|
|||
return Object.keys(value).map(key => value[key]);
|
||||
}
|
||||
|
||||
public static getVocabularyLabel(value: any, vocabulary: any) {
|
||||
public static getVocabularyLabel(value: any, vocabulary: any, returnIfNotFound: boolean = true) {
|
||||
if(value == undefined || value == null) {
|
||||
return null;
|
||||
}
|
||||
if(vocabulary && value in vocabulary) {
|
||||
return vocabulary[value];
|
||||
}
|
||||
if(returnIfNotFound) {
|
||||
return value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static sortSDGs(sgd1: string, sdg2: string): number {
|
||||
let splitA: string[] = sgd1.split(".");
|
||||
|
|
|
@ -123,7 +123,10 @@ export class ResultPreviewComponent implements OnInit, OnChanges {
|
|||
this.beforeTitle.push(this.result.startYear.toString() + ' - ' + this.result.endYear.toString());
|
||||
}
|
||||
if(this.result.provenanceAction) {
|
||||
this.beforeTitle.push(HelperFunctions.getVocabularyLabel(this.result.provenanceAction, this.provenanceActionVocabulary));
|
||||
let value = HelperFunctions.getVocabularyLabel(this.result.provenanceAction, this.provenanceActionVocabulary, false);
|
||||
if(value) {
|
||||
this.beforeTitle.push(value);
|
||||
}
|
||||
}
|
||||
if(this.result.relationName) {
|
||||
this.beforeTitle.push(HelperFunctions.getVocabularyLabel(this.result.relationName, this.relationsVocabulary));
|
||||
|
|
Loading…
Reference in New Issue