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

Profile fields should have an edit capability #347

Open
2 tasks done
glenyingchua opened this issue May 17, 2022 · 5 comments
Open
2 tasks done

Profile fields should have an edit capability #347

glenyingchua opened this issue May 17, 2022 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@glenyingchua
Copy link

glenyingchua commented May 17, 2022

Expected behaviour

User can see an edit button beside the fields. When clicked, the field turns from display view to edit view with a save button. User can also press enter to save.

Social media links editing feature will be consolidated through one button beside all the links. When clicked, users can put urls beside social media icons with save button.

Dependent on Issue #346 completion.

Checklist

  • This issue is linked to the appropriate project.
  • This issue has appropriate labels.
@glenyingchua glenyingchua added the enhancement New feature or request label May 17, 2022
achichikalova added a commit that referenced this issue May 31, 2022
achichikalova added a commit that referenced this issue Jun 1, 2022
achichikalova added a commit that referenced this issue Jun 1, 2022
achichikalova added a commit that referenced this issue Jun 1, 2022
sheacronin added a commit that referenced this issue Jun 1, 2022
@sheacronin
Copy link
Collaborator

sheacronin commented Jun 1, 2022

Today we mostly worked on the social network input fields. We created state in the SocialLinks component that stores the social networks so that networks can be added and removed on the frontend. We decided to limit the user to have 5 social networks at most. There is a dropdown of social networks and an input field for the username/data for each added social network. One thing we need to think about is how to submit the social network data to the database in the correct format using the inputs we have created. The GitHub link is not editable, because the user will always have the same GitHub account that they signed in from.

Previously, we created editable fields for the username, email, and bio.

Things to work on:

  • Responsive for smaller screens when in edit mode
  • Connect to the real data
  • Add state for the name, email, and summary to be updated
  • Create a put route to submit new data for when the edit button is toggled off
  • Add onChange function for the social network input field and a function to update the state when the user submits their data
  • Decide whether we will allow users to have multiple social networks of the same network type (like can they add multiple LinkedIn profiles?). We probably want to let them add multiple websites if desired.

achichikalova added a commit that referenced this issue Jun 2, 2022
sheacronin added a commit that referenced this issue Jun 2, 2022
seidior added a commit that referenced this issue Jun 3, 2022
Merging in recent changes from #356 so we can test the editing functionality on the backend.
@seidior
Copy link
Member

seidior commented Jun 3, 2022

Added in the latest changes from #356, so now you should be able to receive an IUserData object from the database, render it, edit it, and send it back to the database (in an HTTP PUT request). The API will handle all the comparisons to see if anything has updated so that you don't have to do anything special to keep track of changes on the frontend or call different methods for different fields that are added/modified/removed.

seidior added a commit that referenced this issue Jun 3, 2022
Latest changes switch from principal_id to id in many cases, conforming to Entity interface and allowing the app to talk to the API.
seidior added a commit that referenced this issue Jun 3, 2022
seidior added a commit that referenced this issue Jun 3, 2022
Working with Antonina to have the social profiles that we get back from the API to be rendered properly.
achichikalova added a commit that referenced this issue Jun 3, 2022
seidior added a commit that referenced this issue Jun 4, 2022
seidior added a commit that referenced this issue Jun 4, 2022
This commit fully removes profile editing capability but now correctly renders a row of social profile icons.
seidior added a commit that referenced this issue Jun 4, 2022
If the greeting functions are passed a null person's name, just say the greeting; for example "Good morning!" instead of "Good morning, Spencer!"
seidior added a commit that referenced this issue Jun 4, 2022
Bare-bones skeleton of editing functionality, bringing back the clickable pencil icon (which may or may not survive, who knows). Also, a button that tests updating the userData in-state so we can eventually send it back to the API.
seidior added a commit that referenced this issue Jun 4, 2022
When you click into edit mode, you can now see some form fields that are pre-filled with the data from your profile.
seidior added a commit that referenced this issue Jun 4, 2022
This includes the changes that were needed once the HTTP PUT route we made could finally be tested.
seidior added a commit that referenced this issue Jun 4, 2022
This commit cleans up a lot of the React-isms: we're not calling the API multiple times, state is being better preserved, and we're finally properly using the session's principal ID. Plus, this has a working demo of HTTP PUT in action! (only for full_name though).
@seidior
Copy link
Member

seidior commented Jun 4, 2022

