Skip to content

Commit

Permalink
Merge pull request #1771 from CSCfi/CSCTTV-2775
Browse files Browse the repository at this point in the history
CSCTTV-2775
  • Loading branch information
ommann authored Aug 16, 2023
2 parents 66b2ff0 + 3a7129c commit 1ee8f05
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/app/portal/models/dataset/dataset.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1ee8f05

Please sign in to comment.