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

fix: Prevent mutating data in sessions event wizard page #4521

Merged
merged 1 commit into from
Jul 2, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions app/routes/events/view/edit/sessions-speakers.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import classic from 'ember-classic-decorator';
import Route from '@ember/routing/route';
import EventWizardMixin from 'open-event-frontend/mixins/event-wizard';
import { allSettled } from 'rsvp';

@classic
export default class SessionsSpeakersRoute extends Route.extend(EventWizardMixin) {
Expand All @@ -9,13 +10,13 @@ export default class SessionsSpeakersRoute extends Route.extend(EventWizardMixin
}

async model() {
let data = this.modelFor('events.view.edit');
data.tracks = await data.event.get('tracks');
data.microlocations = await data.event.get('microlocations');
data.sessionTypes = await data.event.get('sessionTypes');
data.speakersCall = await this.getOrCreate(data.event, 'speakersCall', 'speakers-call');
const data = this.modelFor('events.view.edit');
const tracksPromise = data.event.get('tracks');
const microlocationsPromise = data.event.get('microlocations');
const sessionTypesPromise = data.event.get('sessionTypes');
const speakersCallPromise = this.getOrCreate(data.event, 'speakersCall', 'speakers-call');
// Only get session/speaker custom forms.
let customFormFilterOptions = [{
const customFormFilterOptions = [{
or: [
{
name : 'form',
Expand All @@ -29,11 +30,20 @@ export default class SessionsSpeakersRoute extends Route.extend(EventWizardMixin
}
]
}];
data.customForms = await data.event.query('customForms', {
const customFormsPromise = data.event.query('customForms', {
filter : customFormFilterOptions,
sort : 'field-identifier',
'page[size]' : 50
});
return data;

const [tracks, microlocations, sessionTypes, speakersCall, customForms] = (await allSettled([tracksPromise, microlocationsPromise, sessionTypesPromise, speakersCallPromise, customFormsPromise])).map(promise => promise.value);
return {
...data,
tracks,
microlocations,
sessionTypes,
speakersCall,
customForms
};
}
}