GeriLife / companionship

Promoting companionship and well-being for everyone.
European Union Public License 1.2
7 stars 18 forks source link

Ability to remove companions #28

Closed brylie closed 2 years ago

brylie commented 2 years ago

Some companionship relationships may be temporary. As such, the care coordinator may need to remove existing companions.

Task

Specification

Example code

The following code snippets may be useful as examples related to this task.

Checking if request User is one of Person's organizers https://github.com/GeriLife/companionship-care/blob/d7cdcdc1a37e5bd08f9c7b6a26a8116b9571ce5e/project/people/templates/people/person_detail.html#L104

Preventing a user from removing themself by checking equality (in our case, it should be !=) https://github.com/GeriLife/companionship-care/blob/d7cdcdc1a37e5bd08f9c7b6a26a8116b9571ce5e/project/people/templates/people/person_activity.html#L70

Linking to a specific view, using the view name and optional arguments https://github.com/GeriLife/companionship-care/blob/d7cdcdc1a37e5bd08f9c7b6a26a8116b9571ce5e/project/people/templates/people/person_detail.html#L130-L132

Ensuring only a Person's organizer can perform database operations related to that person https://github.com/GeriLife/companionship-care/blob/d7cdcdc1a37e5bd08f9c7b6a26a8116b9571ce5e/project/people/views.py#L130-L137

Redirect to Person's detail view after removing the companion: https://github.com/GeriLife/companionship-care/blob/d7cdcdc1a37e5bd08f9c7b6a26a8116b9571ce5e/project/people/views.py#L154

ritikBhandari commented 2 years ago

Hi, This issue looks good for my level. Can I work on this if not urgent?

brylie commented 2 years ago

@ritikBhandari, sure thanks! I'll assign you. I can also provide some guidance on the task.

ritikBhandari commented 2 years ago

So eventually we have to solve #24 right?

brylie commented 2 years ago

I've updated the issue description with a specification to clarify the intent and some code examples that could be useful to follow.

brylie commented 2 years ago

@ritikBhandari, yes, #24 is related to this issue. We can include this issue as part of #24 or handle them separately if desired. What would be your recommendation?

ritikBhandari commented 2 years ago

I guess we can include this issue as part of #24 since it is part of the UI settings proposal and we can have a clarity on what all tasks have been completed from the same #24

ritikBhandari commented 2 years ago

I've updated the issue description with a specification to clarify the intent and some code examples that could be useful to follow.

Yup this is quite good. Atleast provides a fair ground on where to start resolving from.

brylie commented 2 years ago

OK, there is also a pattern we can follow with the modal dialogue for #24

https://github.com/GeriLife/companionship-care/blob/d7cdcdc1a37e5bd08f9c7b6a26a8116b9571ce5e/project/people/templates/people/person_activity.html#L173-L174

The modal dialogue will basically have three action buttons:

I'm a bit concerned about deleting the Companion instance without any confirmation, but don't want to overcomplicate the task(s).

ritikBhandari commented 2 years ago

If we can cancel the dialogue and click the back button(which is already present in the main window), we dont need to add a delete one and over-complicate things. What do u think?

ritikBhandari commented 2 years ago

And if we really want to delete the existing instance, we should create the button in the main window rather than having it in modal dialogue.

brylie commented 2 years ago

Yes, let's just create the button on the main view for now with a confirmation modal. We can improve the user experience later if needed.

ritikBhandari commented 2 years ago

Yes, let's just create the button on the main view for now with a confirmation modal. We can improve the user experience later if needed.

delete one right?

brylie commented 2 years ago

Yes. The user flow would be:

  1. click "remove" button on Companion card
  2. display a modal "Are you sure you want to remove this companion?"
    • clicking "no" dismisses modal
  3. clicking "yes", links to CompanionDeleteView with logic described above

Edit: changed "delete" to "remove" in UI texts.

ritikBhandari commented 2 years ago

That's cool!