-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1771 from CSCfi/CSCTTV-2775
CSCTTV-2775
- Loading branch information
Showing
1 changed file
with
16 additions
and
2 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -5,7 +5,7 @@ | |
// :author: CSC - IT Center for Science Ltd., Espoo Finland [email protected] | ||
// :license: MIT | ||
|
||
import { Injectable } from '@angular/core'; | ||
import { inject, Injectable, LOCALE_ID } from '@angular/core'; | ||
import { Adapter } from '../adapter.model'; | ||
import { ModelUtilsService } from '@shared/services/model-util.service'; | ||
import { | ||
|
@@ -79,7 +79,21 @@ export class DatasetAdapter implements Adapter<Dataset> { | |
const locale = this.appSettingsService.currentLocale; | ||
const capitalizedLocale = this.appSettingsService.capitalizedLocale; | ||
|
||
const keywords = item.keywords ? item.keywords.map((x) => x.keyword) : []; | ||
let keywords: string[] = []; | ||
|
||
const keywordsByLanguage = { | ||
fi: item.keywords ? item.keywords.filter((x) => x.language === 'FI').map((x) => x.keyword) : [], | ||
en: item.keywords ? item.keywords.filter((x) => x.language === 'EN').map((x) => x.keyword) : [], | ||
sv: item.keywords ? item.keywords.filter((x) => x.language === 'SV').map((x) => x.keyword) : [], | ||
und: item.keywords ? item.keywords.filter((x) => x.language === 'UND').map((x) => x.keyword) : [] | ||
} | ||
|
||
// Choose non-empty list of keywords by following the order of current locale, fi, en, sv, und | ||
if (keywordsByLanguage[locale].length > 0) { keywords = keywordsByLanguage[locale]; } | ||
else if (keywordsByLanguage.fi.length > 0) { keywords = keywordsByLanguage.fi; } | ||
else if (keywordsByLanguage.en.length > 0) { keywords = keywordsByLanguage.en; } | ||
else if (keywordsByLanguage.sv.length > 0) { keywords = keywordsByLanguage.sv; } | ||
else if (keywordsByLanguage.und.length > 0) { keywords = keywordsByLanguage.und; } | ||
|
||
let fieldsOfScience: FieldOfScience[] = []; | ||
// All items don't have field_of_science field | ||
|