From f55da2b20d0c68c468bc099fb8d4fc3d8a7dff57 Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Wed, 3 Oct 2018 18:44:31 +0000 Subject: [PATCH] fix submissions page for non-scalar fields (render as yaml). --- formspree/js/forms/FormPage/Submissions.js | 20 +++++++++++++++----- package.json | 1 + 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/formspree/js/forms/FormPage/Submissions.js b/formspree/js/forms/FormPage/Submissions.js index a44d55f..093a8b1 100644 --- a/formspree/js/forms/FormPage/Submissions.js +++ b/formspree/js/forms/FormPage/Submissions.js @@ -3,6 +3,7 @@ const toastr = window.toastr const fetch = window.fetch const React = require('react') +const prettyaml = require('prettyaml') export default class FormSubmissions extends React.Component { constructor(props) { @@ -47,11 +48,20 @@ export default class FormSubmissions extends React.Component { {form.fields .slice(1 /* the first field is 'date' */) - .map(f => ( - -
{s[f]}
- - ))} + .map(f => { + var value + try { + value = prettyaml.stringify(s[f]) + } catch (e) { + value = JSON.stringify(s[f]) + } + + return ( + +
{value}
+ + ) + })}