0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 17:30:29 +01:00
discourse-custom-wizard/assets/javascripts/discourse/routes/admin-wizards-submissions-show.js.es6

43 Zeilen
1,1 KiB
Text

2022-07-27 12:47:50 +02:00
import CustomWizardAdmin from "../models/custom-wizard-admin";
2020-03-21 18:30:11 +01:00
import DiscourseRoute from "discourse/routes/discourse";
2017-10-22 05:37:58 +02:00
2021-07-12 10:01:52 +02:00
const excludedMetaFields = ["route_to", "redirect_on_complete", "redirect_to"];
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) {
if (model && model.submissions) {
2021-07-12 10:01:52 +02:00
let fields = ["username"];
2020-04-12 01:27:16 +02:00
model.submissions.forEach((s) => {
Object.keys(s.fields).forEach((k) => {
if (!excludedMetaFields.includes(k) && fields.indexOf(k) < 0) {
2020-04-12 01:27:16 +02:00
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 = {
2021-07-12 10:01:52 +02:00
username: s.username,
};
Object.keys(s.fields).forEach((f) => {
if (fields.includes(f)) {
submission[f] = s.fields[f];
}
2020-04-12 01:27:16 +02:00
});
submissions.push(submission);
2017-11-01 10:50:03 +01:00
});
2020-04-12 01:27:16 +02:00
controller.setProperties({
wizard: model.wizard,
submissions,
fields,
2020-04-12 01:27:16 +02:00
});
}
},
2017-10-05 02:36:46 +02:00
});