Giter Club home page Giter Club logo

teachme's People

Contributors

jonathantanmy avatar josegrangersalgado avatar josueetcom avatar jpaints3 avatar obitracks avatar

Watchers

 avatar  avatar

teachme's Issues

User description form field and database property

Make sure to change both the form and the user model and handle it in the user servlet.

This could also be something like what's done for #19 where an alert box lets you type a description, a PATCH /users request is sent and then the data is updated on the page.

Post initial user info in onSignIn()

Here's how you can submit a form from JavaScript:
https://stackoverflow.com/q/35325370

Submit a POST /users request with the user information from the sign in (e.g. name, email, imgURL). It should fail if the user already exists (which is OK).

You can verify you're submitting the proper values through the Chrome Inspector:

  1. Open the Chrome Inspector
  2. Go to the Network tab
  3. Refresh the page
  4. Make sure /users request shows up in the Network tab. If not, it's not being called on sign in.
  5. Click on the /users request you sent.
  6. Make sure it says POST under Request Headers
  7. Check the form data at the bottom section called Form Data is correct.

Populate wishlist/teachlist items on the left bar

  1. Send a GET /users?id=ID request using fetch() where ID is the ID returned from the sign in object.

    Note: This piece of the issue similar to #23 as that also requires sending requests on sign in.

  2. Using the JSON response, populate the teachlist/wishlist items on the left for the current user. Example for how to create HTML elements using JavaScript

If the servlet doesn't work yet, you can mimick a GET response to ensure HTML elements are generated correctly. E.g.

// actual fetch code
// const user = fetch('/users?id=' + user.id)...;
// mimicked user
const user = {
  teachlist: ['foo', 'bar'],
  wishlist: ['baz'],
};
// create the elements

Add button for user wishlist/teachlist section

This issue is similar to #18. You might work on both at the same time.

  1. Create a button to add items to the wishlist/teachlist.
  2. On click, use a prompt to let users enter a new teachlist/wishlist item.
  3. Then using JavaScript submit a PATCH /users request with the user ID and the updated property (the list with the new item added). Example using POST (you should use PATCH for this issue though).

You can verify you're submitting the proper values through the Chrome Inspector:

  1. Open the Chrome Inspector
  2. Go to the Network tab
  3. With the inspector open, add a teachlist/wishlist item.
  4. Click on the /users request you sent in the Network tab
  5. Make sure it says PATCH under Request Headers
  6. Check the form data at the bottom section called Form Data is correct.

Add delete button/icon for each user wishlist/topiclist item

This issue is similar to #19. You might work on both at the same time.

  1. Create a button/icon to delete an item from the wishlist/teachlist.
  2. On click, use a confirm alert box to ensure the user wants to delete the item in case it was a misclick.
  3. Then using JavaScript, submit a PATCH /users request with the user ID and the updated property (the list with the deleted item removed). Example using POST (you should use PATCH for this issue though).

You can verify you're submitting the proper values through the Chrome Inspector:

  1. Open the Chrome Inspector
  2. Go to the Network tab
  3. With the inspector open, add a teachlist/wishlist item.
  4. Click on the /users request you sent in the Network tab
  5. Make sure it says PATCH under Request Headers
  6. Check the form data at the bottom section called Form Data is correct.

doPatch() UserServlet method to handle partial user updates

To support partial modifications the prope HTTP method to use is PATCH. The client needs to call PATCH /users?id=123&property=value to update properties for a specific user. In the Java Servlet we need to write doPatch() to handle this. It's body should consist of getting the entity and then updating any properties given if set. It'd look something like this:

// Get the user id from the request and make the entity key.
// Get the user
Entity user = datastore.get(userKey);
// Get a builder for the user
Entity.Builder userEntityBuilder = Entity.newBuilder(user);
// Apply teachlist changes if given
if (request.getParameter("teachlist") != null) {
  String items = Jsoup.clean(request.getParameter("addTeachlistItem"), Whitelist.none()).split(",");
  userEntityBuilder = userEntityBuilder.set("teachList", items);
}
// do something similar for other request parameters

datastore.update(user);

Note: Instead of teachlist you could handle instead parameters like newTeachlistItem/removeTeachlistItem, etc.

In any case, make sure doPatch supports updating the teachlist, wishlist, and description of the user (and whatever other properties that might be updateable)

For additional details on updating a Datastore entity: https://cloud.google.com/datastore/docs/concepts/entities#updating_an_entity

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.