-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add form for reassigning users to places #257 #258
base: 185_multiple_places
Are you sure you want to change the base?
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.
Hi @freddieptf
Thanks for this. I interacted with it but it was unsuccessful.
-
I was getting invalid link due to the regex not matching correctly.
-
After tinkering with the regex I was able to see it work but I have a question. In the Admin app I can see the place has been added to the new contact
westi
and when I login I can see the places
However, I still see the place when I login as the user test
. Is that the expected behavior after re-assigning ?
src/routes/reassign.ts
Outdated
const body = req.body as { [key:string]:string }; | ||
const contactType = Config.getContactType(body.place_type); | ||
|
||
const uuidMatch = body.contact.match('/contacts/(?<uuid>[a-z0-9]{32})'); |
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 regex is not correct.
- I don't think you should use the string inside the match because that will literally search for the string
'/contacts/(?<uuid>[a-z0-9]{32})'
instead of using it as a pattern. - The regex should also match hyphens that are in the contact uuid.
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.
The regex is cause of a weird thing i found, place UUIDs had hyphens but people did not. I thought this was consistent behavior but I just checked on a live instance and it seems this is not always the case. I'll update this
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 don't think you should use the string inside the match because that will literally search for the string '/contacts/(?[a-z0-9]{32})' instead of using it as a pattern.
The regex worked for me when i had UUIDs without hyphens
@Benmuiruri good catch, I'll update this to remove the place from the other user and if the user only had one place assigned then i can just delete 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.
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 @freddieptf the reassignment works.
I have not checked everything but here is one thing I found. When you reassign a place from person A to person B. We change the contact person of the place and replace it with person B. If you want to reassign the place back to person A, how would one go about that? We now cannot find the person. Check attached video
Contact disappears
Screen.Recording.2025-02-28.at.18.20.53.mov
The behavior you observed was due to the fact that the contact was only supervising one place. If a contact is only supervising one place and the place gets assigned to another person, then their user account gets disabled and their contact gets deleted.
They'd have to get their contact and user created manually on the instance. This process can be improved in #257 |
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.
The happy path works to reassign a CHU but I have left some comments and questions that could make the implementation more robust (in terms of error handling) and DRY. I highlighted some places you should consider error handling but review the various API calls and data processing to ensure things fail as expected.
Suggested improvements
- When you submit an incorrect uuid the application fails silently by logging the error message but when you click done, the page breaks with
Site cannot be reached
- when you submit a correct contact link but that person is a CHP it shows failure 400, that error message should better communicate to the user why it failed (Selected contact is not a CHA)
- when you submit a correct contact link of a person who is not a CHA it fails silently in the terminal but the page breaks and you get
Site cannot be reached
- When reassignment is successful, we could improve the feedback to the user with something like
Successfully reassigned place xxx to user yyy
in green. The success is good but it is immediately clear that the process succeeded.
@@ -184,6 +193,16 @@ export class ChtApi { | |||
})); | |||
} | |||
|
|||
async getUser(contactId: string): Promise<UserInfo> { | |||
const url = `api/v2/users?contact_id=${contactId}`; | |||
console.log('axios.get', url); |
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.
delete console.log
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.
These are actually needed when debugging both in dev and prod, that's why every request in cht-api
has a log statement
|
||
fastify.get('/reassign', async (req, resp) => { | ||
const { place_type } = req.query as any; | ||
const contactType = Config.getContactType(place_type); |
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.
Do we need error handling here if getContactType fails ?
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.
Not strictly, the user would have to manually edit the query param in the URL for this to fail
> | ||
https://{{ session.authInfo.domain -}} | ||
</a> | ||
then copy and paste their link below |
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.
It is common throughout the UMT to need to "look up information in eCHIS". In all cases, the user types the name of whatever contact they are looking for.
This is quite a paradigm shift here! We are breaking the pattern and expecting completely different information. It requires the use of a browser instead of using the app. I think it will increase training burdens.
Why can't the user provide the standard inputs to specific a CHU? CHUs have only one primary contact and so the CHA can be specified easily through existing means. I think it makes sense to allow users to provide a UUID any time they are prompted to search for a place. Like you can type "Matunga" or you can copy/paste the place's UUID.
I'm concerned about supporting only UUIDs in this single part of the UI here...
Can you share your thinking on why your approach is so different?
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.
In all cases, the user types the name of whatever contact they are looking for.
I don't feel like we can guarantee a performant search as is, that's why i opted for copying the URL from the CHT. If we can provide the same "general search" experience as the CHT then i think that might be better than copying the URL/UUID especially if we can get the contact hierarchy in the results as well.
@@ -35,6 +35,9 @@ | |||
</a> | |||
<div class="navbar-dropdown"> | |||
{% for placeType in contactTypes %} | |||
{% if placeType.can_assign_multiple %} |
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.
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.
It was never there, you click "Add x" as before and if the instance version is >= 4.9.0 and can_assign_multiple
is set then it loads the new form
@@ -0,0 +1,132 @@ | |||
<div |
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 this experience would be more intuitive if the elements on the form were reordered. what do you think of having "stuff there is only one of" first (CHA information) and the "n element dynamic content with table" at the end?
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.
My thinking here is since CHU's are the focus of re-assignment, they should be first and have more emphasis. I'm trying to make that clear via the UI. Placing the CHA first could make it seem like the CHA will be reassigned to the areas the user is adding and removed from the areas they already supervise
<input name="place_type" value="{{contactType.name}}" hidden> | ||
|
||
<div class="p-2 mt-2" style="border-left: thick solid green;"> | ||
<p>Search and add a {{ contactType.friendly }} below</p> |
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.
Instead of these three
tags, I suspect it would be clearer if they were just titles.
- "Specify the CHA receiving reassignments"
- "Add the CHUs to reassign"
- "Staged Reassignments"
</div> | ||
</div> | ||
|
||
{% if places and places.length > 0 %} |
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 is another paradigm shift to have the table, staging, and upload progress here on the form instead of on the homepage. I have two broad concerns.
First concern is that I'm unclear how you're going to implement CSV import for CHA reassignment and creation. Will there be another form with another table? Rows don't appear editable presently which is key to CSV import experience. Do warnings work? How do you retry if things fail (I tested and didn't see an error).
Would you provide a mockup of how you're expecting the top-level nav to work for this? I think CSV important is really important, so it'd be good to think some of these things through and get on the same page before proceeding too far.
My second concern is just around consistency of the experience. Currently staging and uploading is orchestrated on the home page. I'm not saying what is done here is undesirable, but it is inconsistent.
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.
Would you provide a mockup of how you're expecting the top-level nav to work for this? I think CSV important is really important, so it'd be good to think some of these things through and get on the same page before proceeding too far.
All the items under Manage
on the navbar should have a status page/list of their own. We can have tabs on the homepage or different pages for these
Will there be another form with another table? Rows don't appear editable presently which is key to CSV import experience. Do warnings work?
Yes there will be another form and table reusing the views in this one. I don't think we need warnings/validation as the places are already created.
How do you retry if things fail (I tested and didn't see an error).
Right now, unfortunately, restart from scratch. This will be improved
8b7f131
to
d3756dc
Compare
d3756dc
to
87b4f23
Compare
Part of #185
Fixes #260
This adds the form for re-assigning a user to a place.