diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 38fb997..cfde2dc 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -64,6 +64,18 @@ class PageController extends Controller { /** @var FormsService */ private $formService; + /** @var Array + * + * Maximum String lengths, the database is set to store. + */ + private $maxStringLengths = [ + 'formTitle' => 256, + 'formDescription' => 2048, + 'questionText' => 2048, + 'optionText' => 1024, + 'answerText' => 2048, + ]; + public function __construct(string $appName, IRequest $request, IGroupManager $groupManager, @@ -96,6 +108,7 @@ class PageController extends Controller { public function index(): TemplateResponse { Util::addScript($this->appName, 'forms'); Util::addStyle($this->appName, 'forms'); + $this->initialStateService->provideInitialState($this->appName, 'maxStringLengths', $this->maxStringLengths); return new TemplateResponse($this->appName, 'main'); } @@ -108,6 +121,7 @@ class PageController extends Controller { public function createForm(): TemplateResponse { Util::addScript($this->appName, 'forms'); Util::addStyle($this->appName, 'forms'); + $this->initialStateService->provideInitialState($this->appName, 'maxStringLengths', $this->maxStringLengths); return new TemplateResponse($this->appName, 'main'); } @@ -122,6 +136,7 @@ class PageController extends Controller { public function cloneForm(): TemplateResponse { Util::addScript($this->appName, 'forms'); Util::addStyle($this->appName, 'forms'); + $this->initialStateService->provideInitialState($this->appName, 'maxStringLengths', $this->maxStringLengths); return new TemplateResponse($this->appName, 'main'); } @@ -134,6 +149,7 @@ class PageController extends Controller { public function editForm(): TemplateResponse { Util::addScript($this->appName, 'forms'); Util::addStyle($this->appName, 'forms'); + $this->initialStateService->provideInitialState($this->appName, 'maxStringLengths', $this->maxStringLengths); return new TemplateResponse($this->appName, 'main'); } @@ -182,6 +198,7 @@ class PageController extends Controller { Util::addScript($this->appName, 'submit'); $this->initialStateService->provideInitialState($this->appName, 'form', $this->formsService->getForm($form->getId())); + $this->initialStateService->provideInitialState($this->appName, 'maxStringLengths', $this->maxStringLengths); return new TemplateResponse($this->appName, 'main', [], $renderAs); } diff --git a/src/components/Questions/AnswerInput.vue b/src/components/Questions/AnswerInput.vue index 4fa4926..6e28b9c 100644 --- a/src/components/Questions/AnswerInput.vue +++ b/src/components/Questions/AnswerInput.vue @@ -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() { diff --git a/src/components/Questions/Question.vue b/src/components/Questions/Question.vue index e5c8f07..45d99c6 100644 --- a/src/components/Questions/Question.vue +++ b/src/components/Questions/Question.vue @@ -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: { diff --git a/src/components/Questions/QuestionLong.vue b/src/components/Questions/QuestionLong.vue index 25b3b9f..b0e92ca 100644 --- a/src/components/Questions/QuestionLong.vue +++ b/src/components/Questions/QuestionLong.vue @@ -25,6 +25,7 @@ v-bind.sync="$attrs" :text="text" :edit.sync="edit" + :max-question-length="maxStringLengths.questionText" @delete="onDelete" @update:text="onTitleChange">
@@ -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" /> diff --git a/src/components/Questions/QuestionMultiple.vue b/src/components/Questions/QuestionMultiple.vue index b6e80ad..6896601 100644 --- a/src/components/Questions/QuestionMultiple.vue +++ b/src/components/Questions/QuestionMultiple.vue @@ -26,6 +26,7 @@ v-bind.sync="$attrs" :text="text" :edit.sync="edit" + :max-question-length="maxStringLengths.questionText" @delete="onDelete" @update:text="onTitleChange">