2021-03-08 12:15:54 +00:00
|
|
|
import Component from '@glimmer/component';
|
|
|
|
import { inject as service } from '@ember/service';
|
|
|
|
import { action } from '@ember/object';
|
|
|
|
import { tracked } from '@glimmer/tracking';
|
|
|
|
|
|
|
|
export default class RouteComponent extends Component {
|
|
|
|
@service('routlet') routlet;
|
2021-09-15 18:50:11 +00:00
|
|
|
@service('router') router;
|
2021-03-08 12:15:54 +00:00
|
|
|
|
2021-10-07 11:38:04 +00:00
|
|
|
@tracked _model;
|
2021-03-08 12:15:54 +00:00
|
|
|
|
2021-05-26 16:43:46 +00:00
|
|
|
get params() {
|
|
|
|
return this.routlet.paramsFor(this.args.name);
|
|
|
|
}
|
|
|
|
|
2021-10-07 11:38:04 +00:00
|
|
|
get model() {
|
2022-01-07 19:16:21 +00:00
|
|
|
if(this._model) {
|
|
|
|
return this._model;
|
2021-10-07 11:38:04 +00:00
|
|
|
}
|
2022-01-07 19:16:21 +00:00
|
|
|
if (this.args.name) {
|
|
|
|
const outlet = this.routlet.outletFor(this.args.name);
|
|
|
|
return this.routlet.modelFor(outlet.name);
|
|
|
|
}
|
|
|
|
return undefined;
|
2021-10-07 11:38:04 +00:00
|
|
|
}
|
|
|
|
|
2021-03-08 12:15:54 +00:00
|
|
|
@action
|
|
|
|
connect() {
|
|
|
|
this.routlet.addRoute(this.args.name, this);
|
|
|
|
}
|
2021-04-06 12:40:40 +00:00
|
|
|
|
2021-03-08 12:15:54 +00:00
|
|
|
@action
|
|
|
|
disconnect() {
|
|
|
|
this.routlet.removeRoute(this.args.name, this);
|
|
|
|
}
|
|
|
|
}
|