2021-07-14 08:04:19 +02:00
|
|
|
import { A } from "@ember/array";
|
2021-08-31 01:33:48 +02:00
|
|
|
import EmberObject from "@ember/object";
|
2022-07-27 12:47:50 +02:00
|
|
|
import CustomWizardAdmin from "../models/custom-wizard-admin";
|
2021-08-31 01:33:48 +02:00
|
|
|
import DiscourseRoute from "discourse/routes/discourse";
|
2021-07-12 09:53: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) {
|
2022-07-27 12:47:50 +02:00
|
|
|
return CustomWizardAdmin.submissions(params.wizardId);
|
2017-10-05 02:36:46 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
setupController(controller, model) {
|
2022-09-28 14:26:27 +02:00
|
|
|
let fields = [
|
|
|
|
EmberObject.create({ id: "username", label: "User", enabled: true }),
|
|
|
|
];
|
|
|
|
let submissions = [];
|
|
|
|
|
|
|
|
model.submissions.forEach((s) => {
|
|
|
|
let submission = {
|
|
|
|
username: s.user,
|
|
|
|
};
|
|
|
|
|
|
|
|
Object.keys(s.fields).forEach((fieldId) => {
|
|
|
|
if (!fields.some((field) => field.id === fieldId)) {
|
|
|
|
fields.push(
|
|
|
|
EmberObject.create({
|
|
|
|
id: fieldId,
|
|
|
|
label: s.fields[fieldId].label,
|
|
|
|
enabled: true,
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
submission[fieldId] = s.fields[fieldId];
|
|
|
|
});
|
|
|
|
|
|
|
|
submission["submitted_at"] = s.submitted_at;
|
|
|
|
submissions.push(EmberObject.create(submission));
|
2021-08-31 01:33:48 +02:00
|
|
|
});
|
2022-09-28 14:26:27 +02:00
|
|
|
|
|
|
|
let submittedAt = {
|
|
|
|
id: "submitted_at",
|
|
|
|
label: "Submitted At",
|
|
|
|
enabled: true,
|
|
|
|
};
|
|
|
|
|
|
|
|
fields.push(EmberObject.create(submittedAt));
|
|
|
|
|
2021-07-14 08:04:19 +02:00
|
|
|
controller.setProperties({
|
|
|
|
wizard: model.wizard,
|
2021-08-31 01:33:48 +02:00
|
|
|
fields: A(fields),
|
2022-09-28 14:26:27 +02:00
|
|
|
submissions: A(submissions),
|
2021-07-14 08:05:13 +02:00
|
|
|
total: model.total,
|
2021-07-14 08:04:19 +02:00
|
|
|
});
|
2021-03-28 11:06:49 +02:00
|
|
|
},
|
2017-10-05 02:36:46 +02:00
|
|
|
});
|