Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge changes from qa to devel #1920

Merged
merged 1 commit into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,6 @@ export class DataSourcesFiltersComponent
const handleDataFilter = (category: string) =>
filterData(profileData, this.activeFilters, category);

console.log('profileData', profileData);

// JSON structure mimics the one we got in Portal from Elasticsearch
const filters = {
aggregations: {
Expand Down
44 changes: 30 additions & 14 deletions src/app/mydata/services/search-portal.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export interface Respone {
}

@Injectable({
providedIn: 'root',
providedIn: 'root'
})
export class SearchPortalService {
apiUrl: string;
Expand Down Expand Up @@ -49,7 +49,7 @@ export class SearchPortalService {
case 'name': {
switch (groupId) {
case 'publication': {
sortField = 'publicationName.keyword';
sortField = 'publicationYear';
break;
}
case 'dataset': {
Expand All @@ -66,8 +66,8 @@ export class SearchPortalService {

this.currentSort = {
[sortField]: {
order: sortSettings.direction,
},
order: sortSettings.direction
}
};
}

Expand Down Expand Up @@ -105,26 +105,42 @@ export class SearchPortalService {
}

getData(term: string, groupId: string) {
// Default sort to descending
const sort = this.currentSort
? this.currentSort
: {
[this.getDefaultSortField(groupId)]: { order: 'desc' },

// Leverage query generation method from portal
const finalQuery = {
'bool': {
'must': [{ 'term': { '_index': groupId } }, this.searchSettingsService.querySettings(groupId, term)]
}
};
let sort = undefined;

// Queries and sorts are different for publication category, default sort is descending
if (groupId === 'publication') {
const publicationSort = this.currentSort
? this.currentSort
: {
[this.getDefaultSortField(groupId)]: { order: 'desc' }
};
sort = ['_score', publicationSort, '_score'];
} else {
const generalSort = this.currentSort
? this.currentSort
: {
[this.getDefaultSortField(groupId)]: { order: 'desc', unmapped_type: 'long' }
};
sort = [generalSort, '_score', '_score'];
}

const pageSettings = this.pageSettings;

// Leverage query generation method from portal
const query = this.searchSettingsService.querySettings(groupId, term);

let payload = {
track_total_hits: true,
sort: sort,
from: pageSettings ? pageSettings.pageIndex * pageSettings.pageSize : 0,
size: pageSettings ? pageSettings.pageSize : 10,
size: pageSettings ? pageSettings.pageSize : 10
};

if (term?.length) payload = Object.assign(payload, { query: query });
if (term?.length) payload = Object.assign(payload, { query: finalQuery });

// TODO: Map response
return this.http
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,14 @@ export class ActiveFiltersComponent
// Field of science
if (val.category === 'field' && source.field?.fields) {
const result = source.field.fields.buckets.find(
(key) =>
parseInt(key.fieldId.buckets[0].key, 10) ===
parseInt(val.value, 10)
(key) => {
const res = key.fieldId.buckets.find(item => {
return parseInt(item.key, 10) === parseInt(val.value, 10)
});
return res;
}
);

const foundIndex = this.activeFilters.findIndex(
(x) => x.value === val.value
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,13 @@ export class FundingCallResultsComponent
},
callOpen: {
label: call.openDate.getFullYear()
? this.highlightPipe.transform(call.openDateString === '01.01.1900' ? '-' : call.openDateString, this.input)
? call.openDateString === '01.01.1900' ? '-' : call.openDateString
: '-',
},
callDue: {
label:
call.dueDate.getFullYear() !== 2100
? this.highlightPipe.transform(call.dueDateString, this.input)
? call.dueDateString
: $localize`:@@continuous:Jatkuva`,
},
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,7 @@ export class PublicationsComponent implements OnInit, OnDestroy, AfterViewInit {
template: channelColumnArray[index],
},
year: {
label: this.highlightPipe.transform(
publication.publicationYear,
this.input
),
label: publication.publicationYear,
},
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@ <h2 class="col-12 col-sm-4 col-lg-3 th">
<!-- Normal funding -->
<ng-container *ngIf="!item.euFunding; else euCallProgramme">
<div class="col-12 col-sm-8 col-lg-9 td">
<a [routerLink]="'/results/funding-calls/' + item.funder.callProgrammeName">{{ item.funder.callProgrammeName }}</a>
<!-- If funder is Research council of Finland, directly link to single funding call with id, otherwise link to search page -->
<a [routerLink]="item.funder.callProgrammeId && (item.funder.funderOrganizationId === '02458939' || item.funder.funderOrganizationId === '605001') ? '/results/funding-call/' + item.funder.callProgrammeId : '/results/funding-calls/' + item.funder.callProgrammeName">{{ item.funder.callProgrammeName }}</a>
</div>
</ng-container>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,51 +31,51 @@ import { Search } from 'src/app/portal/models/search.model';
import { MatSnackBar } from '@angular/material/snack-bar';
import MetaTags from 'src/assets/static-data/meta-tags.json';
import { AppSettingsService } from '@shared/services/app-settings.service';
import { ModelUtilsService } from '@shared/services/model-util.service';
import { CleanCitationPipe } from '../../../pipes/clean-citation';
import { MatProgressSpinner } from '@angular/material/progress-spinner';
import { CdkCopyToClipboard } from '@angular/cdk/clipboard';
import { DialogComponent } from '../../../../shared/components/dialog/dialog.component';
import { ShareComponent } from '../share/share.component';
import { SecondaryButtonComponent } from '../../../../shared/components/buttons/secondary-button/secondary-button.component';
import { RelatedLinksComponent } from '../related-links/related-links.component';
import { MatCard, MatCardTitle } from '@angular/material/card';
import { PublicationLinksComponent } from './publication-links/publication-links.component';
import { OrcidComponent } from '../../../../shared/components/orcid/orcid.component';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { TooltipModule } from 'ngx-bootstrap/tooltip';
import { BreadcrumbComponent } from '../../breadcrumb/breadcrumb.component';
import { ModelUtilsService } from '@shared/services/model-util.service';
import { CleanCitationPipe } from '../../../pipes/clean-citation';
import { MatProgressSpinner } from '@angular/material/progress-spinner';
import { CdkCopyToClipboard } from '@angular/cdk/clipboard';
import { DialogComponent } from '../../../../shared/components/dialog/dialog.component';
import { ShareComponent } from '../share/share.component';
import { SecondaryButtonComponent } from '../../../../shared/components/buttons/secondary-button/secondary-button.component';
import { RelatedLinksComponent } from '../related-links/related-links.component';
import { MatCard, MatCardTitle } from '@angular/material/card';
import { PublicationLinksComponent } from './publication-links/publication-links.component';
import { OrcidComponent } from '../../../../shared/components/orcid/orcid.component';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import { TooltipModule } from 'ngx-bootstrap/tooltip';
import { BreadcrumbComponent } from '../../breadcrumb/breadcrumb.component';
import { SearchBarComponent } from '../../search-bar/search-bar.component';

@Component({
selector: 'app-single-publication',
templateUrl: './single-publication.component.html',
styleUrls: ['./single-publication.component.scss'],
standalone: true,
imports: [
SearchBarComponent,
NgIf,
RouterLink,
BreadcrumbComponent,
NgFor,
TooltipModule,
FontAwesomeModule,
NgClass,
OrcidComponent,
NgSwitch,
NgSwitchCase,
NgSwitchDefault,
PublicationLinksComponent,
MatCard,
MatCardTitle,
RelatedLinksComponent,
SecondaryButtonComponent,
ShareComponent,
DialogComponent,
CdkCopyToClipboard,
MatProgressSpinner,
CleanCitationPipe,
],
@Component({
selector: 'app-single-publication',
templateUrl: './single-publication.component.html',
styleUrls: ['./single-publication.component.scss'],
standalone: true,
imports: [
SearchBarComponent,
NgIf,
RouterLink,
BreadcrumbComponent,
NgFor,
TooltipModule,
FontAwesomeModule,
NgClass,
OrcidComponent,
NgSwitch,
NgSwitchCase,
NgSwitchDefault,
PublicationLinksComponent,
MatCard,
MatCardTitle,
RelatedLinksComponent,
SecondaryButtonComponent,
ShareComponent,
DialogComponent,
CdkCopyToClipboard,
MatProgressSpinner,
CleanCitationPipe,
],
})
export class SinglePublicationComponent
implements OnInit, AfterViewInit, OnDestroy
Expand Down Expand Up @@ -631,20 +631,27 @@ export class SinglePublicationComponent
}

filterData() {
// Helper function to check if the field exists and has data
// Helper function to check if the field exists and has valid data
const checkEmpty = (item: { field: string }) => {
return UtilityService.stringHasContent(
this.responseData.publications[0][item.field]
);
};
// Helper function to check if the field has some data
const checkIfValueExists = (item: { field: string }) => {
return this.responseData.publications[0][item.field]?.length > 0;
};

// Filter all the fields to only include properties with defined data
this.infoFields = this.infoFields.filter((item) => checkEmpty(item));
// this.authorFields = this.authorFields.filter(item => checkEmpty(item));
this.organizationSubFields = this.organizationSubFields.filter((item) =>
checkEmpty(item)
);
this.typeFields = this.typeFields.filter((item) => checkEmpty(item));
this.mediumFields = this.mediumFields.filter((item) => checkEmpty(item));

// Jufo code 0 must be shown, so exception added. Check empty function cannot be used, since in interprets 0 as empty.
this.mediumFields = this.mediumFields.filter((item) => item.field !== 'jufoClassCode' ? checkEmpty(item) : checkIfValueExists(item));
this.linksFields = this.linksFields.filter((item) => checkEmpty(item));
this.otherFields = this.otherFields.filter((item) => checkEmpty(item));
this.open_accessFields = this.open_accessFields.filter((item) =>
Expand Down
6 changes: 5 additions & 1 deletion src/app/portal/models/funding/funder.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ export class Funder {
constructor(
public name: string,
public nameUnd: string,
public funderOrganizationId: string,
public typeOfFundingId: string,
public typeOfFundingName: string,
public callProgrammeName: string,
public callProgrammeId: string,
public callProgrammeNameUnd: string,
public callProgrammeHomePage: string,
public frameworkProgramme: string,
Expand Down Expand Up @@ -44,12 +46,14 @@ export class FunderAdapter implements Adapter<Funder> {

return new Funder(
this.utils.checkTranslation('funderName', item),
item.funderNameUnd,
item.funderNameUnd,
item.funderOrganizationId,
item.typeOfFundingId,
this.utils.checkTranslation('typeOfFundingName', item)?.trim().length > 0
? this.utils.checkTranslation('typeOfFundingName', item)
: item.typeOfFundingId,
this.utils.checkTranslation('callProgrammeName', item),
item.callProgrammeId,
item.callProgrammeNameUnd,
item.callProgrammeHomePage,
this.utils.checkTranslation(
Expand Down
8 changes: 4 additions & 4 deletions src/app/portal/pipes/highlight.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { Pipe, PipeTransform } from '@angular/core';
import { DomSanitizer } from '@angular/platform-browser';

@Pipe({
name: 'highlight',
standalone: true,
name: 'highlight',
standalone: true,
})
export class HighlightSearchPipe implements PipeTransform {

Expand All @@ -26,7 +26,7 @@ export class HighlightSearchPipe implements PipeTransform {

const LETTER_EXPRESSION = /^\p{L}$/u;
const isLetter = (character) => {
return character && (LETTER_EXPRESSION.test(character) || !isNaN(character) || character === '.' || character === ',');
return character && (LETTER_EXPRESSION.test(character) || !isNaN(character));
};

// Replace coded umlauts
Expand Down Expand Up @@ -79,7 +79,7 @@ export class HighlightSearchPipe implements PipeTransform {
return processedHighlight;
}
} else {
return processedHighlight + stillToProcessInput;
return processedHighlight + stillToProcessInput;
}
}

Expand Down
34 changes: 20 additions & 14 deletions src/app/portal/services/filters/filter-method.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,32 @@ export class FilterMethodService {
// Map minor fields of science to arrays by major
separateMinor(source) {
let mapped: any;
const subFieldsMerged = [];
this.combined = [];
// Map fields by field & nested id

// Merge nested subfields of science
if (source && source.length > 0) {
mapped = source.map((majorField) => ({
key: majorField.fieldId.buckets[0]?.key.toString() || -1,
label: majorField.key,
// Invalid response if key is 0
id: majorField.fieldId.buckets[0]?.key || -1,
doc_count: majorField.fieldId.buckets[0]?.key
// Separate logic for publications and datasets
? majorField.filtered.filterCount.doc_count
: -1,
}));
source.forEach(item => {
item.fieldId.buckets.forEach(fieldId => {
subFieldsMerged.push({
key: fieldId?.key.toString() || -1,
label: item.key,
// Invalid response if key is 0
id: fieldId?.key || -1,
doc_count: fieldId?.key
// Separate logic for publications and datasets
? fieldId?.doc_count
: -1,
});
});
});
}
// Loop through major fields & push all instances as separate arrays
this.staticDataService.majorFieldsOfScience.forEach((item) => {
let i = item.id;
if (mapped) {
const i = item.id;
if (subFieldsMerged) {
this.combined.push(
mapped
subFieldsMerged
.filter((obj) => {
return obj.id.toString().charAt(0).includes(String(i))
})
Expand Down
Loading
Loading