-
-
Notifications
You must be signed in to change notification settings - Fork 216
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
Distinguish User Data Field required for Web User or Mobile Worker #35218
base: master
Are you sure you want to change the base?
Conversation
…hould be required for
…t is relevent for
…with the default value for User Custom Data Fields
🔍 Existing Issues For ReviewYour pull request is modifying functions with the following pre-existing issues: 📄 File: corehq/apps/custom_data_fields/edit_model.py
Did you find this useful? React with a 👍 or 👎 |
695131e
to
c5c7fd6
Compare
…oncept and is consistent with model definition
…nce instead of the contents of the list. So the intial value did not match to its corresponding option and was not set correclt on the select element dropdown. This change finds the match and sets the intial value as the same reference as that on requiredForOptions so that the <select> element will correctly identify the match
c5c7fd6
to
034792b
Compare
…ango serialization and outputting expected values
…ot required as defined by field's required_for
UI thought: What if this were a dropdown of "Mobile Workers", "Web Users", "both", or "neither"? That seems simpler to think about than a checkbox plus a dropdown. |
user_fields_definitions = CustomDataFieldsDefinition.objects.filter(field_type=CUSTOM_USER_DATA_FIELD_TYPE) | ||
|
||
for definition in user_fields_definitions: | ||
Field.objects.filter(definition=definition).update(required_for=DEFAULT_REQUIRED_FOR) |
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.
Isn't this a change from current behavior? From skimming the ticket and design document, it sounds like right now fields are required for both mobile and web users. It sounds like mobile workers only is the desired default behavior, but are you certain this change won't affect existing projects in a way they don't expect?
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.
Yes it is a change in current behavior and you're correct that right now, fields are required for both mobile and web users. We discussed/are discussing it in this comment thread. The decision from that discussion thread was to migrate existing projects to have required fields apply to "mobile worker".
But you're right that it would be disruptive to change current behavior. So I think the better strategy would be to migrate such that required fields still apply to both web users and mobile workers. And then domains who do not want required fields applied to web users can configure it as such. I followed up in that comment thread to get Mruga's thoughts
Skimmed and left a couple of comments, didn't review closely. |
I did consider including a "None" option in the dropdown and getting rid of the checkbox. But I'm assuming most fields are not going to be required so I think it reduces clutter to just have a checkbox and not unnecessarily display a bunch of dropdowns with text. Also, this same input template is used for other custom data fields so it would also be more consistent to use a checkbox for them all (rather than having only a dropdown here and a checkbox for the other ones) |
Product Description
When editing a User Field, checking "Required" will also display a dropdown with the selection "Web Users", "Mobile Workers" or "Both". When
Technical Summary
USH-4867
Design Spec
Commits are fairly clean, can review commit by commit.
Feature Flag
no FF
Safety Assurance
Safety story
Tested locally and on staging. The blast radius is limited to Custom User Data.
Automated test coverage
Added tests
_make_field
is_field_required
to check if a field is required (taking into considerationrequired_for
)CustomDataFieldsDefinition
worksQA Plan
QA-7171
Migrations
Rollback instructions
Labels & Review