Commit 7c27c39d authored by Viacheslav Pavlov's avatar Viacheslav Pavlov Committed by Matija Obreza
Browse files

Country link

parent dc04be56
......@@ -3,9 +3,17 @@
* Defined in Swagger as '#/definitions/Country'
*/
class Country {
public iso2: string;
public iso3: string;
public code2: string;
public code3: string;
public codeNum: string;
public current: boolean;
public maxLatitude: number;
public maxLongitude: number;
public minLatitude: number;
public minLongitude: number;
public name: string;
public refnameId: number;
public wikiLink: string;
}
......
......@@ -6,6 +6,7 @@ import Subset from 'model/Subset';
import Accession from 'model/Accession';
import FaoInstitute from 'model/FaoInstitute';
import MaterialRequest from 'model/MaterialRequest';
import Country from 'model/Country';
function SubsetLink({ to: subset, edit = false, children = null }
: { to: Subset, edit?: boolean, children?: any }) {
......@@ -71,4 +72,12 @@ function RequestLink({ to: request, edit = false, children = null }
}
}
export { SubsetLink, AccessionLink, InstituteLink, RequestLink };
const CountryLink = ({ country, children }: { country: Country, children?: any }) => (
<Link to={ `/geo/${country.code3}` }>
<div style={ {display: 'flex', alignItems: 'center'} }>
<img src={ `images/flags/${country.code3}.png` } style={ {maxWidth: '1.25rem', padding: '0 0.25rem'} } />{ children || country.name }
</div>
</Link>
);
export { SubsetLink, AccessionLink, InstituteLink, RequestLink, CountryLink};
......@@ -24,7 +24,7 @@ import { ScrollToTopOnMount } from 'ui/common/page/scrollers';
import ReduxCheckbox from 'ui/common/checkbox';
import CropChips from 'ui/genesys/crop/CropChips';
import LocationMap from 'ui/common/LocationMap';
import {InstituteLink} from 'ui/genesys/Links';
import {CountryLink, InstituteLink} from 'ui/genesys/Links';
import McpdDate from 'ui/common/time/McpdDate';
......@@ -120,7 +120,7 @@ class BrowsePage extends React.Component<IBrowsePageProps, any> {
{ accession.institute.fullName }
</InstituteLink>
</PropertiesItem>
<PropertiesItem title="Country of holding institute">{ accession.institute.country.name }</PropertiesItem>
<PropertiesItem title="Country of holding institute">{ <CountryLink country={ accession.institute.country }/> }</PropertiesItem>
<PropertiesItem title="Institute code">{ accession.institute.code }</PropertiesItem>
<PropertiesItem title="Acquisition date"><McpdDate value={ accession.acquisitionDate } /></PropertiesItem>
{ accession.sampStat && <PropertiesItem title="Biological status of accession">{ t(`accession.sampleStatus.${accession.sampStat}`) }</PropertiesItem> }
......@@ -171,7 +171,7 @@ class BrowsePage extends React.Component<IBrowsePageProps, any> {
{ accession.coll &&
<PageSection title="Collecting information">
<Properties>
{ accession.countryOfOrigin && <PropertiesItem title="Country of origin">{ accession.countryOfOrigin.name }</PropertiesItem> }
{ accession.countryOfOrigin && <PropertiesItem title="Country of origin">{ <CountryLink country={ accession.countryOfOrigin }/> }</PropertiesItem> }
{ accession.coll.collDate && <PropertiesItem key="collDate" title={ t(`accession.coll.collDate`) }><McpdDate value={ accession.coll.collDate } /></PropertiesItem> }
{ accession.coll &&
[ 'collMissId', 'collNumb', 'collSite', 'collSrc' ]
......
......@@ -23,6 +23,7 @@ import PieChart from 'ui/common/pie-chart';
import PrettyDate from 'ui/common/time/PrettyDate';
import withWidth from '@material-ui/core/withWidth';
import {Breakpoint} from '@material-ui/core/styles/createBreakpoints';
import {CountryLink} from 'ui/genesys/Links';
interface IDisplayPageProps extends React.ClassAttributes<any> {
t: any;
......@@ -91,7 +92,7 @@ class DisplayPage extends React.Component<IDisplayPageProps, any> {
<Properties>
<PropertiesItem title="Institute code">{ institute.details.code }</PropertiesItem>
<PropertiesItem title="Type">{ institute.details.type }</PropertiesItem>
<PropertiesItem title="Country">{ institute.details.country.name }</PropertiesItem>
<PropertiesItem title="Country">{ <CountryLink country={ institute.details.country }/> }</PropertiesItem>
{ institute.details.url &&
<PropertiesItem title="Web link">
<a href={ institute.details.url }> { institute.details.url }</a>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment