Created
March 6, 2018 18:37
-
-
Save colonelrascals/9a3abdf4e379185390e9a11e03548e96 to your computer and use it in GitHub Desktop.
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
export default class ResourcePanel extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
isBookmark: !_.isEmpty(props.data.bookmark), | |
inPrintQueue: false, // we assume not because we don't map this onto data model currently... | |
shareModalOpen: false, | |
correctModalOpen: false, | |
hasPdf: false | |
}; | |
} | |
deleteBookmark(evt) { | |
bookmarkRequest('delete', this.props.data.id, this.props.csrf).then((success, err) => { | |
this.setState({ isBookmark: false, note: '' }); | |
}); | |
} | |
createBookmark(evt) { | |
console.log(this) | |
bookmarkRequest('post', this.props.data.id, this.props.csrf) | |
.then((success, err) => { | |
this.setState({ isBookmark: true }); | |
}) | |
} | |
render() { | |
const { data, showContact, fullyExpanded, currentUser } = this.props; | |
const { isBookmark } = this.state; | |
return ( | |
<div className="panel panel-default"> | |
<div className="panel-body"> | |
<div> | |
<span className="pull-right"> | |
{[ | |
<PrintIcon key="printBtn" resourceId={data.id} csrf={this.props.csrf} />, | |
<PdfIcon key = 'pdfBtn' resourceId={data.id} csrf={this.props.csrf} />, | |
<OverlayTrigger | |
key="shareBtn" | |
placement="top" | |
overlay={ | |
<Tooltip id={`tooltip-share-resource-${data.id}`}>Share Resource</Tooltip> | |
}> | |
<button | |
className="btn pull-right resource-panel-button" | |
onClick={() => this.setState({ shareModalOpen: true })}> | |
<i className="fa fa-share-alt" aria-hidden="true" /> | |
</button> | |
</OverlayTrigger>, | |
<OverlayTrigger | |
key="reportIssueBtn" | |
placement="top" | |
overlay={<Tooltip id={`tooltip-report-issue-${data.id}`}>Report Issue</Tooltip>}> | |
<button | |
className="btn pull-right resource-panel-button" | |
onClick={() => this.setState({ correctModalOpen: true })}> | |
<i className="fa fa-flag" aria-hidden="true" /> | |
</button> | |
</OverlayTrigger>,, | |
isBookmark ? ( | |
<DeleteBookmark | |
id={data.id} | |
key="deleteBookmarkBtn" | |
deleteBookmark={(evt) => this.deleteBookmark(evt)} | |
/> | |
) : ( | |
<CreateBookmark | |
id={data.id} | |
key="createBookmarkBtn" | |
createBookmark={(evt) => this.createBookmark(evt)} | |
/> | |
) | |
]} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment