Commit edd932aa authored by Matija Obreza's avatar Matija Obreza
Browse files

Accession Details: Config support for pdci, subsets and datasets sections

parent 34badb44
......@@ -12,6 +12,9 @@ const genesysConfig: Config = {
clientKey: 'changeme',
filter: { institute: { code: [ 'COL003', 'BEL084', 'ETH013' ] } },
language: queryLang,
accession: {
pdci: true,
},
shoppingCart: {
enabled: true,
},
......
......@@ -95,7 +95,7 @@ class AccessionDetailsPage extends React.Component<IAccessionDetailsPage & WithT
public render() {
const { accession, cartItems } = this.state;
const { t, appConfig: { apiUrl, shoppingCart }, countryCodes } = this.props;
const { t, appConfig: { apiUrl, shoppingCart }, appConfig, countryCodes } = this.props;
let propertyIndex = 0;
......@@ -108,9 +108,30 @@ class AccessionDetailsPage extends React.Component<IAccessionDetailsPage & WithT
const pdci = accession.pdci;
return (
<>
<h1>{ details.accessionNumber }</h1>
{ details.doi && <Property title={ t('accession.doi') } value={ details.doi } index={ propertyIndex++ }/> }
{ details.accessionName && <Property title={ t('accession.accessionName') } value={ details.accessionName } index={ propertyIndex++ }/> }
<div className="d-flex justify-content-between align-items-center">
<h1>{ details.accessionNumber }</h1>
{ shoppingCart.enabled &&
<div>
{ cartItems.includes(this.props.match.params.uuid) ?
<button
type="button"
name={ `button-remove-${accession.details.uuid}` }
data-uuid={ accession.details.uuid }
className="btn btn-primary"
onClick={ this.removeFromCart }
>
{ t('cart.removeFromCart') }
</button>
:
this.renderAddToCart()
}
</div>
}
</div>
{ details.doi && <Property title={ t('accession.doi') } value={ <a href={ `https://doi.org/${details.doi}` } target="_blank">{ details.doi }</a> } index={ propertyIndex++ }/> }
{ details.accessionName && <Property title={ t('accession.accessionName') } value={ <b>{ details.accessionName }</b> } index={ propertyIndex++ }/> }
<Property title={ t('accession.acceNumb') } value={ details.accessionNumber } index={ propertyIndex++ } />
{ details.institute && details.institute.fullName &&
<Property title={ t('accession.holdingInstitute') } value={ details.institute.fullName } index={ propertyIndex++ }/>
}
......@@ -156,44 +177,33 @@ class AccessionDetailsPage extends React.Component<IAccessionDetailsPage & WithT
index={ propertyIndex++ } />
}
{ details.acceUrl &&
<Property title="Accession URL" value={ <a href={ details.acceUrl } target="_blank" rel="nofollow">{ details.acceUrl }</a> } index={ propertyIndex++ }/>
<Property title="Accession URL" value={ details.acceUrl } index={ propertyIndex++ }/>
}
{/* {details.crop && <Property title={ t('accession.crop') } value={ details.crop.shortName } index={ propertyIndex++ }/>} */}
{ details.cropName && <Property title={ t('accession.cropName') } value={ details.cropName } index={ propertyIndex++ }/> }
{ details.taxonomy &&
<>
<h3 className="mt-4">{t('accession.details.providedTaxonomy')}</h3>
<Property title={ t('accession.taxonomy.genus') } value={ details.taxonomy.genus } index={ propertyIndex++ }/>
<Property title={ t('accession.taxonomy.species') } value={ details.taxonomy.species } index={ propertyIndex++ }/>
<Property title={ t('accession.taxonomy.scientificName') } value={ <span dangerouslySetInnerHTML={ { __html: details.taxonomy.taxonNameHtml } } /> } index={ propertyIndex++ }/>
{details.crop && <Property title={ t('accession.crop') } value={ details.crop.shortName } index={ propertyIndex++ }/>}
{details.cropName && <Property title={ t('accession.cropName') } value={ details.cropName } index={ propertyIndex++ }/>}
</>
}
{ details.taxonomy.grinTaxonomySpecies &&
<div>
<h3 className="mt-4">
{t('accession.details.grinTaxonomy')}
<a href={ `mailto:helpdesk@genesys-pgr.org?subject=Taxonomy of accession ${details.uuid}` }>
Contact us
{ details.taxonomy.grinTaxonomySpecies &&
<Property title={ t('accession.taxonomy.grinTaxonName') } value={
<a href={ `https://npgsweb.ars-grin.gov/gringlobal/taxon/taxonomydetail?id=${details.taxonomy.grinTaxonomySpecies.id}` }>
<GrinSpecies grinSpecies={ details.taxonomy.grinTaxonomySpecies } />
</a>
</h3>
<a href={ `https://npgsweb.ars-grin.gov/gringlobal/taxon/taxonomydetail?id=${details.taxonomy.grinTaxonomySpecies.id}` }>
<GrinSpecies grinSpecies={ details.taxonomy.grinTaxonomySpecies } />
</a>
</div>
}
{ details.taxonomy.currentTaxonomySpecies &&
<div>
<h3 className="mt-4">
{t('accession.details.currentTaxonomy')}
</h3>
<a href={ `https://npgsweb.ars-grin.gov/gringlobal/taxon/taxonomydetail?id=${details.taxonomy.currentTaxonomySpecies.id}` }>
<GrinSpecies grinSpecies={ details.taxonomy.currentTaxonomySpecies } />
</a>
</div>
} index={ propertyIndex++ }/> }
{ details.taxonomy.currentTaxonomySpecies && details.taxonomy.currentTaxonomySpecies.id !== details.taxonomy.grinTaxonomySpecies.id &&
<Property title={ t('accession.taxonomy.grinCurrentName') } value={
<a href={ `https://npgsweb.ars-grin.gov/gringlobal/taxon/taxonomydetail?id=${details.taxonomy.currentTaxonomySpecies.id}` }>
<GrinSpecies grinSpecies={ details.taxonomy.currentTaxonomySpecies } />
</a>
} index={ propertyIndex++ }/> }
</>
}
{details.aliases && details.aliases.length > 0 &&
<>
<h3 className="mt-4">{t('accession.details.accessionNames')}</h3>
......@@ -221,6 +231,7 @@ class AccessionDetailsPage extends React.Component<IAccessionDetailsPage & WithT
<>
<h3 className="mt-4">{t('accession.details.collSite')}</h3>
<Property title={ t('accession.coll.collSite') } value={ details.coll.collSite } index={ propertyIndex++ }/>
<Property title={ t('accession.coll.collSrc') } value={ t(`accession.collectingSource.${details.coll.collSrc}`) } index={ propertyIndex++ }/>
<Property title={ t('accession.coll.collDate') } value={ details.coll.collDate } index={ propertyIndex++ }/>
<Property title={ t('accession.coll.collMissId') } value={ details.coll.collMissId } index={ propertyIndex++ }/>
<Property title={ t('accession.coll.collCode') } value={ details.coll.collCode } index={ propertyIndex++ }/>
......@@ -251,7 +262,7 @@ class AccessionDetailsPage extends React.Component<IAccessionDetailsPage & WithT
</>
}
{ accession.subsets && accession.subsets.length > 0 &&
{ appConfig.accession.subsets && accession.subsets && accession.subsets.length > 0 &&
<>
<h2 className="mt-4">{ t('accession.subsets') }</h2>
{ accession.subsets.map((subset, idx) => (
......@@ -263,7 +274,7 @@ class AccessionDetailsPage extends React.Component<IAccessionDetailsPage & WithT
</>
}
{ accession.datasets && accession.datasets.length > 0 &&
{ appConfig.accession.datasets && accession.datasets && accession.datasets.length > 0 &&
<>
<h2 className="mt-4">{ t('accession.datasets') }</h2>
{ accession.datasets.map((dataset, idx) => (
......@@ -275,7 +286,7 @@ class AccessionDetailsPage extends React.Component<IAccessionDetailsPage & WithT
</>
}
{ pdci && <PdciTable pdci={ pdci } title={ t('accession.details.pdci') }/> }
{ appConfig.accession.pdci && pdci && <PdciTable pdci={ pdci } title={ t('accession.details.pdci') }/> }
<h2 className="mt-4">{ t('accession.details.metadata') }</h2>
<Property title={ t('accession.details.uuid') } value={ `urn:uuid:${details.uuid}` } index={ propertyIndex++ }/>
......@@ -285,28 +296,11 @@ class AccessionDetailsPage extends React.Component<IAccessionDetailsPage & WithT
</a> } index={ propertyIndex++ }/>
{
details.lastModifiedDate &&
<Property title={ t('accession.details.lastUpdated') } value={ details.lastModifiedDate.toLocaleString() } index={ propertyIndex++ }/>
<Property title={ t('accession.details.lastUpdated') } value={ new Date(details.lastModifiedDate).toLocaleString() } index={ propertyIndex++ }/>
}
{
details.createdDate &&
<Property title={ t('accession.details.created') } value={ details.createdDate.toLocaleString() } index={ propertyIndex++ }/>
}
{ shoppingCart.enabled &&
<div className="pt-4">
{ cartItems.includes(this.props.match.params.uuid) ?
<button
type="button"
name={ `button-remove-${accession.details.uuid}` }
data-uuid={ accession.details.uuid }
className="btn btn-primary"
onClick={ this.removeFromCart }
>
{ t('cart.removeFromCart') }
</button>
:
this.renderAddToCart()
}
</div>
<Property title={ t('accession.details.created') } value={ new Date(details.createdDate).toLocaleString() } index={ propertyIndex++ }/>
}
</>
);
......
......@@ -203,7 +203,7 @@ class AccessionListPage extends React.Component<IAccessionListPageProps & WithTr
<th>{ t('accession.crop') }</th>
<th>{ t('accession.acceNumb') }</th>
<th>{ t('accession.accessionName') }</th>
<th>{ t('accession.taxonomy') }</th>
<th>{ t('accession.taxonomy.scientificName') }</th>
<th>{ t('accession.countryOfOrigin') }</th>
<th>{ t('accession.sampStat') }</th>
{ shoppingCart.enabled && ( <th>{ t('list.availability') }</th> ) }
......
......@@ -10,7 +10,7 @@ export class Config {
// module config
public language?: string = 'en';
public accession?: BaseFeatureConfig;
public accession?: AccessionConfig;
public shoppingCart?: BaseFeatureConfig;
public constructor(config: Config) {
......@@ -28,13 +28,26 @@ export class Config {
}
export class BaseFeatureConfig {
public enabled: boolean;
public enabled?: boolean;
}
class AccessionConfig extends BaseFeatureConfig {
public pdci?: boolean;
public subsets?: boolean;
public datasets?: boolean;
}
export const defaultConfig: Partial<Config> = {
apiUrl: 'https://api.sandbox.genesys-pgr.org',
filter: {},
language: 'en',
accession: { enabled: true },
shoppingCart: { enabled: false },
accession: {
enabled: true,
pdci: true,
datasets: true,
subsets: true,
},
shoppingCart: {
enabled: false,
},
};
......@@ -36,7 +36,7 @@
"genusSpecies": "Species",
"subtaxa": "Subtaxon",
"synonyms": "Synonyms",
"grinTaxonName": "GRIN taxon",
"grinTaxonName": "Matched GRIN taxon",
"grinCurrentName": "Current GRIN taxon"
},
"holdingInstitute": "Holding institute",
......@@ -49,13 +49,11 @@
"datasets": "Datasets",
"subsets": "Subsets",
"details": {
"providedTaxonomy": "Taxonomy provided to Genesys",
"providedTaxonomy": "Taxonomy",
"metadata": "Metadata",
"collSite": "Collecting site",
"geo": "Georeference",
"images": "Images",
"grinTaxonomy": "GRIN Taxonomy",
"currentTaxonomy": "Current GRIN Taxon",
"uuid": "UUID",
"permanentURL": "Permanent URL",
"lastUpdated": "Last updated",
......
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