Skip to content

Commit

Permalink
Refresh competences subroutes on view param change
Browse files Browse the repository at this point in the history
Co-authored-by: Iris Benoit-Martin <[email protected]>
Co-authored-by: Jérémie Jadé <[email protected]>
  • Loading branch information
3 people committed Oct 10, 2024
1 parent 218608d commit b88a514
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pix-editor/app/controllers/authenticated/competence.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default class CompetenceController extends Controller {
setView(value) {
if (this.view !== value) {
this.view = value;
this.router.transitionTo({ queryParams: { view: value } });
}
}
Expand Down
6 changes: 6 additions & 0 deletions pix-editor/app/routes/authenticated/competence.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ export default class CompetenceRoute extends Route {
@service store;
@service router;

queryParams = {
view: {
refreshModel: true,
},
};

model(params) {
return this.store.findRecord('competence', params.competence_id);
}
Expand Down
2 changes: 2 additions & 0 deletions pix-editor/app/routes/authenticated/competence/prototypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export default class PrototypesRoute extends Route {
refreshing = false;

async model() {
// eslint-disable-next-line no-unused-vars
const { view } = this.paramsFor('authenticated.competence');
const competence = this.modelFor('authenticated.competence');
if (this.refreshing) {
const themes = await competence.hasMany('rawThemes').reload();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default class SingleRoute extends Route {
if (transition.targetName === 'authenticated.competence.quality.index' && skill.productionPrototype) {
return this.router.transitionTo('authenticated.competence.quality.single', this.currentData.getCompetence(), skill);
} else if (transition.targetName === 'authenticated.competence.skills.index') {
return this.router.transitionTo('authenticated.competence.skills.single', this.currentData.getCompetence(), skill);
return this.router.transitionTo('authenticated.competence.skills.single', this.currentData.getCompetence(), skill.id);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export default class SingleRoute extends Route {
const skill = this.controllerFor('authenticated.competence.skills.single').skill;
const prototype = skill.productionPrototype;
if (prototype) {
return this.router.transitionTo('authenticated.competence.prototypes.single', prototype);
return this.router.transitionTo('authenticated.competence.prototypes.single', prototype.id);
} else {
const tube = skill.tube;
return this.router.transitionTo('authenticated.competence.prototypes.list', tube.get('id'), skill.id);
Expand Down

0 comments on commit b88a514

Please sign in to comment.