diff --git a/src/core/Core.js b/src/core/Core.js
index 4e3b121ce..aa380afb9 100644
--- a/src/core/Core.js
+++ b/src/core/Core.js
@@ -72,6 +72,7 @@ class Uppy {
this.initSocket = this.initSocket.bind(this)
this.log = this.log.bind(this)
this.addFile = this.addFile.bind(this)
+ this.removeFile = this.removeFile.bind(this)
this.calculateProgress = this.calculateProgress.bind(this)
this.resetProgress = this.resetProgress.bind(this)
diff --git a/src/plugins/Dashboard/FileCard.js b/src/plugins/Dashboard/FileCard.js
index 4ff7daf29..51602b8b4 100644
--- a/src/plugins/Dashboard/FileCard.js
+++ b/src/plugins/Dashboard/FileCard.js
@@ -6,7 +6,11 @@ module.exports = function fileCard (props) {
const file = props.fileCardFor ? props.files[props.fileCardFor] : false
const meta = {}
- function tempStoreMeta (ev) {
+ const tempStoreMetaOrSubmit = (ev) => {
+ if (ev.keyCode === 13) {
+ props.done(meta, file.id)
+ }
+
const value = ev.target.value
const name = ev.target.dataset.name
meta[name] = value
@@ -22,7 +26,7 @@ module.exports = function fileCard (props) {
data-name="${field.id}"
value="${file.meta[field.id]}"
placeholder="${field.placeholder || ''}"
- onkeyup=${tempStoreMeta} />`
+ onkeyup=${tempStoreMetaOrSubmit} />`
})
}
@@ -46,8 +50,8 @@ module.exports = function fileCard (props) {
${renderMetaFields(file)}
@@ -60,5 +64,5 @@ module.exports = function fileCard (props) {
title="Finish editing file"
onclick=${() => props.done(meta, file.id)}>${checkIcon()}
- `
+ `
}
diff --git a/src/plugins/Dashboard/index.js b/src/plugins/Dashboard/index.js
index 086918eb6..afe8eb09e 100644
--- a/src/plugins/Dashboard/index.js
+++ b/src/plugins/Dashboard/index.js
@@ -249,7 +249,7 @@ module.exports = class DashboardUI extends Plugin {
}
handleFileCard (fileId) {
- const modal = this.core.getState().modal
+ const modal = this.core.state.modal
this.core.setState({
modal: Object.assign({}, modal, {
@@ -318,44 +318,36 @@ module.exports = class DashboardUI extends Plugin {
return target.type === 'progressindicator'
})
- // const addFile = (file) => {
- // this.core.emitter.emit('core:file-add', file)
- // }
-
- const removeFile = (fileID) => {
- this.core.emitter.emit('core:file-remove', fileID)
- }
-
const startUpload = (ev) => {
this.core.upload().catch((err) => {
// Log error.
- console.error(err.stack || err.message || err)
+ this.core.log(err.stack || err.message || err)
})
}
const pauseUpload = (fileID) => {
- this.core.emitter.emit('core:upload-pause', fileID)
+ this.core.emit.emit('core:upload-pause', fileID)
}
const cancelUpload = (fileID) => {
- this.core.emitter.emit('core:upload-cancel', fileID)
- this.core.emitter.emit('core:file-remove', fileID)
+ this.core.emit('core:upload-cancel', fileID)
+ this.core.emit('core:file-remove', fileID)
}
const showFileCard = (fileID) => {
- this.core.emitter.emit('dashboard:file-card', fileID)
+ this.core.emit('dashboard:file-card', fileID)
}
const fileCardDone = (meta, fileID) => {
- this.core.emitter.emit('core:update-meta', meta, fileID)
- this.core.emitter.emit('dashboard:file-card')
+ this.core.emit('core:update-meta', meta, fileID)
+ this.core.emit('dashboard:file-card')
}
const info = (text, type, duration) => {
this.core.info(text, type, duration)
}
- const resumableUploads = this.core.getState().capabilities.resumableUploads || false
+ const resumableUploads = this.core.state.capabilities.resumableUploads || false
return Dashboard({
state: state,
@@ -382,7 +374,7 @@ module.exports = class DashboardUI extends Plugin {
pauseAll: this.pauseAll,
resumeAll: this.resumeAll,
addFile: this.core.addFile,
- removeFile: removeFile,
+ removeFile: this.core.removeFile,
info: info,
note: this.opts.note,
metaFields: state.metaFields,