summaryrefslogtreecommitdiffstats
path: root/webapp/components
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/components')
-rw-r--r--webapp/components/post_attachment.jsx131
1 files changed, 69 insertions, 62 deletions
diff --git a/webapp/components/post_attachment.jsx b/webapp/components/post_attachment.jsx
index 7c4125c27..1c3df6ea2 100644
--- a/webapp/components/post_attachment.jsx
+++ b/webapp/components/post_attachment.jsx
@@ -87,75 +87,82 @@ class PostAttachment extends React.Component {
return '';
}
- const compactTable = fields.filter((field) => field.short).length > 0;
- let tHead;
- let tBody;
-
- if (compactTable) {
- let headerCols = [];
- let bodyCols = [];
-
- fields.forEach((field, i) => {
- headerCols.push(
- <th
- className='attachment___field-caption'
- key={'attachment__field-caption-' + i}
+ let fieldTables = [];
+
+ let headerCols = [];
+ let bodyCols = [];
+ let rowPos = 0;
+ let lastWasLong = false;
+ let nrTables = 0;
+
+ fields.forEach((field, i) => {
+ if (rowPos === 2 || !(field.short === true) || lastWasLong) {
+ fieldTables.push(
+ <table
+ className='attachment___fields'
+ key={'attachment__table__' + nrTables}
>
- {field.title}
- </th>
+ <thead>
+ <tr>
+ {headerCols}
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ {bodyCols}
+ </tr>
+ </tbody>
+ </table>
);
- bodyCols.push(
- <td
- className='attachment___field'
- key={'attachment__field-' + i}
- dangerouslySetInnerHTML={{__html: TextFormatting.formatText(field.value || '')}}
- >
- </td>
- );
- });
-
- tHead = (
- <tr>
- {headerCols}
- </tr>
+ headerCols = [];
+ bodyCols = [];
+ rowPos = 0;
+ nrTables += 1;
+ lastWasLong = false;
+ }
+ headerCols.push(
+ <th
+ className='attachment___field-caption'
+ key={'attachment__field-caption-' + i + '__' + nrTables}
+ width='50%'
+ >
+ {field.title}
+ </th>
);
- tBody = (
- <tr>
- {bodyCols}
- </tr>
+ bodyCols.push(
+ <td
+ className='attachment___field'
+ key={'attachment__field-' + i + '__' + nrTables}
+ dangerouslySetInnerHTML={{__html: TextFormatting.formatText(field.value || '')}}
+ >
+ </td>
);
- } else {
- tBody = [];
-
- fields.forEach((field, i) => {
- tBody.push(
- <tr key={'attachment__field-' + i}>
- <td
- className='attachment___field-caption'
- >
- {field.title}
- </td>
- <td
- className='attachment___field'
- dangerouslySetInnerHTML={{__html: TextFormatting.formatText(field.value || '')}}
- >
- </td>
- </tr>
+ rowPos += 1;
+ lastWasLong = !(field.short === true);
+ });
+ if (headerCols.length > 0) { // Flush last fields
+ fieldTables.push(
+ <table
+ className='attachment___fields'
+ key={'attachment__table__' + nrTables}
+ >
+ <thead>
+ <tr>
+ {headerCols}
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ {bodyCols}
+ </tr>
+ </tbody>
+ </table>
);
- });
}
-
return (
- <table
- className='attachment___fields'
- >
- <thead>
- {tHead}
- </thead>
- <tbody>
- {tBody}
- </tbody>
- </table>
+ <div>
+ {fieldTables}
+ </div>
);
}