Skip to content
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

feat(#9116): update user place field in admin to allow setting multiple places #9128

Merged
merged 61 commits into from
Jun 20, 2024

Conversation

Benmuiruri
Copy link
Contributor

@Benmuiruri Benmuiruri commented May 16, 2024

Description

This is a continuation of #6543

Now, users can be associated with more than one facility. This PR enables the CHT's Admin app to provide a way to associate those facilities with the user.

To get the feature to work, the admin user must enable can_have_multiple_places to some specific roles (e.g Supervisor, community_health_assistant, etc)

Whenever a new user is added:

  • The dialog displays, and the place field is a multiselect dropdown.
  • The admin submits the form and CHT validates:
    • At least one of the selected roles has can_have_multiple_places
    • Selected places are at the same hierarchy level
    • The user should be a child of at least one of the selected places.
  • CHT displays error in form when above validations don't pass successfully.
  • When editing an existing user, the form should load with the multiselect field prefilled with the user's current place or places. On editing a user the form saves changes correctly

Closes #9116

Code review checklist

  • Readable: Concise, well named, follows the style guide, documented if necessary.
  • Documented: Configuration and user documentation on cht-docs
  • Tested: Unit and/or e2e where appropriate
  • Internationalised: All user facing text
  • Backwards compatible: Works with existing data and configuration or includes a migration. Any breaking changes documented in the release notes.

Compose URLs

If Build CI hasn't passed, these may 404:

License

The software is provided under AGPL-3.0. Contributions to this project are accepted under the same license.

@latin-panda
Copy link
Contributor

@Benmuiruri, this is just a reminder to please enable the test tests/e2e/default/more-options-menu/offline-user/all-permissions.wdio-spec.js so that we can have all the tests working again.

Copy link
Contributor

@ralfudx ralfudx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All AC's in the description look good to me

Copy link
Member

@dianabarsan dianabarsan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool stuff! Great work!
I left some comments mostly about readability and reusability.

admin/src/js/controllers/edit-user.js Show resolved Hide resolved
admin/src/js/controllers/edit-user.js Outdated Show resolved Hide resolved
admin/src/js/controllers/edit-user.js Outdated Show resolved Hide resolved
admin/src/js/controllers/edit-user.js Outdated Show resolved Hide resolved
admin/src/js/controllers/edit-user.js Show resolved Hide resolved
shared-libs/user-management/src/users.js Outdated Show resolved Hide resolved
tests/integration/api/controllers/users.spec.js Outdated Show resolved Hide resolved
webapp/src/ts/modules/contacts/contacts.component.ts Outdated Show resolved Hide resolved
webapp/src/ts/modules/contacts/contacts.component.ts Outdated Show resolved Hide resolved
webapp/src/ts/modules/contacts/contacts.component.ts Outdated Show resolved Hide resolved
@Benmuiruri
Copy link
Contributor Author

Hi @dianabarsan I have made almost all of the requested changes. The one I could not figure out is the suggestion to use _all_docs. Do you mind sharing a suggestion for that one. Thank you 🙏

Base automatically changed from 6543-ui-changes to master June 7, 2024 12:28
@Benmuiruri Benmuiruri force-pushed the 9116-update-admin-place-field branch from 9c72aa4 to 43a970b Compare June 10, 2024 06:18
Copy link
Member

@dianabarsan dianabarsan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Some minor things inline to unblock you. I'll give this a try tomorrow!

admin/src/js/controllers/edit-user.js Outdated Show resolved Hide resolved
admin/src/js/controllers/edit-user.js Outdated Show resolved Hide resolved
admin/src/js/controllers/edit-user.js Outdated Show resolved Hide resolved
admin/src/js/services/select2-search.js Outdated Show resolved Hide resolved
admin/src/js/services/select2-search.js Outdated Show resolved Hide resolved
admin/src/js/services/select2-search.js Outdated Show resolved Hide resolved
admin/src/js/services/select2-search.js Outdated Show resolved Hide resolved
webapp/src/ts/modules/contacts/contacts.component.ts Outdated Show resolved Hide resolved
admin/src/js/services/select2-search.js Dismissed Show dismissed Hide dismissed
admin/src/js/services/contact-types.js Outdated Show resolved Hide resolved
shared-libs/contact-types-utils/src/index.js Outdated Show resolved Hide resolved
admin/src/js/services/select2-search.js Show resolved Hide resolved
@Benmuiruri Benmuiruri force-pushed the 9116-update-admin-place-field branch from 20ae761 to 26cc25b Compare June 14, 2024 08:48
@latin-panda latin-panda linked an issue Jun 18, 2024 that may be closed by this pull request
@Benmuiruri Benmuiruri force-pushed the 9116-update-admin-place-field branch 2 times, most recently from feded91 to 627c2b6 Compare June 18, 2024 15:00
Copy link
Member

@dianabarsan dianabarsan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great stuff! I left one minor comment about unit test coverage.

shared-libs/contact-types-utils/test/index.js Show resolved Hide resolved
@Benmuiruri Benmuiruri merged commit c7fbcb1 into master Jun 20, 2024
41 checks passed
@Benmuiruri Benmuiruri deleted the 9116-update-admin-place-field branch June 20, 2024 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make place field in the user form a multiselect dropdown Allow for multiple places to be assigned to users
4 participants