Commit 94ded04e authored by anton's avatar anton
Browse files

Add type 'file' field

parent fe6fecc4
<template lang="pug">
q-input(v-if="type === 'hidden'", :type="type", v-model="local")
q-field(v-else, :dark="true", :label="fieldLabel", :error="validation ? validation.$error : undefined",
:error-label="errorLabel", :helper="helperLabel || ''")
:error-label="errorLabel", :helper="helperLabel || ''", orientation="vertical")
q-select(v-if="type === 'select'", :float-label="label", :dark="true", v-model="local", :options="selectOptions")
q-chips-input.q-my-md(v-else-if="type === 'chips'", :float-label="label", :dark="true", v-model="local",
chips-color="white", chips-bg-color="grey", @duplicate="duplicate()")
q-autocomplete.bg-grey-9(@search="autocompleteSearch", @selected="autocompleteSelected")
uploader(v-else-if="type === 'file'", dark, :url="url", @finish="onFileFinish", @select="onFileSelect", :headers="headers", :fields="uploadFields || []")
q-input(v-else, :dark="true", :float-label="label", :type="type", v-model="local", :attributes="attributes")
</template>
<script>
import { mapGetters } from 'vuex'
export default {
props: [
'value',
......@@ -21,7 +23,8 @@
'errorLabel',
'helperLabel',
'selectOptions',
'autocompleteOptions'
'autocompleteOptions',
'uploadFields'
],
data () {
return {
......@@ -29,6 +32,17 @@
}
},
computed: {
...mapGetters({
user: 'auth/getUserState'
}),
url () {
return this.user ? `${process.env.API_HOST}/assets/user-${this.user.uuid}` : undefined
},
headers () {
return {
Authorization: `Bearer ${this.$auth.token}`
}
},
error () {
if (this.type === 'hidden') return
return this.validation && this.validation.$error
......@@ -66,6 +80,12 @@
},
autocompleteSelected (item) {
console.debug('FormRow: autocompleteSelected', item)
},
onFileSelect (selection) {
this.$emit('select', selection)
},
onFileFinish (responses) {
this.local = responses
}
},
created () {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment