2020-03-31 18:20:55 +02:00
|
|
|
<!--
|
|
|
|
- @copyright Copyright (c) 2020 John Molakvoæ <skjnldsv@protonmail.com>
|
|
|
|
-
|
|
|
|
- @author John Molakvoæ <skjnldsv@protonmail.com>
|
|
|
|
-
|
|
|
|
- @license GNU AGPL version 3 or any later version
|
|
|
|
-
|
|
|
|
- This program is free software: you can redistribute it and/or modify
|
|
|
|
- it under the terms of the GNU Affero General Public License as
|
|
|
|
- published by the Free Software Foundation, either version 3 of the
|
|
|
|
- License, or (at your option) any later version.
|
|
|
|
-
|
|
|
|
- This program is distributed in the hope that it will be useful,
|
|
|
|
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
- GNU Affero General Public License for more details.
|
|
|
|
-
|
|
|
|
- You should have received a copy of the GNU Affero General Public License
|
|
|
|
- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
-
|
|
|
|
-->
|
|
|
|
|
|
|
|
<template>
|
2020-04-10 17:35:40 +02:00
|
|
|
<Question
|
|
|
|
v-bind.sync="$attrs"
|
2020-04-20 13:51:48 +02:00
|
|
|
:text="text"
|
2020-04-30 10:58:04 +02:00
|
|
|
:mandatory="mandatory"
|
2020-04-10 17:35:40 +02:00
|
|
|
:edit.sync="edit"
|
2020-05-15 14:09:23 +02:00
|
|
|
:read-only="readOnly"
|
2020-05-03 13:07:29 +02:00
|
|
|
:max-question-length="maxStringLengths.questionText"
|
2020-05-14 20:56:22 +02:00
|
|
|
:title-placeholder="answerType.titlePlaceholder"
|
2020-05-26 18:01:48 +02:00
|
|
|
:warning-invalid="answerType.warningInvalid"
|
2020-04-30 10:58:04 +02:00
|
|
|
@update:text="onTitleChange"
|
|
|
|
@update:mandatory="onMandatoryChange"
|
2020-07-07 21:15:53 +02:00
|
|
|
@delete="onDelete"
|
|
|
|
@focus-prev="onFocusPrev"
|
|
|
|
@focus-next="FocusNextOutside">
|
2020-03-31 18:20:55 +02:00
|
|
|
<div class="question__content">
|
|
|
|
<textarea ref="textarea"
|
2020-04-20 13:51:48 +02:00
|
|
|
:aria-label="t('forms', 'A long answer for the question “{text}”', { text })"
|
2020-05-15 14:09:23 +02:00
|
|
|
:placeholder="submissionInputPlaceholder"
|
|
|
|
:disabled="!readOnly"
|
2020-04-30 10:58:04 +02:00
|
|
|
:required="mandatory"
|
2020-03-31 18:20:55 +02:00
|
|
|
:value="values[0]"
|
|
|
|
class="question__text"
|
2020-05-03 13:07:29 +02:00
|
|
|
:maxlength="maxStringLengths.answerText"
|
2020-03-31 18:20:55 +02:00
|
|
|
minlength="1"
|
|
|
|
@input="onInput"
|
2020-05-26 14:37:22 +02:00
|
|
|
@keypress="autoSizeText"
|
|
|
|
@keydown.ctrl.enter="onKeydownCtrlEnter" />
|
2020-03-31 18:20:55 +02:00
|
|
|
</div>
|
|
|
|
</Question>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import QuestionMixin from '../../mixins/QuestionMixin'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
name: 'QuestionLong',
|
|
|
|
|
|
|
|
mixins: [QuestionMixin],
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
height: 1,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2020-05-15 14:09:23 +02:00
|
|
|
computed: {
|
|
|
|
submissionInputPlaceholder() {
|
|
|
|
if (this.readOnly) {
|
|
|
|
return this.answerType.submitPlaceholder
|
|
|
|
}
|
|
|
|
return this.answerType.createPlaceholder
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2020-03-31 18:20:55 +02:00
|
|
|
mounted() {
|
|
|
|
this.autoSizeText()
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
onInput() {
|
|
|
|
const textarea = this.$refs.textarea
|
|
|
|
this.$emit('update:values', [textarea.value])
|
|
|
|
this.autoSizeText()
|
|
|
|
},
|
|
|
|
autoSizeText() {
|
|
|
|
const textarea = this.$refs.textarea
|
|
|
|
textarea.style.cssText = 'height:auto; padding:0'
|
|
|
|
textarea.style.cssText = `height: ${textarea.scrollHeight + 20}px`
|
|
|
|
},
|
2020-05-26 14:37:22 +02:00
|
|
|
onKeydownCtrlEnter(event) {
|
|
|
|
this.$emit('keydown', event)
|
|
|
|
},
|
2020-03-31 18:20:55 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2020-05-27 21:52:35 +02:00
|
|
|
<style lang="scss" scoped>
|
2020-03-31 18:20:55 +02:00
|
|
|
.question__text {
|
|
|
|
// make sure height calculations are correct
|
|
|
|
box-sizing: content-box !important;
|
|
|
|
width: 100%;
|
|
|
|
min-width: 100%;
|
|
|
|
max-width: 100%;
|
|
|
|
min-height: 44px;
|
|
|
|
margin: 0;
|
|
|
|
padding: 6px 0;
|
|
|
|
border: 0;
|
|
|
|
border-bottom: 1px dotted var(--color-border-dark);
|
|
|
|
border-radius: 0;
|
2020-05-01 02:35:40 +02:00
|
|
|
resize: none;
|
2020-05-27 21:52:35 +02:00
|
|
|
font-size: 14px;
|
2020-05-15 14:09:23 +02:00
|
|
|
|
|
|
|
&:disabled {
|
|
|
|
// Just overrides Server CSS-Styling for disabled inputs. -> Not Good??
|
|
|
|
background-color: var(--color-main-background);
|
|
|
|
color: var(--color-main-text);
|
|
|
|
}
|
2020-03-31 18:20:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|