mirror of
https://github.com/ProtonMail/proton-bridge.git
synced 2025-12-16 07:06:45 +00:00
feat(GODT-2816): Handle maxChar even for non mandatory field + make it customisable from JSON.
This commit is contained in:
committed by
Romain Le Jeune
parent
80d729e3e5
commit
243ddf47ab
@ -91,6 +91,7 @@ SettingsView {
|
|||||||
type: root.questions[modelData].type
|
type: root.questions[modelData].type
|
||||||
mandatory: root.questions[modelData].mandatory ? root.questions[modelData].mandatory : false
|
mandatory: root.questions[modelData].mandatory ? root.questions[modelData].mandatory : false
|
||||||
answerList: root.questions[modelData].answerList ? root.questions[modelData].answerList : []
|
answerList: root.questions[modelData].answerList ? root.questions[modelData].answerList : []
|
||||||
|
maxChar: root.questions[modelData].maxChar ? root.questions[modelData].maxChar : 150
|
||||||
|
|
||||||
onAnswerChanged: {
|
onAnswerChanged: {
|
||||||
Backend.setQuestionAnswer(modelData, answer);
|
Backend.setQuestionAnswer(modelData, answer);
|
||||||
|
|||||||
@ -34,6 +34,7 @@ Item {
|
|||||||
property bool mandatory: false
|
property bool mandatory: false
|
||||||
property var type: QuestionItem.InputType.TextInput
|
property var type: QuestionItem.InputType.TextInput
|
||||||
property var answerList: ListModel{}
|
property var answerList: ListModel{}
|
||||||
|
property int maxChar: 150
|
||||||
|
|
||||||
property string answer:{
|
property string answer:{
|
||||||
if (type === QuestionItem.InputType.TextInput) {
|
if (type === QuestionItem.InputType.TextInput) {
|
||||||
@ -62,8 +63,12 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function validate() {
|
function validate() {
|
||||||
|
|
||||||
|
if (root.type === QuestionItem.InputType.TextInput)
|
||||||
textInput.validate()
|
textInput.validate()
|
||||||
|
else if (root.type === QuestionItem.InputType.Radio)
|
||||||
selectionRadio.validate()
|
selectionRadio.validate()
|
||||||
|
else if (root.type === QuestionItem.InputType.Checkbox)
|
||||||
selectionCheckBox.validate()
|
selectionCheckBox.validate()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,11 +94,11 @@ Item {
|
|||||||
Layout.minimumHeight: root.type === QuestionItem.InputType.TextInput ? heightForLinesVisible(2) : 0
|
Layout.minimumHeight: root.type === QuestionItem.InputType.TextInput ? heightForLinesVisible(2) : 0
|
||||||
colorScheme: root.colorScheme
|
colorScheme: root.colorScheme
|
||||||
|
|
||||||
property int _maxLength: 400
|
property int _maxLength: root.maxChar
|
||||||
property int _minLength: 10
|
property int _minLength: 10
|
||||||
|
|
||||||
label: qsTr(root.label)
|
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) : ""
|
placeholderText: mandatory ? qsTr("%1... (min. %2 characters)").arg(root.text).arg(_minLength) : ""
|
||||||
|
|
||||||
function setDefaultValue(defaultValue) {
|
function setDefaultValue(defaultValue) {
|
||||||
@ -101,9 +106,7 @@ Item {
|
|||||||
}
|
}
|
||||||
|
|
||||||
validator: function (text) {
|
validator: function (text) {
|
||||||
if (!mandatory)
|
if (mandatory && textInput.text.length < textInput._minLength) {
|
||||||
return;
|
|
||||||
if (textInput.text.length < textInput._minLength) {
|
|
||||||
return qsTr("min. %1 characters").arg(_minLength);
|
return qsTr("min. %1 characters").arg(_minLength);
|
||||||
}
|
}
|
||||||
if (textInput.text.length > textInput._maxLength) {
|
if (textInput.text.length > textInput._maxLength) {
|
||||||
|
|||||||
@ -36,20 +36,23 @@
|
|||||||
"text": "What happened?",
|
"text": "What happened?",
|
||||||
"tips": "Expected behavior",
|
"tips": "Expected behavior",
|
||||||
"type": 1,
|
"type": 1,
|
||||||
"mandatory": true
|
"mandatory": true,
|
||||||
|
"maxChar": 400
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 1,
|
"id": 1,
|
||||||
"text": "What did you want or expect to happen?",
|
"text": "What did you want or expect to happen?",
|
||||||
"tips": "Result",
|
"tips": "Result",
|
||||||
"type": 1,
|
"type": 1,
|
||||||
"mandatory": true
|
"mandatory": true,
|
||||||
|
"maxChar": 400
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 2,
|
"id": 2,
|
||||||
"text": "What were the step-by-step actions you took that led to this happening?",
|
"text": "What were the step-by-step actions you took that led to this happening?",
|
||||||
"tips": "Steps to reproduce",
|
"tips": "Steps to reproduce",
|
||||||
"type": 1
|
"type": 1,
|
||||||
|
"maxChar": 400
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": 3,
|
"id": 3,
|
||||||
|
|||||||
@ -152,7 +152,7 @@ func (s *scenario) theUserSetSMTPModeToSSL() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *scenario) theUserReportsABug() 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 {
|
func (s *scenario) bridgeSendsAConnectionUpEvent() error {
|
||||||
|
|||||||
Reference in New Issue
Block a user