0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-25 18:50:27 +01:00
discourse-custom-wizard/assets/javascripts/discourse/routes/admin-wizards-submissions-show.js.es6
2022-07-27 11:47:50 +01:00

42 Zeilen
1,1 KiB
JavaScript

import CustomWizardAdmin from "../models/custom-wizard-admin";
import DiscourseRoute from "discourse/routes/discourse";
const excludedMetaFields = ["route_to", "redirect_on_complete", "redirect_to"];
export default DiscourseRoute.extend({
model(params) {
return CustomWizardAdmin.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,
});
}
},
});