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 subroutes #24
Add subroutes #24
Conversation
return this.store.queryRecord('rental', { title: params.title }) | ||
}, | ||
|
||
setupController(controller, model) { |
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.
me no like, is this in the prose @toddjordan ?
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 thought it made the template more readable to access it as rental
instead of model
but I can revert it, nbd. Is it considered bad practice to use setupController
in this way?
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 it's slightly controversial, but I personally think it's unnecessary and unexpected, since you expect the model
property to be set with what's returned from the model hook.
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 other words, there's some valid use cases for setupController
but they're fewer than most people think they are ;)
Looks good :-) I was thinking that you could use transitionTo from the index route to redirect users going to '/' to the new rentals route. http://emberjs.com/api/classes/Ember.Route.html#method_transitionTo Also take a look at the last merge, we've added styling and changed the markup a bit. |
@@ -0,0 +1,6 @@ | |||
<ul> |
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'd expect this template to reflect the content that currently show in the homepage (using this template instead)
@@ -0,0 +1,5 @@ | |||
<ul class="results"> | |||
{{#each model as |rentalUnit|}} | |||
{{rental-listing rental=rentalUnit goToShowRoute="goToShowRoute"}} |
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.
Added an action to make the component clickable per recommendation here:
emberjs/guides#1443 (comment)
Wondering if this is out of scope for a tutorial on sub-routes. Not sure I want to encourage writing actions this way with closure actions and the route-action helper becoming more prominent. But I don't want to introduce a controller just for the sake of a closure action.
Anyone have thoughts on a faster way to do this that doesn't take much explaining for a beginner's tutorial? Maybe just wrap component in a div and add the action to that?
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 You should just wrap rental listing in a {{link-to}} like this:
{{#link-to "rentals.show" rentalUnit.slug}}
{{rental-listing rental=rentalUnit}}
{{/link-to}}
and remove all the "goToShowRoute" stuff
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 was definitely overcomplicating it 😛
I created a PR to your branch with what I was talking about: https://github.com/sbatson5/super-rentals/pull/1 |
@@ -0,0 +1,22 @@ | |||
<div class="jumbo"> | |||
<a href="#" class="button right up-11">Edit</a> |
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.
@toddjordan Do you want an edit
subroute added to this tutorial?
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.
good question. We've been recently discussing whether to add a form section to the tutorial, and edit would be the logical place to do it. What I think is having the one subroute is fine for now, and when we add forms to the tutorial is when we would add the edit subroute.
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.
So go ahead and remove edit and we'll add it back when we introduce a forms section
@toddjordan Thanks! Added a PR: toddjordan/ember-cli-tutorial-style#1 |
Cool. I'll merge and re-publish the addon |
@sbatson5 I updated the super-rentals repo with the updated version of the style addon with your update. you can rebase it into this pr... Also we'll need to squash commits before merge. |
also, currently seems some of the tests are failing in this pr |
Rebased and squashed commits. But not sure why Travis is failing. Have any insight @toddjordan ? Also, I saw your PR I merged into this branch had changes to the |
I was able to correct the listing style issue by updating the ember-cli-tutorial-style addon to be more specific about an anchor style. It seems adding the anchor to the listing for the subroute was picking up an unwanted style. |
I updated the addon, all you'll need to do to fix is Update the ember-cli-tutorial-style version to 0.0.4! I think it'll be then be good to go then and we can focus on getting the tutorial guide page out 👍 |
@toddjordan Thanks so much for catching that. I saw that styling last time but just thought that npm hadn't updated. Forgot to go back and check it. Will update. |
@toddjordan I updated it to |
Hmm I'll recheck tomorrow
|
I'm kind of stumped on this. When I look in |
Sorry been on vacation and didn't get to it as planned. Should be able to
|
@sbatson5 How did you update? The vendor css only gets updated when you run the blueprint, which comes from |
Ah, I was just doing |
Awesome. I think this is good to go. I'll hold off on merge until we merge the tutorial guides PR. I'll look that that this week. |
add unit-tests for sub-routes re-use rental-listing component add slug to mirage config JSON
Created a new branch out of this one for remaining updates. Closing in favor of: #35 |
WIP PR for adding sub-routes per:
emberjs/guides#1374