Commit 264b3631 authored by Matija Obreza's avatar Matija Obreza
Browse files

ISO3316: Moving from /geo to /iso3316

- Default L10n texts
- Code cleanup
parent b1f6fe02
......@@ -407,15 +407,16 @@
"public": {
"p": {
"countryList": {
"title": "Country list",
"subTitle": "By clicking on a country name, you can find registered institutes in the country as well as statistics on plant genetic resources in the country as a whole.",
"title": "ISO-3316 list",
"subTitle": "Find registered institutes as well as overview on plant genetic resources",
"acceCount": "{{count, number}} accessions",
"acceCountAtInstitutes": "{{count, number}} accessions at institutes in this country",
"acceCountAtInstitutes": "{{count, number}} accessions at {{institutes, number}} institutes",
"accessionsInGenesys": "Provenance of accessions",
"institutesCountInWIEWS": "{{count, number}} institutes registered in WIEWS",
"instituteLocations": "Institute locations",
"moreInformation": "More information",
"isoCodes": "ISO",
"countryProfile": "Country profile"
"isoCodes": "ISO-3316",
"countryProfile": "ISO-3316 code {{code}}"
},
"regionList": {
"title": "FAO Geographical regions",
......@@ -435,25 +436,10 @@
"longitude": "Longitude",
"address": "Address",
"country": "Country",
"menu": "Countries"
"menu": "ISO-3316 codes"
}
}
,"list": {
"public": {
"p": {
"browse": {
"title": "Selected accessions",
"subTitle": "As you explore the millions of accessions held in Genesys, you can create your own list to keep track of the results of your search. Your selections are stored here so you can return to them at any time.",
"sendRequest": "Send request",
"noAccessions": "You have not added any accessions to the list."
}
}
},
"common": {
"menu": "My List"
}
}
,"institutes": {
"public": {
"c": {
......@@ -500,6 +486,21 @@
"accessionsInGenesys": "Accessions in Genesys"
}
}
,"list": {
"public": {
"p": {
"browse": {
"title": "Selected accessions",
"subTitle": "As you explore the millions of accessions held in Genesys, you can create your own list to keep track of the results of your search. Your selections are stored here so you can return to them at any time.",
"sendRequest": "Send request",
"noAccessions": "You have not added any accessions to the list."
}
}
},
"common": {
"menu": "My List"
}
}
,"repository": {
"admin": {
"p": {
......
......@@ -44,6 +44,7 @@ export const loadRegions = () => (dispatch, getState) => {
};
export const loadCountryDetails = (iso3code: string) => (dispatch, getState) => {
dispatch(receiveCountryDetails(null));
return GeoService.getCountryDetails(iso3code)
.then((details: CountryDetails) => {
dispatch(receiveCountryDetails(details));
......@@ -54,6 +55,7 @@ export const loadCountryDetails = (iso3code: string) => (dispatch, getState) =>
};
export const loadRegionDetails = (isoCode: string) => (dispatch, getState) => {
dispatch(receiveRegionDetails(null));
return GeoService.getGeoRegion(isoCode)
.then((details: RegionDetails) => {
dispatch(receiveRegionDetails(details));
......
......@@ -16,6 +16,17 @@ const publicRoutes = [
component: RegionDisplayPage,
exact: true,
},
{
path: '/iso3316/:isoCode',
component: CountryDisplayPage,
exact: true,
},
{
path: '/iso3316/',
component: CountryListPage,
exact: true,
},
// Obsolete
{
path: '/geo/:isoCode',
component: CountryDisplayPage,
......
......@@ -2,15 +2,16 @@
"public": {
"p": {
"countryList": {
"title": "Country list",
"subTitle": "By clicking on a country name, you can find registered institutes in the country as well as statistics on plant genetic resources in the country as a whole.",
"title": "ISO-3316 list",
"subTitle": "Find registered institutes as well as overview on plant genetic resources",
"acceCount": "{{count, number}} accessions",
"acceCountAtInstitutes": "{{count, number}} accessions at institutes in this country",
"acceCountAtInstitutes": "{{count, number}} accessions at {{institutes, number}} institutes",
"accessionsInGenesys": "Provenance of accessions",
"institutesCountInWIEWS": "{{count, number}} institutes registered in WIEWS",
"instituteLocations": "Institute locations",
"moreInformation": "More information",
"isoCodes": "ISO",
"countryProfile": "Country profile"
"isoCodes": "ISO-3316",
"countryProfile": "ISO-3316 code {{code}}"
},
"regionList": {
"title": "FAO Geographical regions",
......@@ -30,6 +31,6 @@
"longitude": "Longitude",
"address": "Address",
"country": "Country",
"menu": "Countries"
"menu": "ISO-3316 codes"
}
}
import * as React from 'react';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import { translate } from 'react-i18next';
// Actions
import {loadCountryDetails} from 'geo/actions/public';
import {applyFilters} from 'accessions/actions/public';
import { loadCountryDetails } from 'geo/actions/public';
import { applyFilters } from 'accessions/actions/public';
// Model
import CountryDetails from 'model/geo/CountryDetails';
import FaoInstitute from 'model/genesys/FaoInstitute';
// UI
import PageLayout, {MainSection, PageContents, PageSection} from 'ui/layout/PageLayout';
import {Properties, PropertiesItem} from 'ui/common/Properties';
import {InstituteLink} from 'ui/genesys/Links';
import {ExternalLink} from 'ui/common/Links';
import PageLayout, { MainSection, PageContents, PageSection } from 'ui/layout/PageLayout';
import { Properties, PropertiesItem } from 'ui/common/Properties';
import { InstituteLink } from 'ui/genesys/Links';
import { ExternalLink } from 'ui/common/Links';
import ContentHeader from 'ui/common/heading/ContentHeader';
import LocationMap from 'ui/common/LocationMap';
import Loading from 'ui/common/Loading';
......@@ -48,6 +48,13 @@ class CountryDisplayPage extends React.Component<ICountryDisplayPageProps> {
}
}
public componentWillReceiveProps(nextProps) {
const { loadCountryDetails, details, isoCode } = nextProps;
if (isoCode && (! details || details.code3 !== isoCode)) {
loadCountryDetails(isoCode);
}
}
private getLocations = (institutes: FaoInstitute[]) => {
const instLocations = [];
institutes.forEach((inst) => {
......@@ -66,71 +73,71 @@ class CountryDisplayPage extends React.Component<ICountryDisplayPageProps> {
}
public render() {
const {details, t} = this.props;
const stillLoading: boolean = (! details);
const {details, isoCode, t} = this.props;
const stillLoading: boolean = (! details || details.code3 !== isoCode);
return (
<PageLayout>
<ContentHeader title={ `${t(`geo.public.p.countryList.countryProfile`) }` }/>
<ContentHeader title={ `${t('geo.public.p.countryList.countryProfile', { code: isoCode }) }` }/>
<div>
{ stillLoading ? <Loading /> :
<PageContents>
<MainSection title={ `${details.name}` }>
<Properties>
<PropertiesItem title={ t(`geo.public.p.countryList.moreInformation`) }>
<PropertiesItem title={ t('geo.public.p.countryList.moreInformation') }>
<ExternalLink link={ details.wikiLink }>{ details.wikiLink }</ExternalLink>
</PropertiesItem>
<PropertiesItem title={ `${t(`geo.public.p.countryList.isoCodes`)}` }>
<PropertiesItem title={ `${t('geo.public.p.countryList.isoCodes')}` }>
<span>{ `ISO-3166 3-alpha: ${details.code3}, ISO-3166 2-alpha: ${details.code2}` }</span>
</PropertiesItem>
<PropertiesItem title={ t(`institutes.common.accessionsInGenesys`) }>
<PropertiesItem title={ t('geo.public.p.countryList.accessionsInGenesys') }>
<a onClick={ () => this.applyCountryOfOriginFilter(details.code3) }><Number value={ details.accessionCount || 0 } /></a>
</PropertiesItem>
</Properties>
</MainSection>
{ details.genesysInstitutes && details.genesysInstitutes.length > 0 &&
<PageSection title={ `${t(`geo.public.p.countryList.acceCountAtInstitutes`, {count: details.countByLocation}) }` }>
<PageSection title={ t('geo.public.p.countryList.instituteLocations') }>
<LocationMap locations={ this.getLocations(details.genesysInstitutes) } />
</PageSection>
}
{ details.genesysInstitutes && details.genesysInstitutes.length > 0 &&
<PageSection title={ `${t('geo.public.p.countryList.acceCountAtInstitutes', {count: details.countByLocation, institutes: details.genesysInstitutes.length }) }` }>
<Properties>
{ details.genesysInstitutes.map((institute, index) => (
<PropertiesItem key={ `${institute.id}-${institute.code}-genesys` } numeric
<PropertiesItem key={ `${institute.id}-genesys` } numeric
title={
<span>
{ `${index + 1}` } <br/>
{ /* { `${index + 1}` } */ }
<InstituteLink to={ institute }>
{ `${institute.code}${institute.fullName}` }
</InstituteLink>
</span>
}>{ `${t(`geo.public.p.countryList.acceCount`, {count: institute.accessionCount}) }` }</PropertiesItem>
}>{ `${t('geo.public.p.countryList.acceCount', {count: institute.accessionCount}) }` }</PropertiesItem>
)) }
</Properties>
</PageSection>
}
{ details.faoInstitutes && details.faoInstitutes.length > 0 &&
<PageSection title={ `${t(`geo.public.p.countryList.institutesCountInWIEWS`, {count: details.faoInstitutes.length}) }` }>
<PageSection title={ `${t('geo.public.p.countryList.institutesCountInWIEWS', {count: details.faoInstitutes.length}) }` }>
<Properties>
{ details.faoInstitutes.map((fao, index) => (
<PropertiesItem key={ `${fao.id}-${fao.code}-fao` }
<PropertiesItem key={ `${fao.id}-fao` } numeric keepEmpty
title={
<span>
{ `${index + 1}` } <br/>
{ /* `${index + 1}` */ }
<InstituteLink to={ fao }>
{ `${fao.code}${fao.fullName}` }
</InstituteLink>
</span>
} keepEmpty/>
} />
)) }
</Properties>
</PageSection>
}
{ details.genesysInstitutes && details.genesysInstitutes.length > 0 &&
<PageSection title={ t(`geo.public.p.countryList.instituteLocations`) }>
<LocationMap locations={ this.getLocations(details.genesysInstitutes) } />
</PageSection>
}
</PageContents>
}
</div>
......
......@@ -69,7 +69,7 @@ class RegionDisplayPage extends React.Component<IRegionDisplayPageProps> {
<ContentHeaderWithButton title={ `${details.countries.length > 0 ? t(`geo.public.p.regionList.listOfCountries`) : t(`geo.public.p.regionList.listOfSubRegions`) }` } buttons={
<span>
<ActionButton action={ () => navigateTo('/geo/regions') } title={ t(`geo.public.p.regionList.b.listAllFaoRegions`) }/>
{ details.parentRegion && <ActionButton action={ () => navigateTo(`/geo/region/${details.parentRegion.isoCode}`) } title={ `${t(`geo.public.p.regionList.b.showParentRegion`, {what: details.parentRegion.name}) }` } /> }
{ details.parentRegion && <ActionButton action={ () => navigateTo(`/iso3316/region/${details.parentRegion.isoCode}`) } title={ `${t(`geo.public.p.regionList.b.showParentRegion`, {what: details.parentRegion.name}) }` } /> }
</span>
} />
......
......@@ -30,7 +30,7 @@ const InstituteCard = ({ institute, classes, index, t, ...other }: { institute:
</InstituteLink>
</b>
{ institute.country && ` • ${institute.country.name}` }
{ institute.accessionCount && <span className="float-right">{ t('institutes.public.c.instituteCard.accessionsInGenesys', {count: institute.accessionCount}) }</span> }
{ institute.accessionCount ? <span className="float-right">{ t('institutes.public.c.instituteCard.accessionsInGenesys', {count: institute.accessionCount}) }</span> : null }
</div>
<div>
<em>
......
......@@ -91,7 +91,7 @@ const CountryLink = ({ country, noflag, children }: { country: Country, noflag?:
return null;
}
return (
<Link to={ `/geo/${country.code3}` }>
<Link to={ `/iso3316/${country.code3}` }>
<div style={ {display: 'flex', alignItems: 'center'} }>
{ !noflag && <img src={ `images/flags/${country.code3}.png` } style={ {maxWidth: '1.25rem', padding: '0 0.25rem'} } /> }
{ children || country.name }
......@@ -105,7 +105,7 @@ const RegionLink = ({ region, children }: { region: GeoRegion, children?: any })
return null;
}
return (
<Link to={ `/geo/region/${region.isoCode}` }>
<Link to={ `/iso3316/region/${region.isoCode}` }>
{ children || region.name }
</Link>
);
......
......@@ -120,7 +120,7 @@ class LeftMenu extends React.Component<ILeftMenuProps, any> {
<NavLink activeClassName="active" to="/subsets">{ t('subsets.common.modelName_plural') }</NavLink>
</ListItem>
<ListItem button>
<NavLink activeClassName="active" to="/geo">{ t('geo.common.menu') }</NavLink>
<NavLink activeClassName="active" to="/iso3316">{ t('geo.common.menu') }</NavLink>
</ListItem>
<ListItem button>
<NavLink activeClassName="active" to="/wiews">{ t('institutes.common.modelName_plural') }</NavLink>
......
......@@ -175,7 +175,6 @@ class Header extends React.Component<IHeaderProps | any, any> {
<div className="navigation-block float-right">
<NavLink activeClassName="active" to="/a">{ t('accessions.common.menu') }</NavLink>
<NavLink activeClassName="active" to="/subsets">{ t('subsets.common.menu') }</NavLink>
<NavLink activeClassName="active" to="/geo">{ t('geo.common.menu') }</NavLink>
<NavLink activeClassName="active" to="/wiews">{ t('institutes.common.menu') }</NavLink>
<NavLink activeClassName="active" to="/c">{ t('crop.common.menu') }</NavLink>
<NavLink activeClassName="active" to="/sel">{ t('list.common.menu') }<MyListCount count={ myListItemsCount }/></NavLink>
......
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