Merge pull request #338 from nextcloud/fix/maxStringLengths

Provide DBs max string lengths as InitialState
This commit is contained in:
Jonas 2020-05-04 10:48:22 +02:00 committed by GitHub
commit 78b53cbb8e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 50 additions and 6 deletions

View file

@ -7,7 +7,7 @@
:placeholder="t('forms', 'Answer number {index}', { index: index + 1 })"
:value="answer.text"
class="question__input"
maxlength="256"
:maxlength="maxOptionLength"
minlength="1"
type="text"
@input="onInput"
@ -50,6 +50,10 @@ export default {
type: Number,
required: true,
},
maxOptionLength: {
type: Number,
required: true,
},
},
data() {

View file

@ -41,7 +41,7 @@
class="question__header-title"
type="text"
minlength="1"
maxlength="256"
:maxlength="maxQuestionLength"
required
@input="onInput"
@keyup="onTitleChange">
@ -101,6 +101,10 @@ export default {
type: Boolean,
default: false,
},
maxQuestionLength: {
type: Number,
required: true,
},
},
methods: {

View file

@ -25,6 +25,7 @@
v-bind.sync="$attrs"
:text="text"
:edit.sync="edit"
:max-question-length="maxStringLengths.questionText"
@delete="onDelete"
@update:text="onTitleChange">
<div class="question__content">
@ -35,7 +36,7 @@
:required="true /* TODO: implement required option */"
:value="values[0]"
class="question__text"
maxlength="1024"
:maxlength="maxStringLengths.answerText"
minlength="1"
@input="onInput"
@keydown="autoSizeText" />

View file

@ -26,6 +26,7 @@
v-bind.sync="$attrs"
:text="text"
:edit.sync="edit"
:max-question-length="maxStringLengths.questionText"
@delete="onDelete"
@update:text="onTitleChange">
<ul class="question__content">
@ -57,6 +58,7 @@
ref="input"
:answer="answer"
:index="index"
:max-option-length="maxStringLengths.optionText"
@add="addNewEntry"
@delete="deleteAnswer"
@update:answer="updateAnswer"
@ -64,12 +66,11 @@
</template>
<li v-if="(edit && !isLastEmpty) || hasNoAnswer" class="question__item">
<!-- TODO: properly choose max length -->
<input
:aria-label="t('forms', 'Add a new answer')"
:placeholder="t('forms', 'Add a new answer')"
class="question__input"
maxlength="256"
:maxlength="maxStringLengths.optionText"
minlength="1"
type="text"
@click="addNewEntry">

View file

@ -25,6 +25,7 @@
v-bind.sync="$attrs"
:text="text"
:edit.sync="edit"
:max-question-length="maxStringLengths.questionText"
@delete="onDelete"
@update:text="onTitleChange">
<div class="question__content">
@ -35,7 +36,7 @@
:required="true /* TODO: implement required option */"
:value="values[0]"
class="question__input"
maxlength="256"
:maxlength="maxStringLengths.answerText"
minlength="1"
type="text"
@input="onInput">

View file

@ -57,6 +57,14 @@ export default {
type: Object,
required: true,
},
/**
* Database-Restrictions
*/
maxStringLengths: {
type: Object,
required: true,
},
},
components: {

View file

@ -50,6 +50,7 @@
id="form-title"
v-model="form.title"
:minlength="0"
:maxlength="maxStringLengths.formTitle"
:placeholder="t('forms', 'Form title')"
:required="true"
autofocus
@ -61,6 +62,7 @@
id="form-desc"
ref="description"
v-model="form.description"
:maxlength="maxStringLengths.formDescription"
:placeholder="t('forms', 'Description')"
@change="autoSizeDescription"
@keydown="autoSizeDescription"
@ -83,6 +85,7 @@
:key="question.id"
:model="answerTypes[question.type]"
:index="index + 1"
:max-string-lengths="maxStringLengths"
v-bind.sync="question"
@delete="deleteQuestion(question)" />
</Draggable>
@ -112,6 +115,7 @@
<script>
import { emit } from '@nextcloud/event-bus'
import { generateUrl } from '@nextcloud/router'
import { loadState } from '@nextcloud/initial-state'
import { showError } from '@nextcloud/dialogs'
import axios from '@nextcloud/axios'
import debounce from 'debounce'
@ -151,6 +155,8 @@ export default {
data() {
return {
maxStringLengths: loadState('forms', 'maxStringLengths'),
questionMenuOpened: false,
answerTypes,

View file

@ -44,6 +44,7 @@
:read-only="true"
:model="answerTypes[question.type]"
:index="index + 1"
:max-string-lengths="maxStringLengths"
v-bind="question"
:values.sync="answers[question.id]" />
</ul>
@ -97,6 +98,7 @@ export default {
data() {
return {
form: loadState('forms', 'form'),
maxStringLengths: loadState('forms', 'maxStringLengths'),
answerTypes,
answers: {},
loading: false,