Skip to content
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

Transition error on nested routes #646

Open
AlexAndBear opened this issue Nov 28, 2019 · 1 comment
Open

Transition error on nested routes #646

AlexAndBear opened this issue Nov 28, 2019 · 1 comment

Comments

@AlexAndBear
Copy link

Ember version: 3.13.2
Liquid-fire version: 0.31.0

Hello there, I have a very nested route structure, and I am facing an error when I try to transition from deep nested route to index.

This is my router.js

import EmberRouter from '@ember/routing/router';
import config from 'ember-get-config';

const Router = EmberRouter.extend({
  location: config.locationType,
  rootURL: config.rootURL,
});

Router.map(function() {
  this.route('login');

  this.route('settings', function() {
    this.route('me');
    this.route('users', function() {
      this.route('new');
      this.route('edit', { path: ':user_id' });
    });
    this.route('channels', function() {
      this.route('edit', { path: ':channel_id' });
    });
    this.route('measurement-methods', function() {
      this.route('edit', { path: ':measurement_method_id' });
    });
  });

  this.route(
    'measurement',
    { path: '/measurement/:measurement_id' },
    function() {
      this.route('meta', function() {
        this.route('project');
        this.route('building');
        this.route('measurement');
        this.route('customer');
        this.route('measurement-order');
      });
      this.route('detail', function() {
        this.route('chart');
      });
    },
  );
  this.route('measurement-compare');
});

export default Router;

transitions.js

export default function(){
  this.transition(
    this.use('toUp'),
    this.reverse('toDown'),
    this.debug(),
  );
}

I have implemented {{liquid-outlet}} everywhere, but if I try to transist from :

http://127.0.0.1:4200/measurement/OP4_s24B7pZs8twILklt/detail

or other any route on mearuement to e.G index via:

{{#link-to 'index'}}
go back
{{/link-to}}

I will end up with this error:

index.js:166 Uncaught Error: Assertion Failed: You attempted to generate a link for the "measurement.detail.index" route, but did not pass the models required for generating its dynamic segments. You must provide param `measurement_id` to `generate`.
    at assert (index.js:166)
    at Class.computeLinkToComponentHref (index.js:2862)
    at index.js:3339
    at untrack (index.js:1253)
    at ComputedProperty.get (index.js:3338)
    at Class.CPGETTER_FUNCTION [as href] (index.js:1044)
    at getPossibleMandatoryProxyValue (index.js:1275)
    at get (index.js:1348)
    at index.js:390

Seems, like the transition want let me walk back to /measurement instead of index.
If I use the standard {{outlet}} everything work fine,

hope you could help me out.
Thank you!

@jagthedrummer
Copy link

jagthedrummer commented Mar 10, 2021

I recently ran into this same thing and doing what the error suggested fixed it for me. It seems that liquid-outlet needs you to specify every dynamic segment every time, where a regular outlet is more forgiving.

In my case I have a nested route for showing galleries and gallery members like:

galleries/:gallery_id
galleries/:gallery_id/:gallery_member_id

In my gallery-member template I was originally linking back to the gallery without passing in a model, and Ember would "remember" that it already has a gallery model. This works fine with a regular outlet but breaks with a liquid-outlet.

<LinkTo @route='gallery'>Back to the gallery</LinkTo>

To fix it I added an explicit @model to the link. This makes the liquid-outlet happy and also works with a regular outlet.

<LinkTo @route='gallery' @model={{model.gallery}}>Back to the gallery</LinkTo>

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

No branches or pull requests

2 participants