-
Notifications
You must be signed in to change notification settings - Fork 1
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
Support multiple roles on a contact type #86
Conversation
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.
Nice work, buddy! Really really nice start on this work.
README.md
Outdated
@@ -44,6 +44,7 @@ Property | Type | Description | |||
`contact_types.replacement_property` | Property | Defines how this `contact_type` is described when being replaced. The `property_name` is always `replacement`. See [ConfigProperty](#ConfigProperty). | |||
`contact_types.place_properties` | Array<ConfigProperty> | Defines the attributes which are collected and set on the user's created place. See [ConfigProperty](#ConfigProperty). | |||
`contact_types.contact_properties` | Array<ConfigProperty> | Defines the attributes which are collected and set on the user's primary contact doc. See [ConfigProperty](#ConfigProperty). | |||
`contact_types.user_roles_property` | ConfigProperty | Defines the property used for specifying user role(s) when creating users of this contact type. Add flexibility to choose role(s) when there are multiple roles available at this level of your hierarchy. See [ConfigProperty](#ConfigProperty). |
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.
I think it is important that we somehow capture the "allowed roles" at each level. Currently, this feature supports free-text input but what if somebody uses the wrong case? What if they use a CHW role for a supervisor user (this can actually result in quite serious bugs)? What if there are trailing spaces on the role, which is super common when working with CSVs?
Ideally, I think the best user experience for this feature would be a set of checkboxes like in the CHT today (see screenshot). You don't need to implement that UI here in this PR, we can start with free-text; but if we capture the "allowed roles" and validate them, I think that's a good start.
There are probably a few ways to approach this. But you'll want to validate this propery like the other property types. You'll probably end up with something like argument: ["role1", "role2"]
.
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.
This conversation may be useful or consideration.
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.
Tried to use it, but since select_multiple
only accept parameter
to be object for the moment (not simple array).
Got a simple role validator
that can do the job, maybe the time to complete select_multiple
feature.
…upport-multiple-level-roles
Hi @kennsippell, thank you for your thorough review - I have worked on them. |
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.
Great progress @paulpascal !
…upport-multiple-level-roles
Hello @kennsippell, had some work after our discussion, and made changes accordingly. Many thanks |
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.
Nice. Feels very close!
import { ContactProperty } from '../config'; | ||
import { IValidator } from './validation'; | ||
|
||
export default class ValidatorRole implements IValidator { |
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.
can this be repalced with @inromualdo 's select_multiple
? or are you planning to keep this?
i assumed you're going to delete this; so i didn't review this file. let me know if this is incorrect
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 @kennsippell , of course. Was waiting for his work to be validated to rebase.
But I can rebase right now it is okay with you.
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.
ideally i think we would set Ro's work to be the base branch for this work. then we would merge Ro's PR first.
given the circumstances, i'm fine with pushing this change forward as-is and we can ensure we delete it in Ro's PR
Thanks @kennsippell , feedback addressed |
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.
Very well done, sir
import { ContactProperty } from '../config'; | ||
import { IValidator } from './validation'; | ||
|
||
export default class ValidatorRole implements IValidator { |
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.
ideally i think we would set Ro's work to be the base branch for this work. then we would merge Ro's PR first.
given the circumstances, i'm fine with pushing this change forward as-is and we can ensure we delete it in Ro's PR
<tr> | ||
<td>{{ userRoleProperty.friendly_name }}</td> | ||
<td>{{ userRoleProperty.required }}</td> | ||
<td>Role of the user. Specify multiple roles with <i>space</i>. Allowed roles are <i>{{ contactType.user_role | join: ', ' }} |
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.
<td>Role of the user. Specify multiple roles with <i>space</i>. Allowed roles are <i>{{ contactType.user_role | join: ', ' }} | |
<td>Role of the user. Separate multiple roles with a <i>space</i>. Allowed roles are <i>{{ contactType.user_role | join: ', ' }} |
Can you have a space
in a valid CouchDB role? If so, we should change to ,
.
Fix #69
user_role
tostring[]
userRoleProperty
anytime we may need it (default property_name, type,... and only passing theuser_role
asparameter
)Place
andPlaceFactory
to process the new propertyValidatorRole
to handle checkselected roles
againstuser_role
(behaving asallowed roles
when having more than one item)UserPayload
(to only userole
and no moretype
)