Feature #2698
closedSelect the value if the required select box has only one value
100%
Description
If a select box has only one possible value, and the value is required, choose the value by default.
Use case:- A local administrator has rights to manage users in only one organization. When creating a new user, the admin shouldn't select the organization at all, it should be automatically selected.
- Other places were it's usual to have only one value - mapping for the synchronization etc.
Related issues
Updated by Radek Tomiška almost 4 years ago
- Assignee changed from Radek Tomiška to Vít Švanda
- Estimated time set to 8.00 h
Updated by Vít Švanda over 3 years ago
- Status changed from In Progress to Needs feedback
- Assignee changed from Vít Švanda to Radek Tomiška
- % Done changed from 0 to 90
Implemented new attribute for select box component "useFirstIfOne".
Use the first searched value if exists only one and if selected value is empty. By default is attribute undefined and in that state is selected first result only if select box is required.
Commit: https://github.com/bcvsolutions/CzechIdMng/commit/ac119003f94d347b99f30bfabce21cc2b57517ae
Updated by Vít Švanda over 3 years ago
Fix for default behavior.
Commit: https://github.com/bcvsolutions/CzechIdMng/commit/eb0c7693ff4707bbd78945fe6679806a2e917c4d
Updated by Radek Tomiška over 3 years ago
- Status changed from Needs feedback to In Progress
- Assignee changed from Radek Tomiška to Vít Švanda
I did test and code review.
Review notes
- Feature works on default identity contract detail, when work position is required (by form projection), awesome. But selected value cannot be cleared => selected value is returned after clear action again.
- Feature didn't work in form projection for required work position.
- Feature could work in EnumSelectBox the same way. It make sense mainly, when EnumSelectBox has dynamic options.
Updated by Vít Švanda over 3 years ago
Thanks for feedback. I fixed problem on projection detail. It was about "null vs undefined". Same problem was also for "useFirst", I fixed it too.
Commit: https://github.com/bcvsolutions/CzechIdMng/commit/88564ab4b0ca637225f716c71db748453aa05371
Updated by Vít Švanda over 3 years ago
- Status changed from In Progress to Needs feedback
- Assignee changed from Vít Švanda to Radek Tomiška
- I implemented disable a clear button if only one item is available and no filter (input) is used and if a select box is required.
- Empty item (no selection) is hidden too.
- I didn't implement this feature for enum component, may be in feature in new ticket.
Commit: https://github.com/bcvsolutions/CzechIdMng/commit/5f8413f1ab0c1bc021faad328d78071dc828da5d
Updated by Radek Tomiška over 3 years ago
- Status changed from Needs feedback to Resolved
- Assignee changed from Radek Tomiška to Vít Švanda
- % Done changed from 90 to 100
I did test and code review, feature works in projection now and clerable button (and option) is hidden by default. Code is nice too, thx!
Note: I found just one trivial issue - when record is selected by tree modal window, then clearable button is shown again (empty option is not shown correctly). It's rare UC, so I'm closing this ticket.
Updated by Vít Švanda over 3 years ago
- Status changed from Resolved to In Progress
Updated by Vít Švanda over 3 years ago
- Status changed from In Progress to Needs feedback
- Assignee changed from Vít Švanda to Radek Tomiška
Fixed problem with case, where a selectbox is rquired and user filtering items by selectbox input. If only one remains, then the selectbox select last one, but component is still unvalid.
Solution is not use this feature, if input filtering is uses.
Commit: https://github.com/bcvsolutions/CzechIdMng/commit/0976cc2279771ef08314dd8eb16c0126dbb060ba
Updated by Radek Tomiška over 3 years ago
- Status changed from Needs feedback to Resolved
- Assignee changed from Radek Tomiška to Vít Švanda
I did test nad code review, it works and code is nice, thx!
Updated by Radek Tomiška over 3 years ago
- Status changed from Resolved to Closed
Updated by Radek Tomiška over 3 years ago
- Related to Defect #2841: When we can assign only one role, the modal window is stuck added