New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add configurable word and character limits to questions #272
Conversation
…igned during config load
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Didn't test locally but looks pretty good
client/js/application.ts
Outdated
let wordCountInputs = document.querySelectorAll("[data-max-word-count], [data-min-word-count]") as NodeListOf<HTMLInputElement | HTMLTextAreaElement>; | ||
for (let i = 0; i < wordCountInputs.length; i++) { | ||
wordCountInputs[i].addEventListener("input", e => { | ||
let target = e.target as HTMLInputElement | HTMLTextAreaElement; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like this can be const
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. I'm too used to Rust at the moment where everything is immutable by default and it also uses let
{{#ifCond this.type "textarea"}} | ||
<textarea name="{{this.name}}" id="form-{{this.name}}" placeholder="{{this.placeholder}}" {{required this.required}}>{{this.value}}</textarea> | ||
<textarea name="{{this.name}}" id="form-{{this.name}}" placeholder="{{this.placeholder}}" {{required this.required}} minlength="{{this.minCharacterCount}}" maxlength="{{this.maxCharacterCount}}" data-max-word-count="{{this.maxWordCount}}" data-min-word-count="{{this.minWordCount}}">{{this.value}}</textarea> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this still add the minlength
and other attributes even if those aren't defined in the JSON file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it does
Is it worth adding a Handlebars partial to only add the attribute if it is set?
@@ -45,7 +60,7 @@ | |||
<input type="file" name="{{this.name}}" id="form-{{this.name}}" placeholder="{{this.placeholder}}" {{required this.required}} /> | |||
{{/if}} | |||
{{else}} | |||
<input type="{{this.type}}" name="{{this.name}}" id="form-{{this.name}}" placeholder="{{this.placeholder}}" {{required this.required}} value="{{this.value}}" /> | |||
<input type="{{this.type}}" name="{{this.name}}" id="form-{{this.name}}" placeholder="{{this.placeholder}}" {{required this.required}} minlength="{{this.minCharacterCount}}" maxlength="{{this.maxCharacterCount}}" data-max-word-count="{{this.maxWordCount}}" data-min-word-count="{{this.minWordCount}}" value="{{this.value}}" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here re: attrs
Add configurable word and character limits to questions
maxWordCount
,minWordCount
,maxCharacterCount
, andminCharacterCount
to fields that accept textCloses #268