upload documents
This commit is contained in:
parent
e1756300be
commit
c436f694e6
|
|
@ -10,6 +10,7 @@
|
||||||
<link href="https://use.typekit.net/tck7ptw.css" rel="stylesheet">
|
<link href="https://use.typekit.net/tck7ptw.css" rel="stylesheet">
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
window.UPLOADCARE_PUBLIC_KEY = '78212ff39934a59775ac';
|
||||||
window.UPLOADCARE_LOCALE = 'de';
|
window.UPLOADCARE_LOCALE = 'de';
|
||||||
window.UPLOADCARE_LOCALE_TRANSLATIONS = {
|
window.UPLOADCARE_LOCALE_TRANSLATIONS = {
|
||||||
dialog: {
|
dialog: {
|
||||||
|
|
|
||||||
|
|
@ -1,58 +1,77 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="document-form">
|
<div class="document-form" ref="documentform">
|
||||||
|
<div v-if="!value.url" ref="uploadcare-panel"></div>
|
||||||
<info-icon class="document-form__help-icon help-text__icon"></info-icon>
|
<div v-if="value.url">
|
||||||
<p class="document-form__help-description help-text__description">
|
<a :href="previewUrl">{{previewUrl}}</a>
|
||||||
Sie können Dokumente auf <a class="document-form__platform-link help-text__link" href="https://onedrive.live.com/"
|
</div>
|
||||||
target="_blank">OneDrive</a> hochladen und anschliessen einen Link hier einfügen.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<input class="document-form__document-link skillbox-input"
|
|
||||||
:value="value.url" v-on:input="$emit('document-change-url', $event.target.value, index)"
|
|
||||||
placeholder="URL einfügen...">
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import InfoIcon from '@/components/icons/InfoIcon';
|
import uploadcare from 'uploadcare-widget';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: ['value', 'index'],
|
|
||||||
|
|
||||||
components: {
|
props: ['value', 'index'],
|
||||||
InfoIcon
|
mounted() {
|
||||||
|
const uploadcarePanel = uploadcare.openPanel(this.$refs['uploadcare-panel'], null, {
|
||||||
|
tabs: ['file'],
|
||||||
|
});
|
||||||
|
|
||||||
|
// HACK to change the text of the Uploadcare dynamically we need to change the text here directly
|
||||||
|
setTimeout(() => {
|
||||||
|
const formElem = this.$refs['documentform'];
|
||||||
|
formElem.getElementsByClassName('uploadcare--text_size_extra-large')[1].innerText = 'Ziehen Sie ein Dokument hier hinein';
|
||||||
|
formElem.getElementsByClassName('uploadcare--tab__action-button')[0].innerText = 'Wählen Sie ein lokales Dokument';
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
uploadcarePanel.done(panelResult => {
|
||||||
|
panelResult.done(fileInfo => {
|
||||||
|
this.$emit('link-change-url', fileInfo.cdnUrl, this.index)
|
||||||
|
});
|
||||||
|
|
||||||
|
panelResult.progress(p => {
|
||||||
|
});
|
||||||
|
|
||||||
|
panelResult.fail(uploadResult => {
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
previewUrl: function() {
|
||||||
|
if (this.value && this.value.url) {
|
||||||
|
return this.value.url;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
@import "@/styles/_variables.scss";
|
@import "@/styles/_variables.scss";
|
||||||
@import "@/styles/_functions.scss";
|
|
||||||
|
|
||||||
.document-form {
|
.image-form {
|
||||||
display: grid;
|
&__file-input {
|
||||||
grid-auto-rows: auto;
|
width: 0.1px;
|
||||||
grid-template-columns: 40px 1fr;
|
height: 0.1px;
|
||||||
grid-column-gap: 16px;
|
overflow: hidden;
|
||||||
grid-row-gap: 20px;
|
opacity: 0;
|
||||||
align-items: center;
|
position: absolute;
|
||||||
|
z-index: -1;
|
||||||
|
|
||||||
&__help-icon {
|
& + label {
|
||||||
|
cursor: pointer;
|
||||||
|
background-color: $color-lightgrey;
|
||||||
|
height: 150px;
|
||||||
|
display: flex;
|
||||||
|
width: 100%;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
font-family: $sans-serif-font-family;
|
||||||
|
font-weight: 500;
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&__help-description {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
&__platform-link {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
&__document-link {
|
|
||||||
grid-column: 1 / span 2;
|
|
||||||
width: $modal-input-width
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -14,36 +14,25 @@
|
||||||
|
|
||||||
props: ['value', 'index'],
|
props: ['value', 'index'],
|
||||||
mounted() {
|
mounted() {
|
||||||
let uploadcarePanel = openImagePanel(this.$refs['uploadcare-panel']);
|
const uploadcarePanel = uploadcare.openPanel(this.$refs['uploadcare-panel'], null, {
|
||||||
|
tabs: ['file'],
|
||||||
|
});
|
||||||
|
|
||||||
uploadcarePanel.done(panelResult => {
|
uploadcarePanel.done(panelResult => {
|
||||||
console.log(panelResult);
|
|
||||||
|
|
||||||
panelResult.done(fileInfo => {
|
panelResult.done(fileInfo => {
|
||||||
console.log(fileInfo);
|
console.log(fileInfo);
|
||||||
this.$emit('link-change-url', fileInfo.cdnUrl, this.index)
|
this.$emit('link-change-url', fileInfo.cdnUrl, this.index)
|
||||||
});
|
});
|
||||||
|
|
||||||
panelResult.progress(p => {
|
panelResult.progress(p => {
|
||||||
console.log(p);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
panelResult.fail(uploadResult => {
|
panelResult.fail(uploadResult => {
|
||||||
console.log('fail');
|
|
||||||
console.log(uploadResult);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function openImagePanel(panelElement) {
|
|
||||||
return uploadcare.openPanel(panelElement, null, {
|
|
||||||
tabs: ['file'],
|
|
||||||
publicKey: '78212ff39934a59775ac'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
previewUrl: function() {
|
previewUrl: function() {
|
||||||
console.log(this.value);
|
|
||||||
if (this.value && this.value.url) {
|
if (this.value && this.value.url) {
|
||||||
return this.value.url + '-/preview/200x200/';
|
return this.value.url + '-/preview/200x200/';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue