From a17b76ac75f506f5da6fe8adf9c36632b60d4226 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Sat, 26 Sep 2020 14:56:02 +0200 Subject: refactor to use app-rooted js imports --- frontend/common/tableIndex.component.js | 129 -------------------------------- 1 file changed, 129 deletions(-) delete mode 100644 frontend/common/tableIndex.component.js (limited to 'frontend/common/tableIndex.component.js') diff --git a/frontend/common/tableIndex.component.js b/frontend/common/tableIndex.component.js deleted file mode 100644 index a34a9e9..0000000 --- a/frontend/common/tableIndex.component.js +++ /dev/null @@ -1,129 +0,0 @@ -import React, { Component } from 'react' -import { Link } from 'react-router-dom' -import { connect } from 'react-redux' - -import { formatDateTime } from '../util' -import { Loader, Swatch, Dot } from '../common' - -/* - '/collection/' + row.id + '/show/' }, - { name: 'username', type: 'string' }, - { name: 'date', type: 'date' }, - { name: 'notes', type: 'text' }, - ]} - /> -*/ - -export default class TableIndex extends Component { - componentDidMount() { - this.props.actions && this.props.actions.index() - } - - render() { - const { data, els, title, fields, noHeadings, notFoundMessage } = this.props - if (data.loading) { - return - } - if (!els && (!data.lookup || !data.order.length)) { - return ( -
-

{title}

-

- {notFoundMessage || ("No " + title)} -

-
- ) - } - return ( -
-

{title}

-
- {!noHeadings && } - {els - ? els.map(el => ) - : data.order.map(id => ) - } -
-
- ) - } -} - -const RowHeadings = ({fields}) => { - return ( -
- {fields.map(field => { - if (field.type === 'gallery') return - let css = {} - if (field.width) { - css = { width: field.width, maxWidth: 'none', flex: 'none', } - } - if (field.flex) { - css.flex = field.flex - } - return
{(field.title || field.name).replace(/_/g, ' ')}
- })} -
- ) -} - -const Row = ({ row, fields }) => { - return ( -
- {fields.map(field => { - let value = field.valueFn ? field.valueFn(row) : row[field.name] - let css = {} - if (field.type === 'date' && (row.updated_at || row.created_at || value)) { - // value = (value || "").split('.')[0] - value = formatDateTime(row.updated_at || row.created_at || value) - } else if (field.type === 'text') { - value = String(value || "").trim().split('\n')[0].replace(/^#+/, '').substr(0, 100) - } else if (field.type === 'color') { - value = - } else if (field.type === 'bool') { - value = - } else if (field.type === 'str') { - value = String(value || "").replace(/_/g, ' ') - } else if (field.type === 'gallery') { - return - } - if (field.width) { - css = { width: field.width, maxWidth: 'none', flex: 'none', } - } - if (field.flex) { - css.flex = field.flex - } - let className - if (field.style) { - className = field.type + ' ' + field.style - } else { - className = field.type - } - value =
{value}
- if (field.link) { - return {value} - } - return value - })} -
- ) -} - -const GalleryRow = ({ media }) => { - return ( -
-
- {media.map(img => ( - - - - ))} -
-
- ) -} -- cgit v1.2.3-70-g09d2