Add loading message for spellcheck

This commit is contained in:
Ramon Wenger 2020-02-12 10:37:34 +01:00
parent 680b78e904
commit 919c0aec18
2 changed files with 26 additions and 2 deletions

View File

@ -15,6 +15,7 @@
@changeDocumentUrl="changeDocumentUrl" @changeDocumentUrl="changeDocumentUrl"
@spellcheck="spellcheck" @spellcheck="spellcheck"
:user-input="submission" :user-input="submission"
:spellcheck-loading="spellcheckLoading"
placeholder="Ergebnis erfassen" placeholder="Ergebnis erfassen"
action="Ergebnis mit Lehrperson teilen" action="Ergebnis mit Lehrperson teilen"
shared-msg="Das Ergebnis wurde mit der Lehrperson geteilt." shared-msg="Das Ergebnis wurde mit der Lehrperson geteilt."
@ -191,6 +192,7 @@
}, },
spellcheck() { spellcheck() {
let self = this; let self = this;
this.spellcheckLoading = true;
this.$apollo.mutate({ this.$apollo.mutate({
mutation: SPELL_CHECK_MUTATION, mutation: SPELL_CHECK_MUTATION,
variables: { variables: {
@ -202,6 +204,8 @@
update(store, {data: {spellCheck: {results}}}) { update(store, {data: {spellCheck: {results}}}) {
self.corrections = results; self.corrections = results;
} }
}).then(() => {
this.spellcheckLoading = false;
}); });
} }
}, },
@ -239,7 +243,8 @@
inputType: 'text', inputType: 'text',
unsaved: false, unsaved: false,
saving: 0, saving: 0,
corrections: '' corrections: '',
spellcheckLoading: false
} }
} }
} }

View File

@ -20,7 +20,7 @@
class="submission-form-container__submit submission-form-container__spellcheck button button--primary button--white-bg" class="submission-form-container__submit submission-form-container__spellcheck button button--primary button--white-bg"
v-if="spellcheck" v-if="spellcheck"
@click="$emit('spellcheck')" @click="$emit('spellcheck')"
>Rechtschreibung prüfen >{{spellcheckText}}
</button> </button>
<div v-if="userInput.document"> <div v-if="userInput.document">
<document-block <document-block
@ -65,6 +65,10 @@
type: Boolean, type: Boolean,
default: false default: false
}, },
spellcheckLoading: {
type: Boolean,
default: false
},
sharedMsg: String sharedMsg: String
}, },
@ -81,6 +85,14 @@
}, },
allowsDocuments() { allowsDocuments() {
return 'document' in this.userInput; return 'document' in this.userInput;
},
spellcheckText() {
if (!this.spellcheckLoading) {
return 'Rechtschreibung prüfen'
} else {
return 'Wird geprüft...'
}
} }
}, },
@ -129,6 +141,13 @@
cursor: pointer; cursor: pointer;
} }
} }
&__spellcheck {
/* so the button does not change size when changing the text */
width: 235px;
text-align: center;
display: inline-block;
}
} }
</style> </style>