summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-06-02 14:11:08 +0200
committerJules Laplace <julescarbon@gmail.com>2018-06-02 14:11:08 +0200
commit99d4bf6eb37214a01d5301cdc7b969bcd760cec9 (patch)
treefcca1b8d810b896c75b81b7a3acb3e00b67ee9ca /app
parent015c9b3e7ec8b20308fc604d925a6e9c188aa42e (diff)
curry actions in the dataset component
Diffstat (limited to 'app')
-rw-r--r--app/client/dataset/dataset.component.js34
1 files changed, 9 insertions, 25 deletions
diff --git a/app/client/dataset/dataset.component.js b/app/client/dataset/dataset.component.js
index ebea8c9..f7ffbc5 100644
--- a/app/client/dataset/dataset.component.js
+++ b/app/client/dataset/dataset.component.js
@@ -13,26 +13,6 @@ import TextInput from '../common/textInput.component'
class Dataset extends Component {
constructor(props){
super()
- this.handleName = this.handleName.bind(this)
- this.handleUpload = this.handleUpload.bind(this)
- this.handleURL = this.handleURL.bind(this)
- this.pickFile = this.pickFile.bind(this)
- }
- handleName(name) {
- const { module, folder, actions } = this.props
- actions.dataset.createOrUpdateFolder(module, folder)
- }
- handleUpload(file) {
- const { module, folder, actions } = this.props
- actions.dataset.uploadFile(module, folder, file)
- }
- handleURL(url) {
- const { module, folder, actions } = this.props
- actions.dataset.fetchURL(module, folder, url)
- }
- pickFile(file){
- console.log('pick', file)
- this.props.onPick && this.props.onPick(file)
}
render(){
const {
@@ -40,7 +20,7 @@ class Dataset extends Component {
module, title, folder, files,
canRename, canUpload, canAddURL, canDeleteFile,
linkFiles,
- fileOptions, pickFile
+ fileOptions, pickFile, onPick
} = this.props
// sort files??
return (
@@ -61,7 +41,7 @@ class Dataset extends Component {
title='Files'
files={files}
options={fileOptions}
- onClick={pickFile}
+ onClick={() => onPick && onPick(file)}
canDelete={canDeleteFile}
linkFiles={linkFiles}
/>
@@ -69,25 +49,29 @@ class Dataset extends Component {
</div>
)
}
+ curry(action) {
+ const { module, folder} = this.props
+ return (param) => action(module, folder, param)
+ }
renderFolderNameInput(name){
return <TextInput
title='Dataset name'
value={name}
- onSave={this.handleName}
+ onSave={this.curry(this.props.actions.dataset.createOrUpdateFolder)}
/>
}
renderUploadInput(){
return <FileUpload
title='Upload a file'
mime='image.*'
- onUpload={this.handleUpload}
+ onUpload={this.curry(this.props.actions.dataset.uploadFile)}
/>
}
renderURLInput(){
return <TextInput
title='Fetch a URL'
placeholder='http://'
- onSave={this.handleURL}
+ onSave={this.curry(this.props.actions.dataset.handleURL)}
/>
}
}