Ver código fonte

don’t set metadata values for new files in Dashboard, use uppy.opts.meta instead

Artur Paikin 7 anos atrás
pai
commit
9aa3e00411

+ 8 - 8
examples/bundled-example/main.js

@@ -20,7 +20,8 @@ const uppy = Uppy({
   debug: true,
   autoProceed: false,
   meta: {
-    username: 'John'
+    username: 'John',
+    license: 'Creative Commons'
   }
   // restrictions: {
   //   maxFileSize: 300000,
@@ -47,19 +48,18 @@ const uppy = Uppy({
     // maxWidth: 350,
     // maxHeight: 400,
     inline: false,
-    // disableStatusBar: true,
-    // disableInformer: true,
+    disableStatusBar: false,
+    disableInformer: false,
     getMetaFromForm: true,
-    // replaceTargetContent: true,
-    // target: '.MyForm',
+    replaceTargetContent: false,
     hideUploadButton: false,
     closeModalOnClickOutside: false,
     locale: {
-      strings: {browse: 'browse'}
+      strings: { browse: 'browse' }
     },
     metaFields: [
-      { id: 'license', name: 'License', value: 'Creative Commons', placeholder: 'specify license' },
-      { id: 'caption', name: 'Caption', value: '', placeholder: 'describe what the image is about' }
+      { id: 'license', name: 'License', placeholder: 'specify license' },
+      { id: 'caption', name: 'Caption', placeholder: 'describe what the image is about' }
     ]
     // note: 'Images and video only, 300kb or less'
   })

+ 1 - 1
src/plugins/Dashboard/FileCard.js

@@ -27,7 +27,7 @@ module.exports = function fileCard (props) {
         <input class="UppyDashboardFileCard-input"
                type="text"
                data-name="${field.id}"
-               value="${file.meta[field.id]}"
+               value="${file.meta[field.id] || ''}"
                placeholder="${field.placeholder || ''}"
                onkeyup=${tempStoreMetaOrSubmit}
                onkeydown=${tempStoreMetaOrSubmit}

+ 0 - 13
src/plugins/Dashboard/index.js

@@ -99,7 +99,6 @@ module.exports = class DashboardUI extends Plugin {
     this.getFocusableNodes = this.getFocusableNodes.bind(this)
     this.setFocusToFirstNode = this.setFocusToFirstNode.bind(this)
     this.maintainFocus = this.maintainFocus.bind(this)
-    this.addDashboardMetaToNewFile = this.addDashboardMetaToNewFile.bind(this)
 
     this.initEvents = this.initEvents.bind(this)
     this.onKeydown = this.onKeydown.bind(this)
@@ -262,7 +261,6 @@ module.exports = class DashboardUI extends Plugin {
     })
 
     this.uppy.on('dashboard:file-card', this.handleFileCard)
-    this.uppy.on('file-added', this.addDashboardMetaToNewFile)
 
     window.addEventListener('resize', this.updateDashboardElWidth)
   }
@@ -280,21 +278,10 @@ module.exports = class DashboardUI extends Plugin {
     this.removeDragDropListener()
 
     this.uppy.off('dashboard:file-card', this.handleFileCard)
-    this.uppy.off('file-added', this.addDashboardMetaToNewFile)
 
     window.removeEventListener('resize', this.updateDashboardElWidth)
   }
 
-  addDashboardMetaToNewFile (file) {
-    const metaFields = this.opts.metaFields
-
-    metaFields.forEach((item) => {
-      const obj = {}
-      obj[item.id] = item.value
-      this.uppy.setFileMeta(file.id, obj)
-    })
-  }
-
   updateDashboardElWidth () {
     const dashboardEl = this.el.querySelector('.UppyDashboard-inner')
     this.uppy.log(`Dashboard width: ${dashboardEl.offsetWidth}`)

+ 1 - 1
src/scss/_dashboard.scss

@@ -106,7 +106,7 @@
   }
 
   .UppyDashboard--modal & {
-    z-index: $zIndex-4;
+    z-index: $zIndex-5;
     display: block;
   }
 }