Add single button file upload
This commit is contained in:
parent
6710f51b64
commit
c5fea80ab4
|
|
@ -0,0 +1,73 @@
|
||||||
|
<template>
|
||||||
|
<div class="simple-file-upload">
|
||||||
|
<a class="simple-file-upload__link" @click="clickUploadCare" v-if="!value">
|
||||||
|
<document-icon class="simple-file-upload__icon"></document-icon>
|
||||||
|
</a>
|
||||||
|
<input type="hidden" ref="uploadcare-filedialog" role="uploadcare-uploader" name="file-upload" data-system-dialog/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import uploadcareWidget from 'uploadcare-widget';
|
||||||
|
|
||||||
|
import DocumentIcon from '@/components/icons/DocumentIcon';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: ['value'],
|
||||||
|
|
||||||
|
components: {
|
||||||
|
DocumentIcon
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
clickUploadCare() {
|
||||||
|
// workaround for styling the uploadcare widget
|
||||||
|
let button = this.$el.querySelector('.uploadcare--widget__button');
|
||||||
|
button.click();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
mounted() {
|
||||||
|
let widget = uploadcareWidget.Widget('[role=uploadcare-uploader]');
|
||||||
|
|
||||||
|
widget.onChange(result => {
|
||||||
|
result.done(fileInfo => {
|
||||||
|
let urlWithFilename = fileInfo.cdnUrl + fileInfo.name;
|
||||||
|
this.$emit('link-change-url', urlWithFilename);
|
||||||
|
});
|
||||||
|
|
||||||
|
result.progress(p => {
|
||||||
|
});
|
||||||
|
|
||||||
|
result.fail(uploadResult => {
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
@import "@/styles/_variables.scss";
|
||||||
|
|
||||||
|
.simple-file-upload {
|
||||||
|
width: 25px;
|
||||||
|
height: 25px;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
&__icon {
|
||||||
|
width: 25px;
|
||||||
|
fill: $color-silver-dark;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__link {
|
||||||
|
display: inline-block;
|
||||||
|
overflow: hidden;
|
||||||
|
width: 25px;
|
||||||
|
height: 25px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/deep/ .uploadcare--widget {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -41,7 +41,6 @@
|
||||||
@import '@/styles/_mixins.scss';
|
@import '@/styles/_mixins.scss';
|
||||||
|
|
||||||
.document-block {
|
.document-block {
|
||||||
margin-bottom: 30px;
|
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 50px 1fr 50px;
|
grid-template-columns: 50px 1fr 50px;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
|
||||||
|
|
@ -7,47 +7,39 @@
|
||||||
<solution :value="solution" v-if="assignment.solution"></solution>
|
<solution :value="solution" v-if="assignment.solution"></solution>
|
||||||
|
|
||||||
<template v-if="isStudent">
|
<template v-if="isStudent">
|
||||||
<final-submission :submission="assignment.submission" v-if="final"></final-submission>
|
<div class="assignment__submission">
|
||||||
|
|
||||||
<div class="assignment__submission" v-if="!final">
|
|
||||||
<!--<div class="assignment__toggle-input-container">-->
|
|
||||||
<!--<button-->
|
|
||||||
<!--class="assignment__toggle-input"-->
|
|
||||||
<!--@click="inputType = 'file'"-->
|
|
||||||
<!--:class="{'assignment__toggle-input--active': inputType === 'file'}"-->
|
|
||||||
<!-->Dokument hochladen-->
|
|
||||||
<!--</button>-->
|
|
||||||
<!--</div>-->
|
|
||||||
|
|
||||||
<div class="assignment__inputs">
|
<div class="assignment__inputs">
|
||||||
<submission-form
|
<submission-form
|
||||||
@input="saveInput"
|
@input="saveInput"
|
||||||
:submission="submission"
|
:submission="submission"
|
||||||
:saved="!unsaved"
|
:saved="!unsaved"
|
||||||
|
:final="final"
|
||||||
></submission-form>
|
></submission-form>
|
||||||
<div
|
|
||||||
class="assignment__file-upload"
|
|
||||||
v-if="inputType === 'file'">
|
|
||||||
<div v-if="assignment.submission.document">
|
|
||||||
<document-block
|
|
||||||
:value="{url: assignment.submission.document}"
|
|
||||||
show-trash-icon
|
|
||||||
v-on:trash="changeDocumentUrl('')"
|
|
||||||
></document-block>
|
|
||||||
</div>
|
|
||||||
<document-form
|
|
||||||
v-if="!assignment.submission.document"
|
|
||||||
:value="{url: ''}"
|
|
||||||
v-on:link-change-url="changeDocumentUrl"
|
|
||||||
></document-form>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button
|
<div class="assignment__actions" v-if="!final">
|
||||||
class="assignment__submit button button--primary button--white-bg"
|
<button
|
||||||
@click="turnIn"
|
class="assignment__submit button button--primary button--white-bg"
|
||||||
>Ergebnis mit Lehrperson teilen
|
@click="turnIn"
|
||||||
</button>
|
>Ergebnis mit Lehrperson teilen
|
||||||
|
</button>
|
||||||
|
|
||||||
|
<div v-if="assignment.submission.document">
|
||||||
|
<document-block
|
||||||
|
:value="{url: assignment.submission.document}"
|
||||||
|
show-trash-icon
|
||||||
|
v-on:trash="changeDocumentUrl('')"
|
||||||
|
></document-block>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<simple-file-upload
|
||||||
|
v-on:link-change-url="changeDocumentUrl"
|
||||||
|
:value="assignment.submission.document"
|
||||||
|
></simple-file-upload>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<final-submission :submission="assignment.submission" v-if="final" @reopen="reopen"></final-submission>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template v-if="!isStudent">
|
<template v-if="!isStudent">
|
||||||
|
|
@ -71,6 +63,7 @@
|
||||||
import DocumentForm from '@/components/content-forms/DocumentForm';
|
import DocumentForm from '@/components/content-forms/DocumentForm';
|
||||||
import DocumentBlock from '@/components/content-blocks/DocumentBlock';
|
import DocumentBlock from '@/components/content-blocks/DocumentBlock';
|
||||||
import Solution from '@/components/content-blocks/Solution';
|
import Solution from '@/components/content-blocks/Solution';
|
||||||
|
import SimpleFileUpload from '@/components/SimpleFileUpload';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: ['value'],
|
props: ['value'],
|
||||||
|
|
@ -80,7 +73,8 @@
|
||||||
DocumentForm,
|
DocumentForm,
|
||||||
SubmissionForm,
|
SubmissionForm,
|
||||||
FinalSubmission,
|
FinalSubmission,
|
||||||
Solution
|
Solution,
|
||||||
|
SimpleFileUpload
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -173,6 +167,21 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
reopen() {
|
||||||
|
this.$apollo.mutate({
|
||||||
|
mutation: UPDATE_ASSIGNMENT_MUTATION,
|
||||||
|
variables: {
|
||||||
|
input: {
|
||||||
|
assignment: {
|
||||||
|
id: this.assignment.id,
|
||||||
|
answer: this.assignment.submission.text,
|
||||||
|
document: this.assignment.submission.document,
|
||||||
|
final: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
initialSubmission() {
|
initialSubmission() {
|
||||||
return {
|
return {
|
||||||
text: '',
|
text: '',
|
||||||
|
|
@ -271,6 +280,12 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
&__submit {
|
&__submit {
|
||||||
|
margin-right: $medium-spacing;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__actions {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="final-submission">
|
<div class="final-submission">
|
||||||
<div v-if="submission.text" class="final-submission__text" v-html="text">
|
|
||||||
</div>
|
|
||||||
<document-block
|
<document-block
|
||||||
v-if="submission.document"
|
v-if="submission.document"
|
||||||
:value="{url: submission.document}"
|
:value="{url: submission.document}"
|
||||||
|
class="final-submission__document"
|
||||||
></document-block>
|
></document-block>
|
||||||
<div class="final-submission__explanation">
|
<div class="final-submission__explanation">
|
||||||
<info-icon class="final-submission__explanation-icon"></info-icon>
|
<info-icon class="final-submission__explanation-icon"></info-icon>
|
||||||
<span class="final-submission__explanation-text">Das Ergebnis wurde mit der Lehrperson geteilt</span>
|
<span class="final-submission__explanation-text">Das Ergebnis wurde mit der Lehrperson geteilt</span>
|
||||||
|
<a class="final-submission__reopen" @click="$emit('reopen')">Bearbeiten</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -56,6 +56,10 @@
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__document {
|
||||||
|
margin-bottom: $small-spacing;
|
||||||
|
}
|
||||||
|
|
||||||
&__explanation {
|
&__explanation {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
@ -70,6 +74,12 @@
|
||||||
color: $color-brand;
|
color: $color-brand;
|
||||||
font-family: $sans-serif-font-family;
|
font-family: $sans-serif-font-family;
|
||||||
font-weight: $font-weight-regular;
|
font-weight: $font-weight-regular;
|
||||||
|
margin-right: $medium-spacing;
|
||||||
|
}
|
||||||
|
&__reopen {
|
||||||
|
@include small-text;
|
||||||
|
cursor: pointer;
|
||||||
|
color: $color-charcoal-light;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@
|
||||||
rows="1"
|
rows="1"
|
||||||
class="submission-form__textarea"
|
class="submission-form__textarea"
|
||||||
placeholder="Ergebnis erfassen"
|
placeholder="Ergebnis erfassen"
|
||||||
|
:readonly="final"
|
||||||
:value="submission.text"
|
:value="submission.text"
|
||||||
@input="$emit('input', $event.target.value)"
|
@input="$emit('input', $event.target.value)"
|
||||||
></textarea>
|
></textarea>
|
||||||
|
|
@ -22,7 +23,7 @@
|
||||||
import LoadingIcon from '@/components/icons/LoadingIcon';
|
import LoadingIcon from '@/components/icons/LoadingIcon';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: ['submission', 'saved'],
|
props: ['submission', 'saved', 'final'],
|
||||||
|
|
||||||
components: {
|
components: {
|
||||||
TickCircleIcon,
|
TickCircleIcon,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<svg id="shape" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
|
<svg id="shape" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
|
||||||
<title>document</title>
|
|
||||||
<path
|
<path
|
||||||
d="M22.64,5.3a8.38,8.38,0,0,0-8.37,8.37V86.33a8.38,8.38,0,0,0,8.37,8.37H77.36a8.38,8.38,0,0,0,8.37-8.37v-57L61.39,5.3ZM79.17,88.08a2.74,2.74,0,0,1-2.11.94H22.34a3,3,0,0,1-3-3V13.37a3,3,0,0,1,3-3H54V28.32a7.78,7.78,0,0,0,7.77,7.77H79.75V85.73A2.85,2.85,0,0,1,79.17,88.08ZM62.11,31a2.34,2.34,0,0,1-2.39-2.39V11.15L79.58,31Z"/>
|
d="M22.64,5.3a8.38,8.38,0,0,0-8.37,8.37V86.33a8.38,8.38,0,0,0,8.37,8.37H77.36a8.38,8.38,0,0,0,8.37-8.37v-57L61.39,5.3ZM79.17,88.08a2.74,2.74,0,0,1-2.11.94H22.34a3,3,0,0,1-3-3V13.37a3,3,0,0,1,3-3H54V28.32a7.78,7.78,0,0,0,7.77,7.77H79.75V85.73A2.85,2.85,0,0,1,79.17,88.08ZM62.11,31a2.34,2.34,0,0,1-2.39-2.39V11.15L79.58,31Z"/>
|
||||||
<path
|
<path
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><title>
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
|
||||||
tick-circle</title>
|
|
||||||
<path
|
<path
|
||||||
d="M50,6.48A43.62,43.62,0,0,0,6.56,47.08S6.5,48.46,6.5,50s.06,2.83.06,2.92A43.52,43.52,0,1,0,50,6.48Zm0,82.15A38.62,38.62,0,1,1,88.6,50,38.67,38.67,0,0,1,50,88.62Z"/>
|
d="M50,6.48A43.62,43.62,0,0,0,6.56,47.08S6.5,48.46,6.5,50s.06,2.83.06,2.92A43.52,43.52,0,1,0,50,6.48Zm0,82.15A38.62,38.62,0,1,1,88.6,50,38.67,38.67,0,0,1,50,88.62Z"/>
|
||||||
<path d="M69.27,41a2.45,2.45,0,1,0-3.46-3.46L45,58.3,34.2,47.49A2.45,2.45,0,0,0,30.73,51L45,65.23Z"/>
|
<path d="M69.27,41a2.45,2.45,0,1,0-3.46-3.46L45,58.3,34.2,47.49A2.45,2.45,0,0,0,30.73,51L45,65.23Z"/>
|
||||||
|
|
|
||||||
|
|
@ -18,12 +18,13 @@
|
||||||
<script>
|
<script>
|
||||||
import {newLineToParagraph} from '@/helpers/text';
|
import {newLineToParagraph} from '@/helpers/text';
|
||||||
|
|
||||||
import DocumentIcon from '@/components/icons/DocumentIcon';
|
|
||||||
import StudentSubmissionDocument from '@/components/StudentSubmissionDocument';
|
import StudentSubmissionDocument from '@/components/StudentSubmissionDocument';
|
||||||
import STUDENT_SUBMISSIONS_QUERY from '@/graphql/gql/studentSubmissionQuery.gql';
|
import STUDENT_SUBMISSIONS_QUERY from '@/graphql/gql/studentSubmissionQuery.gql';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {DocumentIcon, StudentSubmissionDocument},
|
components: {
|
||||||
|
StudentSubmissionDocument
|
||||||
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
text() {
|
text() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue