Commit 19aa9d0c authored by Matija Obreza's avatar Matija Obreza

Merge branch '696-fao-wiews-link' into 'master'

FAO WIEWS link

Closes #696

See merge request genesys-pgr/genesys-ui!677
parents 0b3c11ea 288243fd
......@@ -50,6 +50,9 @@ module.exports = {
compress: true,
port: PORT,
host: HOST,
watchOptions: {
ignored: /node_modules/
},
overlay: {
warnings: true,
errors: true
......
......@@ -1797,7 +1797,8 @@
"pdciDescription2": ". For example, a wild accession should have a well-defined collection site but no variety name. The PDCI ranges from 0 to 10, where 0 is the minimum score assigned to rather incomplete passport records and 10 is the maximum score assigned to very complete passport records. Any type of accession, wild, landrace, breeding material or modern variety, can attain the PDCI’s maximal score.",
"pdciDescriptionLink": "(van Hintum et al. 2011)",
"pdciYLabel": "Number of passport records",
"pdciXLabel": "Passport Data Completeness Index (PDCI)"
"pdciXLabel": "Passport Data Completeness Index (PDCI)",
"showWiewsPage": "Show in FAO WIEWS database"
}
}
},
......
This diff is collapsed.
......@@ -42,7 +42,8 @@
"pdciDescription2": ". For example, a wild accession should have a well-defined collection site but no variety name. The PDCI ranges from 0 to 10, where 0 is the minimum score assigned to rather incomplete passport records and 10 is the maximum score assigned to very complete passport records. Any type of accession, wild, landrace, breeding material or modern variety, can attain the PDCI’s maximal score.",
"pdciDescriptionLink": "(van Hintum et al. 2011)",
"pdciYLabel": "Number of passport records",
"pdciXLabel": "Passport Data Completeness Index (PDCI)"
"pdciXLabel": "Passport Data Completeness Index (PDCI)",
"showWiewsPage": "Show in FAO WIEWS database"
}
}
},
......
......@@ -41,7 +41,7 @@ import ErrorMessage from 'ui/common/error/ErrorMessage';
import { PartnerLink } from 'ui/catalog/Links';
import PropertiesCard from 'ui/common/PropertiesCard';
import { Grid } from '@material-ui/core';
import { ExternalInstituteLink } from 'ui/common/Links';
import { ExternalInstituteLink, FaoWiewsLink } from 'ui/common/Links';
/* eslint-disable*/
const styles = (theme) => ({
......@@ -79,6 +79,7 @@ interface IDisplayPageProps extends React.ClassAttributes<any>, WithTranslation
mapLayers: MapLayer[];
apiUrl: string;
showSnackbar: (snack: string) => void;
lang: string;
}
......@@ -173,7 +174,7 @@ class DisplayPage extends React.Component<IDisplayPageProps, any> {
}
public render() {
const { error, loading, institute, code, userRoles, mapLayers, classes, apiUrl, t } = this.props;
const { error, loading, institute, code, userRoles, mapLayers, classes, apiUrl, t, lang } = this.props;
const slug: string = this.state.authenticated ? DOWNLOAD_AUTH_SLUG : DOWNLOAD_ANON_SLUG;
let cropShortNameOverview;
......@@ -253,7 +254,10 @@ class DisplayPage extends React.Component<IDisplayPageProps, any> {
</div>
}
<Properties>
<PropertiesItem title={ t('institutes.common.instituteCode') }>{ institute.details.code }</PropertiesItem>
<PropertiesItem title={ t('institutes.common.instituteCode') }>
<strong>{ institute.details.code }</strong>
<div className="float-right"><FaoWiewsLink lang={ lang } wiewsCode={ institute.details.code }>{ t('institutes.public.p.display.showWiewsPage') }</FaoWiewsLink></div>
</PropertiesItem>
<PropertiesItem title={ t('institutes.public.p.display.type') }>{ institute.details.type }</PropertiesItem>
<PropertiesItem title={ t('geo.common.country') }>{ <CountryLink country={ institute.details.country }/> }</PropertiesItem>
{hasNewVersion &&
......@@ -419,6 +423,7 @@ const mapStateToProps = (state, ownProps) => ({
userRoles: state.login.authorities,
apiUrl: state.applicationConfig.apiUrl,
mapLayers: state.accessions.public.mapLayers,
lang: state.applicationConfig.lang,
});
const mapDispatchToProps = (dispatch) => bindActionCreators({
......
......@@ -10,9 +10,20 @@ const ExternalLink = ({link, children}: { link: string, children?: any }) => {
);
};
const FaoWiewsLink = ({ wiewsCode, children }: { wiewsCode: string, children?: any }) => (
<ExternalLink link={ `http://www.fao.org/wiews/data/organizations/en/?instcode=${wiewsCode}` }>{ children ? children : wiewsCode }</ExternalLink>
);
const FaoWiewsLink = ({ wiewsCode, children, lang }: { wiewsCode: string, children?: any, lang: string }) => {
const toFaoLang = (lang: string): string => {
const FAO_LANGUAGES = ['zh', 'en', 'fr', 'ru', 'es', 'ar'];
return FAO_LANGUAGES.some((faoLang) => faoLang === lang) ? lang : 'en';
};
return (
<ExternalLink
link={ `http://www.fao.org/wiews/data/organizations/${toFaoLang(lang)}/?instcode=${wiewsCode}#details` }
>
{ children ? children : wiewsCode }
</ExternalLink>
);
};
const ExternalInstituteLink = ({links}: {links: string}) => {
const separatedLinks = links.split(/[,;]?\s+/);
......
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