-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from Inist-CNRS/format
[RFR] Formats
- Loading branch information
Showing
56 changed files
with
616 additions
and
63 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
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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import branch from 'recompose/branch'; | ||
import renderComponent from 'recompose/renderComponent'; | ||
|
||
import UriColumn from './UriColumn'; | ||
import DefaultColumn from './DefaultColumn'; | ||
|
||
export default branch( | ||
props => props.column.name === 'uri', | ||
renderComponent(UriColumn), | ||
)(DefaultColumn); |
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 |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React, { Component, PropTypes } from 'react'; | ||
import { connect } from 'react-redux'; | ||
import compose from 'recompose/compose'; | ||
import withHandlers from 'recompose/withHandlers'; | ||
import withState from 'recompose/withState'; | ||
|
||
import { TableRowColumn } from 'material-ui/Table'; | ||
import Format from '../formats/Format'; | ||
import fetchByUri from '../lib/fetchByUri'; | ||
import { getToken } from '../user'; | ||
import { field as fieldPropTypes } from '../propTypes'; | ||
|
||
export class DatasetColumnComponent extends Component { | ||
componentWillMount() { | ||
const { column, resource } = this.props; | ||
const linkTransformer = column.transformers && column.transformers.find(t => t.operation === 'LINK'); | ||
if (linkTransformer) { | ||
const uri = resource[linkTransformer.args.find(a => a.name === 'reference').value]; | ||
this.props.fetchLinkedResource(uri); | ||
} | ||
} | ||
|
||
render() { | ||
const { column, columns, linkedResource, resource } = this.props; | ||
|
||
return ( | ||
<TableRowColumn className={`dataset-${column.name}`}> | ||
<Format | ||
field={column} | ||
fields={columns} | ||
linkedResource={linkedResource} | ||
resource={resource} | ||
/> | ||
</TableRowColumn> | ||
); | ||
} | ||
} | ||
|
||
DatasetColumnComponent.propTypes = { | ||
column: fieldPropTypes.isRequired, | ||
columns: PropTypes.arrayOf(fieldPropTypes).isRequired, | ||
fetchLinkedResource: PropTypes.func.isRequired, | ||
linkedResource: PropTypes.object, // eslint-disable-line | ||
resource: PropTypes.object.isRequired, // eslint-disable-line | ||
}; | ||
|
||
const mapStateToProps = state => ({ | ||
token: getToken(state), | ||
}); | ||
|
||
export default compose( | ||
connect(mapStateToProps), | ||
withState('linkedResource', 'setLinkedResource', null), | ||
withHandlers({ | ||
fetchLinkedResource: ({ setLinkedResource, token }) => uri => | ||
fetchByUri(uri, token) | ||
.then((linkedResource) => { | ||
setLinkedResource(linkedResource); | ||
}), | ||
}), | ||
)(DatasetColumnComponent); | ||
|
Oops, something went wrong.