feat(GODT-2816): Handle maxChar even for non mandatory field + make it customisable from JSON.
This commit is contained in:
parent
80d729e3e5
commit
243ddf47ab
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue