From b88a5147b377eceba345d621270296bbace6770f Mon Sep 17 00:00:00 2001 From: Fael BASSETTI Date: Thu, 10 Oct 2024 17:52:55 +0200 Subject: [PATCH] Refresh competences subroutes on view param change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Iris Benoit-Martin Co-authored-by: Jérémie Jadé --- pix-editor/app/controllers/authenticated/competence.js | 2 +- pix-editor/app/routes/authenticated/competence.js | 6 ++++++ .../app/routes/authenticated/competence/prototypes.js | 2 ++ .../routes/authenticated/competence/prototypes/single.js | 2 +- .../app/routes/authenticated/competence/skills/single.js | 2 +- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/pix-editor/app/controllers/authenticated/competence.js b/pix-editor/app/controllers/authenticated/competence.js index 68164a4cc..701c31c32 100644 --- a/pix-editor/app/controllers/authenticated/competence.js +++ b/pix-editor/app/controllers/authenticated/competence.js @@ -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 } }); } } diff --git a/pix-editor/app/routes/authenticated/competence.js b/pix-editor/app/routes/authenticated/competence.js index 9f7e2375e..c91dde877 100644 --- a/pix-editor/app/routes/authenticated/competence.js +++ b/pix-editor/app/routes/authenticated/competence.js @@ -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); } diff --git a/pix-editor/app/routes/authenticated/competence/prototypes.js b/pix-editor/app/routes/authenticated/competence/prototypes.js index 8f8d1156c..dbbf61193 100644 --- a/pix-editor/app/routes/authenticated/competence/prototypes.js +++ b/pix-editor/app/routes/authenticated/competence/prototypes.js @@ -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(); diff --git a/pix-editor/app/routes/authenticated/competence/prototypes/single.js b/pix-editor/app/routes/authenticated/competence/prototypes/single.js index f4303c1ff..41e3a5b2f 100644 --- a/pix-editor/app/routes/authenticated/competence/prototypes/single.js +++ b/pix-editor/app/routes/authenticated/competence/prototypes/single.js @@ -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); } } } diff --git a/pix-editor/app/routes/authenticated/competence/skills/single.js b/pix-editor/app/routes/authenticated/competence/skills/single.js index f2dc46393..1407bada3 100644 --- a/pix-editor/app/routes/authenticated/competence/skills/single.js +++ b/pix-editor/app/routes/authenticated/competence/skills/single.js @@ -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);