0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-23 01:40:29 +01:00
discourse-custom-wizard/assets/javascripts/discourse/routes/admin-wizards-submissions-show.js.es6
2021-07-12 16:01:52 +08:00

42 Zeilen
1,1 KiB
JavaScript

import CustomWizard from "../models/custom-wizard";
import DiscourseRoute from "discourse/routes/discourse";
const excludedMetaFields = ["route_to", "redirect_on_complete", "redirect_to"];
export default DiscourseRoute.extend({
model(params) {
return CustomWizard.submissions(params.wizardId);
},
setupController(controller, model) {
if (model && model.submissions) {
let fields = ["username"];
model.submissions.forEach((s) => {
Object.keys(s.fields).forEach((k) => {
if (!excludedMetaFields.includes(k) && fields.indexOf(k) < 0) {
fields.push(k);
}
});
});
let submissions = [];
model.submissions.forEach((s) => {
let submission = {
username: s.username,
};
Object.keys(s.fields).forEach((f) => {
if (fields.includes(f)) {
submission[f] = s.fields[f];
}
});
submissions.push(submission);
});
controller.setProperties({
wizard: model.wizard,
submissions,
fields,
});
}
},
});