dev/core#1451 Incorrect dropdown action choices on case type listing screen #16035
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
There's some incorrect boolean comparisons being made against strings and undefined that prevent the dropdown list from appearing or showing appropriate choices. For example you should be able to delete the stock case types from the UI, or when you disable a case type the dropdown action to enable should be there but it still says disable.
Before
After
Choices as intended.
Note also that unless you've done something in code or in the database directly to set is_reserved=1, there will almost always be a dropdown with at least something in it. I'm not sure what is_reserved means here though because you can still edit the type, but that's maybe a separate question. The stock types are not reserved.
Technical Details
The below javascript code will output true for both. And similarly
if (!x)
would output false for both.So for example where it used to check
!caseType.is_reserved
to determine whether to show Delete, it still wouldn't show it even if is_reserved="0". Note also that is_reserved might not even be present, which is why I've used!=1
which covers both situations.The addition of the classes in list.html is to support the test.
Comments
I guess maybe nobody's questioned it because you might assume the screen doesn't let you delete the stock case types because there's something special about them. But there isn't. And not showing "Enable" is only a minor annoyance because you can just edit the type and check the box, or if you decide to click disable again anyway it actually enables it.