diff --git a/internal/frontend/bridge-gui/bridge-gui/qml/BugQuestionView.qml b/internal/frontend/bridge-gui/bridge-gui/qml/BugQuestionView.qml index d1ee19b0..8c809e61 100644 --- a/internal/frontend/bridge-gui/bridge-gui/qml/BugQuestionView.qml +++ b/internal/frontend/bridge-gui/bridge-gui/qml/BugQuestionView.qml @@ -91,6 +91,7 @@ SettingsView { type: root.questions[modelData].type mandatory: root.questions[modelData].mandatory ? root.questions[modelData].mandatory : false answerList: root.questions[modelData].answerList ? root.questions[modelData].answerList : [] + maxChar: root.questions[modelData].maxChar ? root.questions[modelData].maxChar : 150 onAnswerChanged: { Backend.setQuestionAnswer(modelData, answer); diff --git a/internal/frontend/bridge-gui/bridge-gui/qml/QuestionItem.qml b/internal/frontend/bridge-gui/bridge-gui/qml/QuestionItem.qml index 6c5cfb24..2db58c0a 100644 --- a/internal/frontend/bridge-gui/bridge-gui/qml/QuestionItem.qml +++ b/internal/frontend/bridge-gui/bridge-gui/qml/QuestionItem.qml @@ -34,6 +34,7 @@ Item { property bool mandatory: false property var type: QuestionItem.InputType.TextInput property var answerList: ListModel{} + property int maxChar: 150 property string answer:{ if (type === QuestionItem.InputType.TextInput) { @@ -62,8 +63,12 @@ Item { } function validate() { + + if (root.type === QuestionItem.InputType.TextInput) textInput.validate() + else if (root.type === QuestionItem.InputType.Radio) selectionRadio.validate() + else if (root.type === QuestionItem.InputType.Checkbox) selectionCheckBox.validate() } @@ -89,11 +94,11 @@ Item { Layout.minimumHeight: root.type === QuestionItem.InputType.TextInput ? heightForLinesVisible(2) : 0 colorScheme: root.colorScheme - property int _maxLength: 400 + property int _maxLength: root.maxChar property int _minLength: 10 label: qsTr(root.label) - hint: mandatory ? textInput.text.length + "/" + _maxLength : "" + hint: textInput.text.length + "/" + _maxLength placeholderText: mandatory ? qsTr("%1... (min. %2 characters)").arg(root.text).arg(_minLength) : "" function setDefaultValue(defaultValue) { @@ -101,9 +106,7 @@ Item { } validator: function (text) { - if (!mandatory) - return; - if (textInput.text.length < textInput._minLength) { + if (mandatory && textInput.text.length < textInput._minLength) { return qsTr("min. %1 characters").arg(_minLength); } if (textInput.text.length > textInput._maxLength) { diff --git a/internal/frontend/bridge-gui/bridge-gui/qml/Resources/bug_report_flow.json b/internal/frontend/bridge-gui/bridge-gui/qml/Resources/bug_report_flow.json index 3054b27b..391c31f7 100644 --- a/internal/frontend/bridge-gui/bridge-gui/qml/Resources/bug_report_flow.json +++ b/internal/frontend/bridge-gui/bridge-gui/qml/Resources/bug_report_flow.json @@ -36,20 +36,23 @@ "text": "What happened?", "tips": "Expected behavior", "type": 1, - "mandatory": true + "mandatory": true, + "maxChar": 400 }, { "id": 1, "text": "What did you want or expect to happen?", "tips": "Result", "type": 1, - "mandatory": true + "mandatory": true, + "maxChar": 400 }, { "id": 2, "text": "What were the step-by-step actions you took that led to this happening?", "tips": "Steps to reproduce", - "type": 1 + "type": 1, + "maxChar": 400 }, { "id": 3, diff --git a/tests/bridge_test.go b/tests/bridge_test.go index 4885d000..2be4aece 100644 --- a/tests/bridge_test.go +++ b/tests/bridge_test.go @@ -152,7 +152,7 @@ func (s *scenario) theUserSetSMTPModeToSSL() error { } func (s *scenario) theUserReportsABug() error { - return s.t.bridge.ReportBug(context.Background(), "osType", "osVersion", "description", "username", "email", "client", false) + return s.t.bridge.ReportBug(context.Background(), "osType", "osVersion", "title", "description", "username", "email", "client", false) } func (s *scenario) bridgeSendsAConnectionUpEvent() error {