Page MenuHomec4science

TermCard.js
No OneTemporary

File Metadata

Created
Thu, Jun 6, 17:29

TermCard.js

/*
This is the Open Access Compliance Check Tool (OACCT).
The publication of scientific articles as Open Access (OA), usually in the variants "Green OA" and "Gold OA", allows free access to scientific research results and their largely unhindered dissemination. Often, however, the multitude of available publication conditions makes the decision in favor of a particular journal difficult: requirements of the funding agencies and publication guidelines of the universities and colleges must be carefully compared with the offers of the publishing houses, and separately concluded publication agreements can also offer additional benefits. The "OA Compliance Check Tool" provides a comprehensive overview of the possible publication conditions for a large number of journals, especially for the Swiss university landscape, and thus supports the decision-making process.
© All rights reserved. ECOLE POLYTECHNIQUE FEDERALE DE LAUSANNE, Switzerland, Scientific Information and Libraries, 2022
See LICENSE.TXT for more details.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License along with this program. If not, see
<https://www.gnu.org/licenses/>.
*/
import React, {useState, useContext, useEffect} from "react"
import {Context} from "../ContextProvider"
import { makeStyles } from '@material-ui/core/styles';
import "./termcard.css"
import Chip from '@material-ui/core/Chip';
import DoneIcon from '@material-ui/icons/Done';
import HighlightOffIcon from '@material-ui/icons/HighlightOff';
import Typography from '@material-ui/core/Typography';
import DateRangeIcon from '@material-ui/icons/DateRange';
import { FaCoins, FaRegHandshake, FaUserGraduate } from 'react-icons/fa';
import { RiFilePaper2Line } from 'react-icons/ri';
import Button from '@material-ui/core/Button';
import { HiLink } from "react-icons/hi";
import { GrInfo } from "react-icons/gr";
import Container from '@material-ui/core/Container'
import Grid from '@material-ui/core/Grid'
import Card from '@material-ui/core/Card';
import CardActions from '@material-ui/core/CardActions';
import CardContent from '@material-ui/core/CardContent';
import Tooltip from '@material-ui/core/Tooltip';
import { BsNewspaper } from 'react-icons/bs';
import { FiFlag } from 'react-icons/fi';
const useStyles = makeStyles((theme) =>({
card: {
width: '100%',
marginTop: "1rem",
textAlign:'left'
},
root: {
flexGrow: 1,
textAlign:'left',
},
chip: {
margin: 0.5,
},
heading: {
fontSize: theme.typography.pxToRem(15),
fontWeight: theme.typography.fontWeightRegular,
},
}))
const IDConditionTypeJournal = 3;
const IDConditionTypeOrganization = 1;
const IDConditionTypeAgreement = 2;
export default function TermCard({term}) {
const classes = useStyles();
//call the custom hook to share the state between different level componant
const {url} = useContext(Context)
const [ref, setRef] = useState("")
console.log(ref)
useEffect(() => {
// ## Update ref term by creating a specific Reference based on the Condition set ID = C and Term.id = T
setRef(
term.map( j=> (
j[0] &&
`C${j[0]}/T${term[0].id}`
))
)
},[]); // render once
function handleClick () {
// ## Create mail template to report a modification, contain the actual Url and the reference Term Card
window.open(`mailto:publishsupport@epfl.ch?subject= OACCT Modification request for ${encodeURIComponent(url)} Term Card Reference: ${ref[1]} &body=Request Description:`)
}
console.log(`cost factor data: ${term[0].cost_factor[0].cost_factor_type.name}`)
const licenceIcon =
term[0].licence?.map(i=>(
<>
{ (i.name_or_abbrev != 'UNKNOWN') ?
<Tooltip disableFocusListener title="To learn more about licence" arrow>
<Button href={i.website} target="blank" rel="noopener noreferrer" size="small">
<Chip
size="small"
avatar={ <RiFilePaper2Line />}
label={i.name_or_abbrev}
// clickable={handleClick}
// color="secondary"
// onDelete={handleDelete}
className={classes.chip}
style={{ background: "#FFFFFF", textAlign: "left"}}
// title="Licence Information"
/>
</Button>
</Tooltip>
: <Tooltip disableFocusListener title="To learn more about licence" arrow>
<Button href={i.website} target="blank" rel="noopener noreferrer" size="small">
<Chip
size="small"
avatar={ <RiFilePaper2Line />}
label={'No licence guidelines'}
// clickable={handleClick}
// color="secondary"
// onDelete={handleDelete}
className={classes.chip}
style={{ background: "#FFFFFF", textAlign: "left"}}
// title="Licence Information"
/>
</Button>
</Tooltip>
}
</>
))
const cost = term[0].cost_factor?.map( i => (
<>
{ (i.cost_factor_type.name != 'UNKNOWN') ?
<Tooltip disableFocusListener title={i.comment} arrow>
<Button>
<Chip
key={i.cost_factor_type.id}
size="small"
avatar={ <FaCoins />}
label={i.cost_factor_type.name + " : " + i.amount + " " + i.symbol}
// clickable={handleClick}
// color="secondary"
// onDelete={handleDelete}
className={classes.chip}
style={{ background: "#FFFFFF"}}
// title={i.comment}
/>
</Button>
</Tooltip>
: null
}
</>
))
const termArchive = term[0].ir_archiving && term[0].ir_archiving ? (
<Chip
size="small"
avatar={<DoneIcon />}
label={"Upload to institutional repository"}
// variant="outlined"
// clickable={handleClick}
// color="secondary"
// onDelete={handleDelete}
style={{ background: "#DAF7A6"}}
// title="This is more information"
/>
): (
<Chip
size="small"
avatar={<HighlightOffIcon />}
label="Upload to institutional repository"
// clickable={handleClick}
// color="secondary"
// onDelete={handleDelete}
style={{ background: "#f50057"}}
// title="This is more information"
/>
)
const embargo = ( term[0].embargo_months != null ?
<Chip
size="small"
avatar={<DateRangeIcon />}
label={ ("Embargo: " + term[0].embargo_months + " Month(s)") }
// variant="outlined"
// clickable={handleClick}
// color="secondary"
// onDelete={handleDelete}
style={{ background: "#FFFFFF"}}
// title="This is more information"
/>
: null
)
return (
<div>
<Card key={term.id} className="term-Card"
style={{ textAlign: "left"}}
>
<CardContent>
<Typography className={classes.title} color="textSecondary" gutterBottom>
{term.map( j=> (
j[0] &&
<>
<p>{j[2].id === IDConditionTypeJournal &&
<BsNewspaper />}
{j[2].id === IDConditionTypeAgreement &&
<FaRegHandshake />}
{j[2].id === IDConditionTypeOrganization &&
<FaUserGraduate />} {j[2].condition_issuer}
{j[1] ?
<h5>{j[1]}</h5> : ''}</p>
<p>
{ j[3] &&
<Button href={j[3]} target="blank" rel="noopener noreferrer" size="small"><HiLink/>Source</Button>
}
</p>
</>
))
}
</Typography>
<Typography variant="h5" component="h2">
</Typography>
<Typography className={classes.pos} color="textSecondary">
</Typography>
<Typography variant="body2" component="p">
<Container maxWidth="xs" >
<Grid container>
<Grid item xs={6} sm={2}>
{/* filter Unknow cost factor type to not display */}
{cost}
{licenceIcon}
{termArchive}
{embargo}
</Grid>
</Grid>
</Container>
<div
style={{ marginTop: "1rem"}}
>
{term[0].comment ?
<div style={{ textAlign: "left"}}>
<p>
<small>
<GrInfo
style={{
padding: "0.05rem"
}}
/>
{term[0].comment}
</small>
</p>
</div>
:null}
</div>
<div style={{textAlign: 'right'}}>
{term.map( j=> (
j[0] &&
<small><small>C{j[0]}/T{term[0].id}</small></small>
))
}
</div>
</Typography>
</CardContent>
<CardActions>
{term[0].source ?
<Button href={term[0].source} target="blank" rel="noopener noreferrer" size="small">
<i style={{fontSize: "70%"}}>
<HiLink/> More Information
</i>
</Button>
:null}
<Button onClick={handleClick} variant="outlined" color="secondary" size="small" ><FiFlag/>
<i style={{fontSize: "70%"}}>
Modification Request
</i>
</Button>
</CardActions>
</Card>
</div>
)
}

Event Timeline