Skip to content

Commit

Permalink
fix(openalex): No flag if no country, filter on empty countries and s…
Browse files Browse the repository at this point in the history
…ort countries by Alphanumeric order
  • Loading branch information
annelhote committed Nov 25, 2024
1 parent 7748d85 commit 85e89bc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 1 addition & 1 deletion client/src/pages/openalex-ror/results/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ export default function Affiliations() {
)}
{isLoadingRorData && (
<tr>
<td colspan="4">
<td colSpan={4}>
<Spinner size={24} />
</td>
</tr>
Expand Down
19 changes: 10 additions & 9 deletions client/src/pages/openalex-ror/results/views-selector.jsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import { Badge,
import {
Badge,
Button,
Col, Row,
Col,
Modal, ModalContent, ModalFooter, ModalTitle,
ButtonGroup,
Row,
} from '@dataesr/dsfr-plus';
import { useState, useEffect } from 'react';
import PropTypes from 'prop-types';
import { useEffect, useState } from 'react';
import { useSearchParams } from 'react-router-dom';

import useToast from '../../../hooks/useToast';
import { getAffiliationsCorrections } from '../../../utils/curations';
import getFlagEmoji from '../../../utils/flags';
import { isRor } from '../../../utils/ror';

import ListView from './list-view';
import DataTableView from './datatable-view';
import getFlagEmoji from '../../../utils/flags';
import ListView from './list-view';

export default function OpenalexView({
allAffiliations,
Expand Down Expand Up @@ -108,7 +108,7 @@ export default function OpenalexView({
<Row>
<Col>
<input
checked={selectedOpenAlex.length === allAffiliations.length}
checked={(selectedOpenAlex.length === allAffiliations.length) && (selectedOpenAlex.length > 0)}
className="fr-ml-2w"
onChange={() => {
if (selectedOpenAlex.length === 0) {
Expand Down Expand Up @@ -238,6 +238,8 @@ export default function OpenalexView({
<option value="all">All countries</option>
{
[...new Set(allAffiliations.flatMap((affiliation) => affiliation.rors.map((ror) => ror.rorCountry)))]
.filter((country) => !!country)
.sort((a, b) => new Intl.DisplayNames(['en'], { type: 'region' }).of(a).localeCompare(new Intl.DisplayNames(['en'], { type: 'region' }).of(b)))
.sort((a, b) => allAffiliations.filter((aff) => aff.rors.some((r) => r.rorCountry === b)).length - allAffiliations.filter((aff) => aff.rors.some((r) => r.rorCountry === a)).length)
.map((country) => (
<option
Expand All @@ -263,7 +265,6 @@ export default function OpenalexView({
>
Reset to default
</Button>

<Button
onClick={() => {
setSortsAndFilters({
Expand Down
1 change: 1 addition & 0 deletions client/src/utils/flags.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export default function getFlagEmoji(countryCode) {
if (!countryCode) return '';
const codePoints = countryCode
.toUpperCase()
.split('')
Expand Down

0 comments on commit 85e89bc

Please sign in to comment.