forked from zotero/zoterobib
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
89 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,54 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import Button from './ui/button'; | ||
import { formatBib } from '../cite'; | ||
|
||
class Review extends React.PureComponent { | ||
handleDismiss() { | ||
this.props.onReviewDismiss(); | ||
} | ||
|
||
handleDelete() { | ||
this.props.onReviewDelete(); | ||
} | ||
|
||
handleEdit() { | ||
this.props.onReviewEdit(); | ||
} | ||
|
||
render() { | ||
if(this.props.isTranslating) { | ||
return ( | ||
<section className="section section-review review"> | ||
<h2>New item…</h2> | ||
</section> | ||
); | ||
} | ||
|
||
if(!this.props.itemUnderReviewBibliography) { | ||
return null; | ||
} | ||
|
||
const { citations, bibliography, isFallback } = this.props.itemUnderReviewBibliography; | ||
const html = isFallback ? | ||
`<ol><li>${citations.join('</li><li>')}</li></ol>` : | ||
formatBib(bibliography); | ||
const div = document.createElement('div'); | ||
div.innerHTML = html; | ||
return ( | ||
<section className="section section-review review"> | ||
<h2 className="sr-only">New item …</h2> | ||
<div className="container"> | ||
<div | ||
dangerouslySetInnerHTML={ { __html: div.innerHTML } } | ||
/> | ||
<div className="actions"> | ||
<Button | ||
className="btn-outline-secondary btn-min-width" | ||
onClick={ this.handleDismiss.bind(this) } | ||
> | ||
Close | ||
</Button> | ||
<Button | ||
className="btn-outline-secondary btn-min-width" | ||
onClick={ this.handleDelete.bind(this) } | ||
> | ||
Delete | ||
</Button> | ||
<Button | ||
className="btn-secondary btn-min-width" | ||
onClick={ this.handleEdit.bind(this) } | ||
> | ||
Edit | ||
</Button> | ||
</div> | ||
import { formatBib, formatFallback } from '../cite'; | ||
|
||
const Review = ({ isTranslating, itemUnderReview, onReviewEdit, onReviewDelete, onReviewDismiss, styleHasBibliography }) => { | ||
const { bibliographyItems, bibliographyMeta } = itemUnderReview; | ||
const html = styleHasBibliography ? formatBib(bibliographyItems, bibliographyMeta) : formatFallback(bibliographyItems); | ||
console.log({ html, bibliographyItems, bibliographyMeta }); | ||
|
||
return isTranslating ? ( | ||
<section className="section section-review review"> | ||
<h2>New item…</h2> | ||
</section> | ||
) : ( | ||
<section className="section section-review review"> | ||
<h2 className="sr-only">New item …</h2> | ||
<div className="container"> | ||
<div dangerouslySetInnerHTML={ { __html: html } } /> | ||
<div className="actions"> | ||
<Button | ||
className="btn-outline-secondary btn-min-width" | ||
onClick={ onReviewDismiss } | ||
> | ||
Close | ||
</Button> | ||
<Button | ||
className="btn-outline-secondary btn-min-width" | ||
onClick={ onReviewDelete } | ||
> | ||
Delete | ||
</Button> | ||
<Button | ||
className="btn-secondary btn-min-width" | ||
onClick={ onReviewEdit } | ||
> | ||
Edit | ||
</Button> | ||
</div> | ||
</section> | ||
); | ||
} | ||
</div> | ||
</section> | ||
); | ||
} | ||
|
||
static propTypes = { | ||
isTranslating: PropTypes.bool, | ||
itemUnderReviewBibliography: PropTypes.object, | ||
onReviewDelete: PropTypes.func.isRequired, | ||
onReviewDismiss: PropTypes.func.isRequired, | ||
onReviewEdit: PropTypes.func.isRequired, | ||
} | ||
Review.propTypes = { | ||
isTranslating: PropTypes.bool, | ||
itemUnderReview: PropTypes.object, | ||
onReviewDelete: PropTypes.func.isRequired, | ||
onReviewDismiss: PropTypes.func.isRequired, | ||
onReviewEdit: PropTypes.func.isRequired, | ||
styleHasBibliography: PropTypes.bool, | ||
} | ||
|
||
export default Review; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters