Commit 0180348b authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch '44-disabling-overview-sections' into 'main'

Disabling Overview sections

Closes #44

See merge request !38
parents 2bd966ed c231d789
......@@ -44,6 +44,9 @@ Add a container `<div>` to your HTML page and initialize the Genesys UI with the
pdci: true, // Show PDCI
subsets: true, // Show list of subsets
datasets: true, // Show list of datasets
overviews: {
'aegis': false, // Don't display the AEGIS Overview
}
},
shoppingCart: {
enabled: true, // Enable shopping cart
......@@ -113,6 +116,49 @@ Features can be toggled by setting corresponding property **on** (set to `true`)
|`subsets`|`true`| Display the list of **subsets** on accession details page |
|`datasets`|`true`| Display the list of C&E **datasets** on accession details page |
|`pdci`|`true`| Display passport data completeness index (PDCI) information on accession details page |
|`overviews`|`{ ... }`| Allows for disabling individual sections in the display of Overviews |
### Disabling individual Overview sections
The Overviews sections display the number of accessions by different categories.
The following categories are available and enabled by default:
|Overview|Enabled|Description|
|--|--|--|
|`institute.code`| `false` | Number of accessions by FAO Institute Code of the holding genebank
|`institute.country.code3`| `false` | Number of accessions by the country of the holding genebank
|`cropName`| `true` | Crop name as submitted to Genesys
|`crop.shortName`| `true` | Genesys crop
|`sampStat`| `true` | Biological status of accession
|`taxonomy.genus`| `true` | Genus name
|`taxonomy.genusSpecies`| `true` | Species name
|`taxonomy.grinTaxonomySpecies.name`| `true` | Species name according to GRIN-Taxonomy (auto-detected by Genesys)
|`taxonomy.currentTaxonomySpecies.name`| `true` | The current species name according to GRIN-Taxonomy
|`countryOfOrigin.code3`| `true` | Country of origin
|`donorCode`| `true` | FAO WIEWS Institute code of the accession donor institute
|`mlsStatus`| `true` | Accession status in the Multi-lateral System of the ITPGRFA
|`available`| `true` | Accession availability
|`duplSite`| `true` | FAO WIEWS Institute code where accessions are safety-duplicated
|`storage`| `true` | Type of germplasm storage
|`breederCode`| `true` | FAO WIEWS Insitute code of the institute that bred the material
|`aegis`| `false` | Status of accession in European AEGIS network
|`sgsv`| `true` | Accessions safety-backed up in Svalbard Global Seed Vault
To disable the *AEGIS* and *Institute code* sections in the Overviews, the update your config to include:
```js
const genesysConfig = {
..., // other configuration options
accession: {
... // other accession options
overviews: {
'aegis': false, // Don't display the AEGIS Overview
'institute.code': false, // Exclude summary by FAO Institude Code
},
},
... // other configuration
}
```
## Shopping cart and captcha options
......@@ -149,7 +195,7 @@ The map is **disabled by default**. To allow users to see map of accession colle
|`height`|`'400px'`| Height of the map of accessions (use a CSS expression) |
|`baseMap`|`{ url: ..., attribution: ... }`| See `url` and `attribution` below. |
|`baseMap.url`|[World_Light_Gray_Base](https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}/)| Tile server template URL for the base map layer. |
|`baseMap.attribution`|Tiles &copy; ...| Map base layer attribution. |
|`baseMap.attribution`|Tiles &copy; ...| Map base layer attribution |
# Translating Embedded Genesys
......
......@@ -15,6 +15,10 @@ const genesysConfig: Config = {
pdci: true,
subsets: true,
datasets: true,
overviews: {
'aegis': false,
'sgsv': false,
},
},
shoppingCart: {
enabled: true,
......
......@@ -3,21 +3,20 @@ import { withTranslation, WithTranslation } from 'react-i18next';
import { connect } from 'react-redux';
// model
import { OverviewItem } from '@genesys-pgr/client/model/accession/AccessionOverview';
import {Config} from 'config/config';
//ui
import PropertiesCard from 'ui/common/PropertiesCard';
interface AccessionOverviewPageProps {
overview: { [key: string]: OverviewItem };
countryCodes: Record<string, string>;
appConfig: Config;
}
class AccessionOverviewSection extends React.Component<AccessionOverviewPageProps & WithTranslation> {
private overviewKeys = ['institute.code', 'institute.country.code3', 'cropName', 'crop.shortName', 'sampStat', 'taxonomy.genus', 'taxonomy.genusSpecies',
'taxonomy.grinTaxonomySpecies.name', 'taxonomy.currentTaxonomySpecies.name',
'countryOfOrigin.code3', 'donorCode', 'mlsStatus', 'available', 'duplSite', 'sgsv', 'storage', 'breederCode', 'aegis'];
public render() {
const { overview, t, countryCodes } = this.props;
const { overview, t, countryCodes, appConfig } = this.props;
if (!overview) {
return null;
......@@ -25,7 +24,9 @@ class AccessionOverviewSection extends React.Component<AccessionOverviewPageProp
const overviewsTerms = new Map();
this.overviewKeys.forEach((key) => {
Object.keys(appConfig?.accession?.overviews)
.filter((key) => !Object.keys(appConfig.accession.overviews).includes(key) || appConfig.accession.overviews[key])
.forEach((key) => {
const overviewEl = overview[key];
const terms = overviewEl && overviewEl.terms ? [].concat(overviewEl.terms) : [];
if (overviewEl && overviewEl.other && overviewEl.other > 0) {
......@@ -190,6 +191,7 @@ class AccessionOverviewSection extends React.Component<AccessionOverviewPageProp
const mapStateToProps = (state) => ({
appConfig: state.appConfig.config,
countryCodes: state.decoding.countryCodes,
});
......
import _merge from 'lodash/merge';
export interface WithConfig {
appConfig: Config;
}
......@@ -28,13 +29,13 @@ export class Config {
this.i18n = config.i18n || defaultConfig.i18n;
// Merge feature config
this.accession = {...defaultConfig.accession, ...config.accession};
this.shoppingCart = {...defaultConfig.shoppingCart, ...config.shoppingCart};
if (! this.captchaSiteKey) {
this.accession = _merge(defaultConfig.accession, config.accession);
this.shoppingCart = _merge(defaultConfig.shoppingCart, config.shoppingCart);
if (!this.captchaSiteKey) {
// Force disable shopping cart if captchaSiteKey is missing
this.shoppingCart.enabled = false;
}
this.map = {...defaultConfig.map, ...config.map};
this.map = _merge(defaultConfig.map, config.map);
// console.log('Source and merged configuration', config, this);
}
}
......@@ -47,6 +48,26 @@ class AccessionConfig extends BaseFeatureConfig {
public pdci?: boolean;
public subsets?: boolean;
public datasets?: boolean;
public overviews?: {
'institute.code'?: boolean,
'institute.country.code3'?: boolean,
'cropName'?: boolean,
'crop.shortName'?: boolean,
'sampStat'?: boolean,
'taxonomy.genus'?: boolean,
'taxonomy.genusSpecies'?: boolean,
'taxonomy.grinTaxonomySpecies.name'?: boolean,
'taxonomy.currentTaxonomySpecies.name'?: boolean,
'countryOfOrigin.code3'?: boolean,
'donorCode'?: boolean,
'mlsStatus'?: boolean,
'available'?: boolean,
'duplSite'?: boolean,
'storage'?: boolean,
'breederCode'?: boolean,
'aegis'?: boolean,
'sgsv'?: boolean,
}
}
export class MapConfig extends BaseFeatureConfig {
......@@ -71,22 +92,30 @@ export const defaultConfig: Partial<Config> = {
pdci: true,
datasets: true,
subsets: true,
overviews: {
'institute.code': false,
'institute.country.code3': false,
'cropName': true,
'crop.shortName': true,
'sampStat': true,
'taxonomy.genus': true,
'taxonomy.genusSpecies': true,
'taxonomy.grinTaxonomySpecies.name': true,
'taxonomy.currentTaxonomySpecies.name': true,
'countryOfOrigin.code3': true,
'donorCode': true,
'mlsStatus': true,
'available': true,
'duplSite': true,
'storage': true,
'breederCode': true,
'aegis': false,
'sgsv': true,
}
},
shoppingCart: {
enabled: false,
},
i18n: {
en: {
translations:
{
'action': {
'cancel': 'Cancel',
'save': 'Save',
'delete': 'Delete',
}
},
}
},
map: {
enabled: true,
height: '400px', // 'calc(100vh - 115px)',
......
import i18n from 'i18next';
import * as _ from 'lodash';
import _merge from 'lodash/merge';
// import HttpApi from 'i18next-http-backend';
import { initReactI18next } from 'react-i18next';
import transEn from 'locales/en/translations.json';
......@@ -45,7 +45,7 @@ const initI18n = (language = 'en', translations?: { [key: string]: Translations
react: {
useSuspense: false,
},
resources: _.merge(resources, translations),
resources: _merge(resources, translations),
// partialBundledLanguages: true,
// backend: loaderOptions, // backend options
interpolation: {
......
......@@ -104,8 +104,8 @@
"institute country code3": "Country of holding institute",
"crop shortName": "Crop",
"sampStat": "Biological status of accession",
"taxonomy genus": "Genus name provided to Genesys",
"taxonomy genusSpecies": "Species name provided to Genesys",
"taxonomy genus": "Genus name",
"taxonomy genusSpecies": "Species name",
"taxonomy grinTaxonomySpecies": "Matched GRIN taxon",
"taxonomy currentTaxonomySpecies": "Current GRIN taxon",
"countryOfOrigin code3": "Provenance of material",
......
Supports Markdown
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