From 60abb6981eaa651ae5643fe00291e2f798d37921 Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Wed, 28 Sep 2022 14:26:27 +0200 Subject: [PATCH] FIX: re-add logic incorrectly removed submissions logic during merge --- .../admin-wizards-submissions-show.js.es6 | 40 ++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/assets/javascripts/discourse/routes/admin-wizards-submissions-show.js.es6 b/assets/javascripts/discourse/routes/admin-wizards-submissions-show.js.es6 index 5a9d6046..59f4eec4 100644 --- a/assets/javascripts/discourse/routes/admin-wizards-submissions-show.js.es6 +++ b/assets/javascripts/discourse/routes/admin-wizards-submissions-show.js.es6 @@ -9,15 +9,45 @@ export default DiscourseRoute.extend({ }, setupController(controller, model) { - const fields = model.fields.map((f) => { - const fieldsObject = EmberObject.create(f); - fieldsObject.enabled = true; - return fieldsObject; + 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)); }); + + let submittedAt = { + id: "submitted_at", + label: "Submitted At", + enabled: true, + }; + + fields.push(EmberObject.create(submittedAt)); + controller.setProperties({ wizard: model.wizard, fields: A(fields), - submissions: A(model.submissions), + submissions: A(submissions), total: model.total, }); },