Hello, OpenTree family! I'm wrapping up for the evening and I'd like to share my progress of where I'm at for the day.

Compared with the state last night, the profile page is now pulling directly from the database for its information with absolutely no placeholder content. (Sorry to our fictional test user!) Huge thanks to @achichikalova and @Nazanin-Rezaei for getting that work started this morning on the front end and to @SiriusLL for working late last night to try tying in the backend stuff.

This afternoon, I completely re-architected the editing / saving functionality based on combining both teams’ work with React best practices. The user data is now being properly loaded into the profile page's state from the API and is being rendered on the front end. Changes to the user data within the state variable get reflected on the page immediately. And that user data object can now be sent to the server for updates!

I've also updated the bio (from GitHub), full_name (from GitHub), and email_address fields (from social networks) to pull the data from their corresponding places if the fields are not defined (such as when first logging in). However, upon first save, all of those fields’ values that were pre-populated from their original places are now copied into the principals table as they should be.

Here's a quick overview of how it looks right now. This is just after first logging in (although I cheated and added some extra social profiles in my database so you could see how it looks with multiple profiles defined):

rhizone_swohlers_20220603_1

This is after clicking the edit button (sorry, I haven't styled anything yet):

rhizone_swohlers_20220603_2

And finally, this is after clicking that big "Change My Name to Something Else" button, which changes the full_name in the userData state variable to "OpenTree Education", then pushes that userData object up to the API using an HTTP PUT. The API then saves that field in the database so future page loads show with the full name field override of "OpenTree Education":

rhizone_swohlers_20220603_3

(And logging out and logging back in preserves those overrides, as it should.)

I’m really happy with the progress we made this week, and the end product is looking closer and closer to the ideal of how we set out initially. Extra thanks to everyone who put in late and early hours to get as much done as possible.

While the commits from today did clear up a bunch of tasks, there’s still lots more detail work to be done such as making the full name editable, making the social profiles actually editable (they just look editable right now but they’re not; I just wanted the form controls pre-populated with data from the database), making the bio editable, and tons of styling work. Plus, I was really pushing today and I could have been a lot better about commenting the code I wrote.

@seidior
Copy link
Member

seidior commented Jun 4, 2022

Decide whether we will allow users to have multiple social networks of the same network type (like can they add multiple LinkedIn profiles?). We probably want to let them add multiple websites if desired.

I'm going to say this is out of scope. Great ideas; however, the purpose of the website is mostly to link to a single portfolio site, and it's unlikely users will ever need to add more than one profile of any other type (the database schema doesn't support this right now, and it'd be tricky to modify at this point).

But insightful out-of-the-box thinking, @sheacronin and @MahoMori.

seidior added a commit that referenced this issue Jun 4, 2022
This will save us time when the work from issues #347 and #356 get merged into main eventually.
seidior added a commit that referenced this issue Jun 5, 2022
This commit adds a status update at the top of the page that shares with the user the status of their edit submission.
seidior added a commit that referenced this issue Jun 5, 2022
Rename the profile page to UserProfile.tsx to clarify between a "user profile" and a "social profile."
seidior added a commit that referenced this issue Jun 5, 2022
Full name updates actually work now.
seidior added a commit that referenced this issue Jun 10, 2022
Now that #356 has reached pull request status, incorporate those changes here so that we ensure the automated API tests are passing.
seidior added a commit that referenced this issue Jun 10, 2022
This will make the future merger with main a lot smoother.
@seidior
Copy link
Member

seidior commented Jun 10, 2022

Daily update: no forward progress was made on this ticket, but I did bring the branch up to date with the latest from #356 which now causes all automated tests on code for the repository to be updated.

I did have to revert a commit from the #356 branch because it affected files in the webapp/ subdirectory. I'll have to manually incorporate those changes here to preserve the work that was done by the mentees.

seidior added a commit that referenced this issue Jun 12, 2022
The full name swaps out for a text field, the social profiles get shoved inside a form group, and the bio field becomes editable.
seidior added a commit that referenced this issue Jun 12, 2022
seidior added a commit that referenced this issue Jun 12, 2022
This version now shows an editing form that allows for users to edit every field of their profile. Instead of an "add social network"/"remove social network" control, if a user blanks out the "user name" field for a social network, that removes it from the list of social networks. The control that allows a user to change public visibility only shows if there's something in the "user name" field. And there's a "cancel editing" button that restores any changes to the user profile to the version that comes from the API.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants