Skip to content

Commit

Permalink
[#268] [BUGFIX] Ré-initialisation de la page de résultats d'une campa…
Browse files Browse the repository at this point in the history
…gne (pf-449).

Merge pull request #268 from 1024pix/pf-449-bugfix-share-campaign-results
  • Loading branch information
lisequesnel committed Nov 15, 2018
2 parents 1819d0a + fc2ad2d commit 942a247
Show file tree
Hide file tree
Showing 10 changed files with 310 additions and 79 deletions.
9 changes: 8 additions & 1 deletion mon-pix/app/routes/campaigns/skill-review.js
Expand Up @@ -18,5 +18,12 @@ export default BaseRoute.extend(AuthenticatedRouteMixin, {
if(model.campaignParticipation.isShared) {
this.controllerFor('campaigns.skill-review').send('hideShareButton');
}
}
},

setupController(controller, model) {
this._super(...arguments);
if(!model.campaignParticipation.isShared) {
controller.set('showButtonToShareResult', true);
}
},
});
7 changes: 3 additions & 4 deletions mon-pix/mirage/config.js
@@ -1,14 +1,14 @@
import getAnswer from './routes/get-answer';
import getAnswerByChallengeAndAssessment from './routes/get-answer-by-challenge-and-assessment';
import getAssessment from './routes/get-assessment';
import findAssessments from './routes/find-assessments';
import getAuthenticatedUser from './routes/get-user-me';
import getCampaigns from './routes/get-campaigns';
import getCampaignParticipation from './routes/get-campaign-participation';
import getChallenge from './routes/get-challenge';
import getChallenges from './routes/get-challenges';
import getCourse from './routes/get-course';
import getCourses from './routes/get-courses';
import getCoursesOfTheWeek from './routes/get-courses-of-the-week';
import getNextChallenge from './routes/get-next-challenge';
import getOrganizations from './routes/get-organizations';
import getSnapshots from './routes/get-snapshots';
Expand Down Expand Up @@ -36,13 +36,11 @@ export default function() {
this.timing = 0; // response delay

this.get('/courses', getCourses);
this.get('/courses?isCourseOfTheWeek=true', getCoursesOfTheWeek);

this.get('/challenges', getChallenges);
this.get('/challenges/:id', getChallenge);

this.post('/assessments', postAssessments);
this.get('/assessments');
this.get('/assessments/:id', getAssessment);
this.get('/assessments/:assessmentId/next/:challengeId', getNextChallenge);
this.get('/assessments/:assessmentId/next', getNextChallenge);
Expand All @@ -56,7 +54,8 @@ export default function() {

//Nouveau Mirage

//Courses
this.get('/assessments', findAssessments);

this.get('/courses/:id', getCourse);
this.post('/courses', postCertificationCourse);

Expand Down
18 changes: 18 additions & 0 deletions mon-pix/mirage/routes/find-assessments.js
@@ -0,0 +1,18 @@
export default function(schema, request) {

const campaignCode = request.queryParams['filter[codeCampaign]'];

if (campaignCode) {
const campaign = schema.campaigns.findBy({ code: campaignCode });

if (campaign) {
const assessment = schema.campaignParticipations.findBy({ campaignId: campaign.id });

if (assessment) {
return schema.assessments.where({ id: assessment.id });
}
}
}

return schema.assessments.all();
}
16 changes: 14 additions & 2 deletions mon-pix/mirage/routes/get-campaign-participation.js
@@ -1,3 +1,15 @@
export default function(schema) {
return schema.campaignParticipations.find(['1']);
import Response from 'ember-cli-mirage/response';

export default function(schema, request) {
const assessmentId = request.queryParams['filter[assessmentId]'];

if (assessmentId) {
const campaignParticipations = schema.campaignParticipations.where({ assessmentId });
if (campaignParticipations.length === 0) {
return new Response(404);
}
return campaignParticipations;
}
return schema.campaignParticipations.all();

}
5 changes: 0 additions & 5 deletions mon-pix/mirage/routes/get-courses-of-the-week.js

This file was deleted.

11 changes: 4 additions & 7 deletions mon-pix/mirage/scenarios/default.js
@@ -1,5 +1,7 @@
export default function(server) {

/* eslint max-statements: off */

server.loadFixtures('areas');
server.loadFixtures('competences');
server.loadFixtures('courses');
Expand Down Expand Up @@ -86,24 +88,19 @@ export default function(server) {
server.create('correction');

server.create('campaign', {
id: '1',
id: 1,
name: 'Campagne 1 avec Id Externe',
code: 'AZERTY1',
idPixLabel: 'Mail Pro',
organizationLogoUrl: 'data:jpeg;base64=somelogo',
});
server.create('campaign', {
id: '2',
id: 2,
name: 'Campagne 2 sans Id Externe',
code: 'AZERTY2',
idPixLabel: null,
});

server.create('campaignParticipation', {
id: '1',
isShared: false,
});

server.create('campaign', {
code: 'codecampagnepix',
title: 'Le Titre de la campagne'
Expand Down

0 comments on commit 942a247

Please sign in to comment.