Add numbered shortcuts and filter search to Question select/checkbox#2446
Add numbered shortcuts and filter search to Question select/checkbox#2446RR5555 wants to merge 19 commits intocopier-org:masterfrom
Question select/checkbox#2446Conversation
…ilter_search` to `Question` class for selection with number shortcuts or filter Refs: copier-org#2155
…se_shortcuts` & `use_filter_search`
…& `use_filter_search`
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #2446 +/- ##
==========================================
- Coverage 97.25% 97.16% -0.10%
==========================================
Files 58 59 +1
Lines 6751 6846 +95
==========================================
+ Hits 6566 6652 +86
- Misses 185 194 +9
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Per reviewer suggestion/request Reviewed-by: sisp Refs: copier-org#2446#discussion_r2678784231
f043dd4 to
08371bf
Compare
…_filter_search` to `use_search_filter` Per reviewer catch to match `questionary` args as intended Reviewed-by: sisp Refs: copier-org#2446#discussion_r2678785014
Per reviewer request Reviewed-by: sisp Refs: copier-org#2446#discussion_r2678786515
Per reviewer suggestion/request Remove development leftovers Reviewed-by: sisp Refs: copier-org#2446#discussion_r2678777344 copier-org#2446#discussion_r2678779566
Per reviewer suggestion/request Reviewed-by: sisp Refs: copier-org#2446#discussion_r2678780560
…_filter` Per reviewer suggestion/request Reviewed-by: sisp Refs: copier-org#2446#pullrequestreview-3647014001
|
Thank you for reviewing another of my PRs ^^ I had a first go at the documentation of the settings (docs(docs/configuring.md): add docs for |
…se_searcg_filter` Per reviewer suggestion/request Reviewed-by: sisp Refs: copier-org#2446#discussion_r2678783429
…pes` change `dict` to `dict[str, Any]`
…al exclusiveness Per reviewer request. Before: `use_search_filter`>`use_shortcuts` After: ValidationError Before: `multiselect`>`use_shortcuts` After: ValidationError Refs: copier-org#2446#pullrequestreview-3687996014
Per reviewer request. Refs: copier-org#2446#pullrequestreview-3687996014
…add ValidationError tests Per reviewer request. Refs: copier-org#2446#discussion_r2718709082
…se_shortcuts` & `use_search_filter` Per reviewer request. Refs: copier-org#2446#pullrequestreview-3687996014
Per reviewer request/suggestion. Refs: copier-org#2446#pullrequestreview-3687996014
|
Thank you for your previous round of review. Sorry for the delay. |
sisp
left a comment
There was a problem hiding this comment.
Looks great, thank you! 👍 Just a minor request and a question, then we're ready to merge. 🎉
| if self.use_shortcuts: | ||
| if self.multiselect: | ||
| raise ValidationError.from_exception_data( | ||
| title=f"`{self.var_name}`", | ||
| line_errors=[ | ||
| { | ||
| "type": PydanticCustomError( | ||
| '"`use_shortcuts` & `multiselect` are mutually exclusive"', | ||
| "Use either `use_shortcuts: true` or `multiselect: true`", | ||
| ), | ||
| "input": {"use_shortcuts": True, "multiselect": True}, | ||
| } | ||
| ], | ||
| ) | ||
| if self.use_search_filter: | ||
| raise ValidationError.from_exception_data( | ||
| title=f"`{self.var_name}`", | ||
| line_errors=[ | ||
| { | ||
| "type": PydanticCustomError( | ||
| '"`use_shortcuts` & `use_search_filter` are mutually exclusive"', | ||
| "Use either `use_shortcuts: true` or `use_search_filter: true`", | ||
| ), | ||
| "input": { | ||
| "use_shortcuts": True, | ||
| "use_search_filter": True, | ||
| }, | ||
| } | ||
| ], | ||
| ) |
There was a problem hiding this comment.
While thinking about this some more, I think it's better to move these checks to a Pydantic model validator method to enforce these invariants at object construction time (and remove this code block from the questionary transformation logic).
| Some array: "[str, keeps, this, as, a, str]" | ||
| ``` | ||
|
|
||
| - **use_shortcuts**: When set to `true`, allows selecting choice question items via |
There was a problem hiding this comment.
Should we move this list item down by one position to below multiselect and above use_search_filter to group use_shortcuts and use_search_filter?
PR Description
This PR adds the
questionaryoptionsuse_shortcuts&use_filter_searchto CopierQuestion, to allow the usage of numbered shortcuts forselectquestions, and filter search forselect/checkboxquestions.It addresses Issue #2155
It adds two new attributes to the
Questionclass:use_shortcuts: booluse_filter_search: boolWhich are passed down to
questionary, thus producing the desired effect.Note
use_filter_searchis not compatible withuse_jk_keysquestionaryoption which is activated by default. Thus, whenuse_filter_searchisTruefor aselect/checkboxquestion, we pass and putuse_jk_keystoFalse.Choice
Although, it is possible to pass both
{use_filter_search: True, use_shortcuts: True}forselectquestions, I have decided to makeuse_filter_searchhave precedence overuse_shortcutsto avoid any ambiguity. Thus, if both areTruefor aselectquestion, onlyuse_filter_searchis passed and activated.Usage
use_shortcutscopier.yamlThis will display:
And pressing
3will direct the cursor onto3) three.use_filter_searchcopier.yamlPressing
twill make a field appeared at the bottom left with/ t...while only showing:Next, pressing
wwill change the bottom field to/ tw..while only showing:Pressing Backspace will delete the searched letter one at a time, allowing for correction or new/additional filter search.
Limitation
The two new attributes are only booleans, they are not
str|bool, and not rendered.