From 280d2ffe54e4a9e3debe95deafa7bc419665707b Mon Sep 17 00:00:00 2001 From: Keegan George Date: Tue, 31 Aug 2021 13:29:30 -0700 Subject: [PATCH] IMPROVE: Make edit columns adjust submissions as well --- .../admin-wizards-submissions-show.js.es6 | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/assets/javascripts/discourse/controllers/admin-wizards-submissions-show.js.es6 b/assets/javascripts/discourse/controllers/admin-wizards-submissions-show.js.es6 index 40a08f4f..2667b6b2 100644 --- a/assets/javascripts/discourse/controllers/admin-wizards-submissions-show.js.es6 +++ b/assets/javascripts/discourse/controllers/admin-wizards-submissions-show.js.es6 @@ -31,16 +31,20 @@ export default Controller.extend({ @discourseComputed('submissions', 'fields.@each.enabled') displaySubmissions(submissions, fields) { - return submissions.map(submission => { - let field = fields.find(f => Object.keys(submission).includes(f.id)); - if (!field.enabled) { - // insert field / submission deletion code here: - console.log(field, "is not enabled for ", submission); - } else if (field.enabled) { - console.log(field, "is enabled for ", submission); - } - return submission; + let result = []; + + submissions.forEach(submission => { + let sub = {}; + + Object.keys(submission).forEach(fieldId => { + if (fields.some(f => f.id === fieldId && f.enabled)) { + sub[fieldId] = submission[fieldId]; + } + }); + result.push(sub); }); + + return result; }, actions: {