diff --git a/frontend/my/src/Subscribers.js b/frontend/my/src/Subscribers.js index b3f154e..e49bf52 100644 --- a/frontend/my/src/Subscribers.js +++ b/frontend/my/src/Subscribers.js @@ -204,7 +204,9 @@ class Subscribers extends React.PureComponent { query: null, targetLists: [] }, - listAddVisible: false + listAddVisible: false, + allRowsSelected: false, + rowsSelected: [] } // Pagination config. @@ -234,7 +236,6 @@ class Subscribers extends React.PureComponent { sorter: true, width: "25%", render: (text, record) => { - const out = []; out.push(
@@ -244,7 +245,9 @@ class Subscribers extends React.PureComponent { if(record.lists.length > 0) { for (let i = 0; i < record.lists.length; i++) { - out.push({ record.lists[i].name }) + out.push( + { record.lists[i].name } + ) } } @@ -255,7 +258,7 @@ class Subscribers extends React.PureComponent { title: "Name", dataIndex: "name", sorter: true, - width: "25%", + width: "15%", render: (text, record) => { return ( this.handleShowEditForm(record)}>{text} @@ -398,14 +401,23 @@ class Subscribers extends React.PureComponent { this.setState({ formType: cs.FormEdit, record: record }) } - handleToggleQueryForm = () => { - // The query form is being cancelled. Reset the results. - if(this.state.queryFormVisible) { - this.fetchRecords({ - query: null - }) + handleSearch = (q) => { + q = q.trim().toLowerCase() + if(q === "") { + this.fetchRecords({ query: null }) + return } + q = q.replace(/'/g, "''") + const query = `(name LIKE '%${q}%' OR email LIKE '%${q}%')` + this.fetchRecords({ query: query }) + } + + handleRowSelection = (_, records) => { + this.setState({ allRowsSelected: false, rowsSelected: records.map(r => r.id) }) + } + + handleToggleQueryForm = () => { this.setState({ queryFormVisible: !this.state.queryFormVisible }) } @@ -429,54 +441,93 @@ class Subscribers extends React.PureComponent {
- -

- Subscribers - { this.state.queryParams.list && - » { this.state.queryParams.list.name } } + +

+ Subscribers + { this.state.queryParams.list && + » { this.state.queryParams.list.name } } -

- - - { !this.state.queryFormVisible && - Advanced } - - - - + + + + +
- { this.state.queryFormVisible && -
-

- Write a partial SQL expression to query the subscribers based on their - primary information or attributes. Learn more. -

- { - this.setState({ queryParams: { ...this.state.queryParams, query: e.target.value } }) - }} - autosize={{ minRows: 2, maxRows: 10 }} /> - -
- - {" "} - - {" "} - -
-
- } +
+ + + + + + + {" "} + + +
+ + Advanced + +
+ { this.state.queryFormVisible && +
+

+ + { + this.setState({ queryParams: { ...this.state.queryParams, query: e.target.value } }) + }} + value={ this.state.queryParams.query } + autosize={{ minRows: 2, maxRows: 10 }} /> + + Write a partial SQL expression to query the subscribers based on their primary information or attributes. Learn more. + +

+

+ + {" "} + +

+
+ } + + + { this.state.rowsSelected.length > 0 && + + } + +
+
diff --git a/frontend/my/src/index.css b/frontend/my/src/index.css index 71da156..51be6f6 100644 --- a/frontend/my/src/index.css +++ b/frontend/my/src/index.css @@ -110,6 +110,13 @@ td .ant-tag { margin-top: 5px; } +/* External options */ +.table-options { +} + .table-options a { + margin-right: 30px; + } + /* Dashboard */ .dashboard { margin: 24px; @@ -124,27 +131,19 @@ td .ant-tag { } /* Subscribers */ -.subscriber-filter { - background: #fff; - min-width: 300px; - max-width: 500px; - width: 100%; - padding: 15px; - box-shadow: 0 1px 6px rgba(0, 0, 0, .2); -} - .subscriber-filter .lists { - width: 100%; - } - .subscribers table .name { margin-bottom: 10px; } .subscriber-query { - margin: 15px 0 30px 0; + margin: 0 0 15px 0; padding: 30px; box-shadow: 0 1px 6px #ddd; + min-height: 140px; } + .subscriber-query .advanced-query { + margin-top: 15px; + } .subscriber-query textarea { font-family: monospace; }