handle unsupported file types
This commit is contained in:
@@ -76,6 +76,7 @@ window.customElements.define('template-builder', class extends HTMLElement {
|
||||
template: reactive(JSON.parse(this.dataset.template)),
|
||||
backgroundColor: '#faf7f5',
|
||||
withPhone: this.dataset.withPhone === 'true',
|
||||
acceptFileTypes: this.dataset.acceptFileTypes,
|
||||
isDirectUpload: this.dataset.isDirectUpload === 'true'
|
||||
})
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@
|
||||
:with-arrows="template.schema.length > 1"
|
||||
:item="item"
|
||||
:document="sortedDocuments[index]"
|
||||
:accept-file-types="acceptFileTypes"
|
||||
:template="template"
|
||||
:is-direct-upload="isDirectUpload"
|
||||
@scroll-to="scrollIntoDocument(item)"
|
||||
@@ -90,6 +91,7 @@
|
||||
>
|
||||
<Upload
|
||||
v-if="sortedDocuments.length"
|
||||
:accept-file-types="acceptFileTypes"
|
||||
:template-id="template.id"
|
||||
:is-direct-upload="isDirectUpload"
|
||||
@success="updateFromUpload"
|
||||
@@ -104,6 +106,7 @@
|
||||
<Dropzone
|
||||
v-if="!sortedDocuments.length"
|
||||
:template-id="template.id"
|
||||
:accept-file-types="acceptFileTypes"
|
||||
:is-direct-upload="isDirectUpload"
|
||||
@success="updateFromUpload"
|
||||
/>
|
||||
@@ -256,6 +259,11 @@ export default {
|
||||
required: false,
|
||||
default: ''
|
||||
},
|
||||
acceptFileTypes: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: 'image/*, application/pdf'
|
||||
},
|
||||
baseUrl: {
|
||||
type: String,
|
||||
required: false,
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
ref="input"
|
||||
type="file"
|
||||
name="files[]"
|
||||
accept="image/*, application/pdf"
|
||||
:accept="acceptFileTypes"
|
||||
multiple
|
||||
@change="upload"
|
||||
>
|
||||
@@ -67,6 +67,11 @@ export default {
|
||||
type: [Number, String],
|
||||
required: true
|
||||
},
|
||||
acceptFileTypes: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: 'image/*, application/pdf'
|
||||
},
|
||||
isDirectUpload: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
@@ -89,8 +94,10 @@ export default {
|
||||
return 'Uploading...'
|
||||
} else if (this.isProcessing) {
|
||||
return 'Processing...'
|
||||
} else {
|
||||
} else if (this.acceptFileTypes === 'image/*, application/pdf') {
|
||||
return 'Add PDF documents or images'
|
||||
} else {
|
||||
return 'Add documents or images'
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -102,7 +109,7 @@ export default {
|
||||
methods: {
|
||||
upload: Upload.methods.upload,
|
||||
onDropFiles (e) {
|
||||
if ([...e.dataTransfer.files].every((f) => f.type.match(/(?:image\/)|(?:application\/pdf)/))) {
|
||||
if (this.acceptFileTypes !== 'image/*, application/pdf' || [...e.dataTransfer.files].every((f) => f.type.match(/(?:image\/)|(?:application\/pdf)/))) {
|
||||
this.$refs.input.files = e.dataTransfer.files
|
||||
|
||||
this.upload()
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<ReplaceButton
|
||||
:is-direct-upload="isDirectUpload"
|
||||
:template-id="template.id"
|
||||
:accept-file-types="acceptFileTypes"
|
||||
class="opacity-0 group-hover:opacity-100"
|
||||
@click.stop
|
||||
@success="$emit('replace', { replaceSchemaItem: item, ...$event })"
|
||||
@@ -94,6 +95,11 @@ export default {
|
||||
type: Object,
|
||||
required: true
|
||||
},
|
||||
acceptFileTypes: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: 'image/*, application/pdf'
|
||||
},
|
||||
isDirectUpload: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
ref="input"
|
||||
name="files[]"
|
||||
type="file"
|
||||
accept="image/*, application/pdf"
|
||||
:accept="acceptFileTypes"
|
||||
@change="upload"
|
||||
>
|
||||
</form>
|
||||
@@ -32,6 +32,11 @@ export default {
|
||||
type: [Number, String],
|
||||
required: true
|
||||
},
|
||||
acceptFileTypes: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: 'image/*, application/pdf'
|
||||
},
|
||||
isDirectUpload: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
ref="input"
|
||||
name="files[]"
|
||||
type="file"
|
||||
accept="image/*, application/pdf"
|
||||
:accept="acceptFileTypes"
|
||||
multiple
|
||||
@change="upload"
|
||||
>
|
||||
@@ -56,6 +56,11 @@ export default {
|
||||
type: [Number, String],
|
||||
required: true
|
||||
},
|
||||
acceptFileTypes: {
|
||||
type: String,
|
||||
required: false,
|
||||
default: 'image/*, application/pdf'
|
||||
},
|
||||
isDirectUpload: {
|
||||
type: Boolean,
|
||||
required: true,
|
||||
|
||||
Reference in New Issue
Block a user