ember-crumbly icon indicating copy to clipboard operation
ember-crumbly copied to clipboard

Route file ignored when both file and directory present.

Open henrymazza opened this issue 8 years ago • 5 comments

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)

henrymazza avatar Jan 20 '17 02:01 henrymazza

@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 avatar Mar 19 '17 17:03 dguettler

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 avatar Apr 07 '17 02:04 dguettler

@henrymazza @andrewfan @sergproua @mrkirchner @knownasilya Can you try out [email protected] 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

dguettler avatar Apr 13 '17 03:04 dguettler

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

mrkirchner avatar Apr 13 '17 15:04 mrkirchner

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...

dguettler avatar Apr 15 '17 02:04 dguettler