admin-wizard-submissions.js.es6 647 B

1234567891011121314151617181920212223242526272829
  1. import CustomWizard from '../models/custom-wizard';
  2. export default Discourse.Route.extend({
  3. model(params) {
  4. return CustomWizard.submissions(params.wizard_id);
  5. },
  6. setupController(controller, model) {
  7. let fields = [];
  8. model.forEach((s) => {
  9. Object.keys(s).forEach((k) => {
  10. if (fields.indexOf(k) < 0) {
  11. fields.push(k);
  12. }
  13. });
  14. });
  15. let submissions = [];
  16. model.forEach((s) => {
  17. let submission = {};
  18. fields.forEach((f) => {
  19. submission[f] = s[f];
  20. });
  21. submissions.push(submission);
  22. });
  23. controller.setProperties({ submissions, fields });
  24. }
  25. });