-
Notifications
You must be signed in to change notification settings - Fork 78
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
Simplify comments list behavior so API requests are consistent with other types of records. #647
Conversation
…ther types of records.
@begedin sure, create an issue, but make it low priority. |
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.
LGTM 👍
setupController(controller, task) { | ||
let user = this.get('currentUser.user'); | ||
let newComment = this.store.createRecord('comment', { user }); | ||
return controller.setProperties({ newComment, task }); |
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 the return
here isn't necessary. setupController
does not return a value by default:
http://emberjs.com/api/classes/Ember.Route.html#method_setupController
It should be fine to just do controller.setProperties({ newComment, task });
without the return
controller.set('newComment', models.comment); | ||
controller.set('comments', models.comments); | ||
setupController(controller, task) { | ||
let user = this.get('currentUser.user'); |
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 out of the scope of this PR, but I never like fetching properties directly from Services. It would be nice to have a getUser
method:
this.get('currentUser').getUser();
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.
@sbatson5 so we don't lose this, would you want to open an issue here or do a quick PR for this?
…ther types of records.
7c6c7d2
to
819eb85
Compare
What's in this PR?
This makes it so that, on the
project.tasks.task
route, instead of explicitly fetching comments for the task, we instead simply bind totask.comments
instead.This change causes the following
projects/:id/tasks/:number/comments/
route. Instead, we simply fetch from/comments/
using coalesced id requests.model
andsetupController
hooks for theproject.tasks.task
route are much simpler.Further options
We could potentially further simplify things.
The
setupController
hook could check if the session is authenticated and simply push a new comment into thetask.comments
collection.The
comment-list-component
could then be the one that displays either acomment-item
component, or some sort ofcomment-item-edit
component, which can be used both for new and existing comments, depending on anisEditing
flag.I believe it would reduce and dry up the code related to this section of the app a good deal, but it can be done in a separate PR. @joshsmith I can create an issue if you think it makes sense to do so. The behavior would be similar to what we're doing with donation goals.
References
Fixes #644
Progress on: code-corps/code-corps-api#372