2021-02-24 08:43:35 +01:00
|
|
|
import CustomWizard from "../models/custom-wizard";
|
2020-03-21 18:30:11 +01:00
|
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
2017-10-22 05:37:58 +02:00
|
|
|
|
2020-03-21 18:30:11 +01:00
|
|
|
export default DiscourseRoute.extend({
|
2017-10-05 02:36:46 +02:00
|
|
|
model(params) {
|
2020-04-13 14:17:22 +02:00
|
|
|
return CustomWizard.submissions(params.wizardId);
|
2017-10-05 02:36:46 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
setupController(controller, model) {
|
2020-04-12 01:27:16 +02:00
|
|
|
if (model.submissions) {
|
|
|
|
let fields = [];
|
|
|
|
model.submissions.forEach((s) => {
|
|
|
|
Object.keys(s).forEach((k) => {
|
|
|
|
if (fields.indexOf(k) < 0) {
|
|
|
|
fields.push(k);
|
|
|
|
}
|
|
|
|
});
|
2017-11-01 10:50:03 +01:00
|
|
|
});
|
2017-10-30 07:24:51 +01:00
|
|
|
|
2020-04-12 01:27:16 +02:00
|
|
|
let submissions = [];
|
|
|
|
model.submissions.forEach((s) => {
|
|
|
|
let submission = {};
|
|
|
|
fields.forEach((f) => {
|
|
|
|
submission[f] = s[f];
|
|
|
|
});
|
|
|
|
submissions.push(submission);
|
2017-11-01 10:50:03 +01:00
|
|
|
});
|
2021-02-24 08:43:35 +01:00
|
|
|
|
2020-04-12 01:27:16 +02:00
|
|
|
controller.setProperties({
|
|
|
|
wizard: model.wizard,
|
|
|
|
submissions,
|
2021-02-24 08:43:35 +01:00
|
|
|
fields,
|
2020-04-12 01:27:16 +02:00
|
|
|
});
|
|
|
|
}
|
2021-02-24 08:43:35 +01:00
|
|
|
},
|
2017-10-05 02:36:46 +02:00
|
|
|
});
|