Skip to content
This repository has been archived by the owner on Nov 9, 2021. It is now read-only.

Route file ignored when both file and directory present. #104

Open
henrymazza opened this issue Jan 20, 2017 · 5 comments
Open

Route file ignored when both file and directory present. #104

henrymazza opened this issue Jan 20, 2017 · 5 comments
Labels

Comments

@henrymazza
Copy link

henrymazza commented Jan 20, 2017

Crumbly doesn’t honor Ember convention: authors/Index.js route isn’t parent of authors/posts.js, it’s actually the default route. Loading /authors/1/posts will not load index model, so can’t compute properties to make a “Jack > Posts” type of crumbs. User gonna see “Authors > Posts” then navigate away and back again to see “Jack > Posts” and get confused.

There’s an authors.js route adjacent to authors directory which will load model and compute its properties but it gets ignored. Most people use index, ok, but no excuse to ignore the right file.

PS: It may be related to #99 (but with less commas)

@dguettler
Copy link
Collaborator

@henrymazza yes I agree with you. ember-crumbly should not render foo.index when visiting /foo/bar

The current proposed solution:
/foo/bar renders foo and bar.index crumbs
/foo renders foo.index crumb if it exists otherwise fallback to foo crumb

Related #99 #83

@dguettler
Copy link
Collaborator

I was playing with this yesterday and it actually gets a bit complicated / messy if you have nested routes under an index route

    this.route('sections', function() {
      this.route('index', { path: '' }, function() {
        this.route('new');
        this.route('edit', { path: ':section_id/edit' });
        this.route('delete', { path: ':section_id/delete' });

        this.route('menus', { path: ':section_id/menus' }, function() {
          this.route('new');
          this.route('edit', { path: ':menu_id/edit' });
          this.route('delete', { path: ':menu_id/delete' });
        });
      });
    });

Wondering if anybody else is using similar routing structure or if I'm covering an extreme edge case here.
@henrymazza @andrewfan @sergproua @mrkirchner @knownasilya

@dguettler
Copy link
Collaborator

@henrymazza @andrewfan @sergproua @mrkirchner @knownasilya
Can you try out ember-crumbly@2.0.0-alpha.0
The following will be rendered now

foo                      :: foo.index
foo.bar.index            :: foo > bar.index
foo.bar.baz.index        :: foo > bar > baz.index

sections                 :: sections.index
sections.index.new       :: sections > index > new
sections.index.menus.new :: sections > index > menus > new

@mrkirchner
Copy link

Seems to work as you described but i am not sure i agree with the proposed solution:

/foo/bar renders foo and bar.index crumbs
/foo renders foo.index crumb if it exists otherwise fallback to foo crumb

Shouldn't bar also fallback to bar crumb if index doesn't exist? Right now even if i define a breadcrumb at the bar route it is not used when the last crumb. I have to add index route with breadcrumb for almost every route now.

breadcrumb order i believe should always be

index (if exists and breadcrumb defined) > route (if breadcrumb defined) > route name

@dguettler

@dguettler
Copy link
Collaborator

Index probably exists (ember generates it), that's why it's not falling back to bar.
I can see your point that in the case of index you'd want to check if a bread crumb is actually defined as it's rather unlikely someone really wants to see "Index" as a breadCrumb.
So I assume the majority of people would set an explicit breadCrumb for index if desired.
I'll look into how to implement this...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants