Skip to content

Commit

Permalink
🐞 Write-in issues (#459)
Browse files Browse the repository at this point in the history
Parent issue: sequentech/meta#1670
  • Loading branch information
Findeton authored Aug 8, 2024
1 parent b7ea7b8 commit a5e6064
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
19 changes: 10 additions & 9 deletions avBooth/error-checker-generator-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -457,22 +457,23 @@ angular.module('avUi')
return true;
}

var foundField = question.answers
var foundFields = question.answers
// only write-in questions
.filter(function (answer) {
return service.hasUrl(answer.urls, 'isWriteIn', 'true') &&
answer.selected > -1 &&
_.isObject(answer.writeInFields);
})
// get write-in fields
.map(function (answer) { return Object.values(answer.writeInFields); })
.flat()
.find(function (field) {
// check field min restriction against value
return _.isString(field.value) && field.value.length < field.min;
});

return !foundField;
.map(function (answer) {
return Object.values(answer.writeInFields)
.find(function (field) {
// check field min restriction against value
return (_.isString(field.value) && field.value.length < field.min) || (answer.text && field.min && !field.value);
});
})
.filter(value => value);
return 0 === foundFields.length;
},
postfix: "-writein-field-min-length"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
type="text"
ng-readonly="!!hideCheck()"
class="form-control write-in-extra-field-input"
ng-class="{'invalid': (field.value && field.min && field.value.length < field.min) || (field.value && field.max && field.value.length > field.max)}"
ng-class="{'invalid': (answer.text && !field.value && field.min) || (field.value && field.min && field.value.length < field.min) || (field.value && field.max && field.value.length > field.max)}"
autocomplete="off"
id="question_{{question.index}}_answer_{{answer.id}}_{{field.id}}"
placeholder="{{field | customI18n: 'placeholder'}}"
Expand Down

0 comments on commit a5e6064

Please sign in to comment.