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

Configurable Overview sections

parent 2bd966ed
......@@ -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,
});
......
......@@ -28,13 +28,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 = { ...defaultConfig.accession, ...config.accession };
this.shoppingCart = { ...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 = { ...defaultConfig.map, ...config.map };
// console.log('Source and merged configuration', config, this);
}
}
......@@ -47,6 +47,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 +91,30 @@ export const defaultConfig: Partial<Config> = {
pdci: true,
datasets: true,
subsets: true,
overviews: {
'institute.code': true,
'institute.country.code3': true,
'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': true,
'sgsv': true,
}
},
shoppingCart: {
enabled: false,
},
i18n: {
en: {
translations:
{
'action': {
'cancel': 'Cancel',
'save': 'Save',
'delete': 'Delete',
}
},
}
},
map: {
enabled: true,
height: '400px', // 'calc(100vh - 115px)',
......
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