diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-11-25 22:19:15 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-11-25 22:19:15 +0100 |
| commit | ee3d0d98e19f1d8177d85af1866fd0ee431fe9ea (patch) | |
| tree | 41372528e78d4328bc2a47bbbabac7e809c58894 /client/common/table.component.js | |
| parent | 255b8178af1e25a71fd23703d30c0d1f74911f47 (diff) | |
moving stuff
Diffstat (limited to 'client/common/table.component.js')
| -rw-r--r-- | client/common/table.component.js | 121 |
1 files changed, 0 insertions, 121 deletions
diff --git a/client/common/table.component.js b/client/common/table.component.js deleted file mode 100644 index 76a1d57c..00000000 --- a/client/common/table.component.js +++ /dev/null @@ -1,121 +0,0 @@ -import React from 'react' - -import { formatName } from '../util' - -const __HR__ = '__HR__' - -export function TableObject({ tag, object, order, summary }) { - if (!object) return null - if (object === 'loading') { - return <div className='tableObject loading'>{tag}{': Loading'}</div> - } - if (object.err) { - return <div className='tableObject error'>{tag}{' Error: '}{object.err}</div> - } - let objects = Object.keys(object) - if (order) { - const grouped = objects.reduce((a, b) => { - const index = order.indexOf(b) - if (index !== -1) { - a.order.push([index, b]) - } else { - a.alpha.push(b) - } - return a - }, { order: [], alpha: [] }) - objects = grouped.order - .sort((a, b) => a[0] - b[0]) - .map(([i, s]) => s) - if (!summary) { - objects = objects - // .concat([__HR__]) - .concat(grouped.alpha.sort()) - } - } else { - objects = objects.sort() - } - return ( - <div> - {tag && <h3>{tag}</h3>} - <table className={'tableObject ' + tag}> - <tbody> - {objects.map((key, i) => ( - <TableRow key={key + '_' + i} name={key} value={object[key]} /> - ))} - </tbody> - </table> - </div> - ) -} - -export function TableArray({ tag, list }) { - if (!list) return null - return ( - <div> - {tag && <h3>{tag}</h3>} - <table className={'tableArray ' + tag}> - <tbody> - {list.map((value, i) => ( - <tr key={tag + '_' + i}> - <TableCell value={value} /> - </tr> - ))} - </tbody> - </table> - </div> - ) -} - -export function TableTuples({ tag, list }) { - if (!list) return null - return ( - <div> - {tag && <h3>{tag}</h3>} - <table className={'tableTuples ' + tag}> - <tbody> - {list.map(([key, ...values], i) => ( - <tr key={tag + '_' + i}> - <th>{formatName(key)}</th> - {values.map((value, j) => ( - <TableCell key={i + '_' + j} value={value} /> - ))} - </tr> - ))} - </tbody> - </table> - </div> - ) -} - -export function TableRow({ name, value }) { - if (name === __HR__) { - return ( - <tr> - <th className='tr'> - <hr /> - </th> - </tr> - ) - } - return ( - <tr> - <th>{formatName(name)}</th> - <TableCell name={name} value={value} /> - </tr> - ) -} - -export function TableCell({ value }) { - if (value && typeof value === 'object') { - if (value._raw) { - value = value.value - } else if (value.length) { - value = <TableArray nested tag={''} list={value} /> - } else { - value = <TableObject nested tag={''} object={value} /> - } - } - return ( - <td>{value}</td> - ) -} |
