|
@@ -1,5 +1,5 @@
|
|
-import React from "react"
|
|
|
|
-import { Link } from "react-router-dom"
|
|
|
|
|
|
+import React from "react";
|
|
|
|
+import { Link } from "react-router-dom";
|
|
import {
|
|
import {
|
|
Row,
|
|
Row,
|
|
Col,
|
|
Col,
|
|
@@ -15,44 +15,44 @@ import {
|
|
Popconfirm,
|
|
Popconfirm,
|
|
notification,
|
|
notification,
|
|
Radio
|
|
Radio
|
|
-} from "antd"
|
|
|
|
|
|
+} from "antd";
|
|
|
|
|
|
-import Utils from "./utils"
|
|
|
|
-import Subscriber from "./Subscriber"
|
|
|
|
-import * as cs from "./constants"
|
|
|
|
|
|
+import Utils from "./utils";
|
|
|
|
+import Subscriber from "./Subscriber";
|
|
|
|
+import * as cs from "./constants";
|
|
|
|
|
|
const tagColors = {
|
|
const tagColors = {
|
|
enabled: "green",
|
|
enabled: "green",
|
|
blacklisted: "red"
|
|
blacklisted: "red"
|
|
-}
|
|
|
|
|
|
+};
|
|
|
|
|
|
class ListsFormDef extends React.PureComponent {
|
|
class ListsFormDef extends React.PureComponent {
|
|
state = {
|
|
state = {
|
|
modalWaiting: false
|
|
modalWaiting: false
|
|
- }
|
|
|
|
|
|
+ };
|
|
|
|
|
|
// Handle create / edit form submission.
|
|
// Handle create / edit form submission.
|
|
handleSubmit = e => {
|
|
handleSubmit = e => {
|
|
- e.preventDefault()
|
|
|
|
|
|
+ e.preventDefault();
|
|
|
|
|
|
var err = null,
|
|
var err = null,
|
|
- values = {}
|
|
|
|
|
|
+ values = {};
|
|
this.props.form.validateFields((e, v) => {
|
|
this.props.form.validateFields((e, v) => {
|
|
- err = e
|
|
|
|
- values = v
|
|
|
|
- })
|
|
|
|
|
|
+ err = e;
|
|
|
|
+ values = v;
|
|
|
|
+ });
|
|
if (err) {
|
|
if (err) {
|
|
- return
|
|
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
if (this.props.allRowsSelected) {
|
|
if (this.props.allRowsSelected) {
|
|
- values["list_ids"] = this.props.listIDs
|
|
|
|
- values["query"] = this.props.query
|
|
|
|
|
|
+ values["list_ids"] = this.props.listIDs;
|
|
|
|
+ values["query"] = this.props.query;
|
|
} else {
|
|
} else {
|
|
- values["ids"] = this.props.selectedRows.map(r => r.id)
|
|
|
|
|
|
+ values["ids"] = this.props.selectedRows.map(r => r.id);
|
|
}
|
|
}
|
|
|
|
|
|
- this.setState({ modalWaiting: true })
|
|
|
|
|
|
+ this.setState({ modalWaiting: true });
|
|
this.props
|
|
this.props
|
|
.request(
|
|
.request(
|
|
!this.props.allRowsSelected
|
|
!this.props.allRowsSelected
|
|
@@ -65,24 +65,24 @@ class ListsFormDef extends React.PureComponent {
|
|
notification["success"]({
|
|
notification["success"]({
|
|
message: "Lists changed",
|
|
message: "Lists changed",
|
|
description: `Lists changed for selected subscribers`
|
|
description: `Lists changed for selected subscribers`
|
|
- })
|
|
|
|
- this.props.clearSelectedRows()
|
|
|
|
- this.props.fetchRecords()
|
|
|
|
- this.setState({ modalWaiting: false })
|
|
|
|
- this.props.onClose()
|
|
|
|
|
|
+ });
|
|
|
|
+ this.props.clearSelectedRows();
|
|
|
|
+ this.props.fetchRecords();
|
|
|
|
+ this.setState({ modalWaiting: false });
|
|
|
|
+ this.props.onClose();
|
|
})
|
|
})
|
|
.catch(e => {
|
|
.catch(e => {
|
|
- notification["error"]({ message: "Error", description: e.message })
|
|
|
|
- this.setState({ modalWaiting: false })
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
|
|
+ notification["error"]({ message: "Error", description: e.message });
|
|
|
|
+ this.setState({ modalWaiting: false });
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
|
|
render() {
|
|
render() {
|
|
- const { getFieldDecorator } = this.props.form
|
|
|
|
|
|
+ const { getFieldDecorator } = this.props.form;
|
|
const formItemLayout = {
|
|
const formItemLayout = {
|
|
labelCol: { xs: { span: 16 }, sm: { span: 4 } },
|
|
labelCol: { xs: { span: 16 }, sm: { span: 4 } },
|
|
wrapperCol: { xs: { span: 16 }, sm: { span: 18 } }
|
|
wrapperCol: { xs: { span: 16 }, sm: { span: 18 } }
|
|
- }
|
|
|
|
|
|
+ };
|
|
|
|
|
|
return (
|
|
return (
|
|
<Modal
|
|
<Modal
|
|
@@ -123,14 +123,14 @@ class ListsFormDef extends React.PureComponent {
|
|
</Form.Item>
|
|
</Form.Item>
|
|
</Form>
|
|
</Form>
|
|
</Modal>
|
|
</Modal>
|
|
- )
|
|
|
|
|
|
+ );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-const ListsForm = Form.create()(ListsFormDef)
|
|
|
|
|
|
+const ListsForm = Form.create()(ListsFormDef);
|
|
|
|
|
|
class Subscribers extends React.PureComponent {
|
|
class Subscribers extends React.PureComponent {
|
|
- defaultPerPage = 20
|
|
|
|
|
|
+ defaultPerPage = 20;
|
|
|
|
|
|
state = {
|
|
state = {
|
|
formType: null,
|
|
formType: null,
|
|
@@ -151,7 +151,7 @@ class Subscribers extends React.PureComponent {
|
|
listModalVisible: false,
|
|
listModalVisible: false,
|
|
allRowsSelected: false,
|
|
allRowsSelected: false,
|
|
selectedRows: []
|
|
selectedRows: []
|
|
- }
|
|
|
|
|
|
+ };
|
|
|
|
|
|
// Pagination config.
|
|
// Pagination config.
|
|
paginationOptions = {
|
|
paginationOptions = {
|
|
@@ -163,15 +163,15 @@ class Subscribers extends React.PureComponent {
|
|
position: "both",
|
|
position: "both",
|
|
showTotal: (total, range) => `${range[0]} to ${range[1]} of ${total}`,
|
|
showTotal: (total, range) => `${range[0]} to ${range[1]} of ${total}`,
|
|
onChange: (page, perPage) => {
|
|
onChange: (page, perPage) => {
|
|
- this.fetchRecords({ page: page, per_page: perPage })
|
|
|
|
|
|
+ this.fetchRecords({ page: page, per_page: perPage });
|
|
},
|
|
},
|
|
onShowSizeChange: (page, perPage) => {
|
|
onShowSizeChange: (page, perPage) => {
|
|
- this.fetchRecords({ page: page, per_page: perPage })
|
|
|
|
|
|
+ this.fetchRecords({ page: page, per_page: perPage });
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
+ };
|
|
|
|
|
|
constructor(props) {
|
|
constructor(props) {
|
|
- super(props)
|
|
|
|
|
|
+ super(props);
|
|
|
|
|
|
// Table layout.
|
|
// Table layout.
|
|
this.columns = [
|
|
this.columns = [
|
|
@@ -181,7 +181,7 @@ class Subscribers extends React.PureComponent {
|
|
sorter: true,
|
|
sorter: true,
|
|
width: "25%",
|
|
width: "25%",
|
|
render: (text, record) => {
|
|
render: (text, record) => {
|
|
- const out = []
|
|
|
|
|
|
+ const out = [];
|
|
out.push(
|
|
out.push(
|
|
<div key={`sub-email-${record.id}`} className="sub-name">
|
|
<div key={`sub-email-${record.id}`} className="sub-name">
|
|
<Link
|
|
<Link
|
|
@@ -190,15 +190,15 @@ class Subscribers extends React.PureComponent {
|
|
// Open the individual subscriber page on ctrl+click
|
|
// Open the individual subscriber page on ctrl+click
|
|
// and the modal otherwise.
|
|
// and the modal otherwise.
|
|
if (!e.ctrlKey) {
|
|
if (!e.ctrlKey) {
|
|
- this.handleShowEditForm(record)
|
|
|
|
- e.preventDefault()
|
|
|
|
|
|
+ this.handleShowEditForm(record);
|
|
|
|
+ e.preventDefault();
|
|
}
|
|
}
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
{text}
|
|
{text}
|
|
</Link>
|
|
</Link>
|
|
</div>
|
|
</div>
|
|
- )
|
|
|
|
|
|
+ );
|
|
|
|
|
|
if (record.lists.length > 0) {
|
|
if (record.lists.length > 0) {
|
|
for (let i = 0; i < record.lists.length; i++) {
|
|
for (let i = 0; i < record.lists.length; i++) {
|
|
@@ -220,11 +220,11 @@ class Subscribers extends React.PureComponent {
|
|
{record.lists[i].subscription_status}
|
|
{record.lists[i].subscription_status}
|
|
</sup>
|
|
</sup>
|
|
</Tag>
|
|
</Tag>
|
|
- )
|
|
|
|
|
|
+ );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- return out
|
|
|
|
|
|
+ return out;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
{
|
|
{
|
|
@@ -240,14 +240,14 @@ class Subscribers extends React.PureComponent {
|
|
// Open the individual subscriber page on ctrl+click
|
|
// Open the individual subscriber page on ctrl+click
|
|
// and the modal otherwise.
|
|
// and the modal otherwise.
|
|
if (!e.ctrlKey) {
|
|
if (!e.ctrlKey) {
|
|
- this.handleShowEditForm(record)
|
|
|
|
- e.preventDefault()
|
|
|
|
|
|
+ this.handleShowEditForm(record);
|
|
|
|
+ e.preventDefault();
|
|
}
|
|
}
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
{text}
|
|
{text}
|
|
</Link>
|
|
</Link>
|
|
- )
|
|
|
|
|
|
+ );
|
|
}
|
|
}
|
|
},
|
|
},
|
|
{
|
|
{
|
|
@@ -261,7 +261,7 @@ class Subscribers extends React.PureComponent {
|
|
>
|
|
>
|
|
{status}
|
|
{status}
|
|
</Tag>
|
|
</Tag>
|
|
- )
|
|
|
|
|
|
+ );
|
|
}
|
|
}
|
|
},
|
|
},
|
|
{
|
|
{
|
|
@@ -282,7 +282,7 @@ class Subscribers extends React.PureComponent {
|
|
0
|
|
0
|
|
)}
|
|
)}
|
|
</span>
|
|
</span>
|
|
- )
|
|
|
|
|
|
+ );
|
|
}
|
|
}
|
|
},
|
|
},
|
|
{
|
|
{
|
|
@@ -290,7 +290,7 @@ class Subscribers extends React.PureComponent {
|
|
width: "10%",
|
|
width: "10%",
|
|
dataIndex: "created_at",
|
|
dataIndex: "created_at",
|
|
render: (date, _) => {
|
|
render: (date, _) => {
|
|
- return Utils.DateString(date)
|
|
|
|
|
|
+ return Utils.DateString(date);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
{
|
|
{
|
|
@@ -298,7 +298,7 @@ class Subscribers extends React.PureComponent {
|
|
width: "10%",
|
|
width: "10%",
|
|
dataIndex: "updated_at",
|
|
dataIndex: "updated_at",
|
|
render: (date, _) => {
|
|
render: (date, _) => {
|
|
- return Utils.DateString(date)
|
|
|
|
|
|
+ return Utils.DateString(date);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
{
|
|
{
|
|
@@ -328,10 +328,10 @@ class Subscribers extends React.PureComponent {
|
|
</Tooltip>
|
|
</Tooltip>
|
|
</Popconfirm>
|
|
</Popconfirm>
|
|
</div>
|
|
</div>
|
|
- )
|
|
|
|
|
|
+ );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- ]
|
|
|
|
|
|
+ ];
|
|
}
|
|
}
|
|
|
|
|
|
componentDidMount() {
|
|
componentDidMount() {
|
|
@@ -341,18 +341,18 @@ class Subscribers extends React.PureComponent {
|
|
.then(() => {
|
|
.then(() => {
|
|
// If this is an individual list's view, pick up that list.
|
|
// If this is an individual list's view, pick up that list.
|
|
if (this.state.queryParams.listID) {
|
|
if (this.state.queryParams.listID) {
|
|
- this.props.data[cs.ModelLists].forEach(l => {
|
|
|
|
|
|
+ this.props.data[cs.ModelLists].results.forEach(l => {
|
|
if (l.id === this.state.queryParams.listID) {
|
|
if (l.id === this.state.queryParams.listID) {
|
|
this.setState({
|
|
this.setState({
|
|
queryParams: { ...this.state.queryParams, list: l }
|
|
queryParams: { ...this.state.queryParams, list: l }
|
|
- })
|
|
|
|
- return false
|
|
|
|
|
|
+ });
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
- })
|
|
|
|
|
|
+ });
|
|
}
|
|
}
|
|
- })
|
|
|
|
|
|
+ });
|
|
|
|
|
|
- this.fetchRecords()
|
|
|
|
|
|
+ this.fetchRecords();
|
|
}
|
|
}
|
|
|
|
|
|
fetchRecords = params => {
|
|
fetchRecords = params => {
|
|
@@ -361,15 +361,15 @@ class Subscribers extends React.PureComponent {
|
|
per_page: this.state.queryParams.per_page,
|
|
per_page: this.state.queryParams.per_page,
|
|
list_id: this.state.queryParams.listID,
|
|
list_id: this.state.queryParams.listID,
|
|
query: this.state.queryParams.query
|
|
query: this.state.queryParams.query
|
|
- }
|
|
|
|
|
|
+ };
|
|
|
|
|
|
// The records are for a specific list.
|
|
// The records are for a specific list.
|
|
if (this.state.queryParams.listID) {
|
|
if (this.state.queryParams.listID) {
|
|
- qParams.list_id = this.state.queryParams.listID
|
|
|
|
|
|
+ qParams.list_id = this.state.queryParams.listID;
|
|
}
|
|
}
|
|
|
|
|
|
if (params) {
|
|
if (params) {
|
|
- qParams = { ...qParams, ...params }
|
|
|
|
|
|
+ qParams = { ...qParams, ...params };
|
|
}
|
|
}
|
|
|
|
|
|
this.props
|
|
this.props
|
|
@@ -388,9 +388,9 @@ class Subscribers extends React.PureComponent {
|
|
page: this.props.data[cs.ModelSubscribers].page,
|
|
page: this.props.data[cs.ModelSubscribers].page,
|
|
query: this.props.data[cs.ModelSubscribers].query
|
|
query: this.props.data[cs.ModelSubscribers].query
|
|
}
|
|
}
|
|
- })
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
|
|
+ });
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
|
|
handleDeleteRecord = record => {
|
|
handleDeleteRecord = record => {
|
|
this.props
|
|
this.props
|
|
@@ -404,15 +404,15 @@ class Subscribers extends React.PureComponent {
|
|
notification["success"]({
|
|
notification["success"]({
|
|
message: "Subscriber deleted",
|
|
message: "Subscriber deleted",
|
|
description: `${record.email} deleted`
|
|
description: `${record.email} deleted`
|
|
- })
|
|
|
|
|
|
+ });
|
|
|
|
|
|
// Reload the table.
|
|
// Reload the table.
|
|
- this.fetchRecords()
|
|
|
|
|
|
+ this.fetchRecords();
|
|
})
|
|
})
|
|
.catch(e => {
|
|
.catch(e => {
|
|
- notification["error"]({ message: "Error", description: e.message })
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
|
|
+ notification["error"]({ message: "Error", description: e.message });
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
|
|
handleDeleteRecords = records => {
|
|
handleDeleteRecords = records => {
|
|
this.props
|
|
this.props
|
|
@@ -426,15 +426,15 @@ class Subscribers extends React.PureComponent {
|
|
notification["success"]({
|
|
notification["success"]({
|
|
message: "Subscriber(s) deleted",
|
|
message: "Subscriber(s) deleted",
|
|
description: "Selected subscribers deleted"
|
|
description: "Selected subscribers deleted"
|
|
- })
|
|
|
|
|
|
+ });
|
|
|
|
|
|
// Reload the table.
|
|
// Reload the table.
|
|
- this.fetchRecords()
|
|
|
|
|
|
+ this.fetchRecords();
|
|
})
|
|
})
|
|
.catch(e => {
|
|
.catch(e => {
|
|
- notification["error"]({ message: "Error", description: e.message })
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
|
|
+ notification["error"]({ message: "Error", description: e.message });
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
|
|
handleBlacklistSubscribers = records => {
|
|
handleBlacklistSubscribers = records => {
|
|
this.props
|
|
this.props
|
|
@@ -445,15 +445,15 @@ class Subscribers extends React.PureComponent {
|
|
notification["success"]({
|
|
notification["success"]({
|
|
message: "Subscriber(s) blacklisted",
|
|
message: "Subscriber(s) blacklisted",
|
|
description: "Selected subscribers blacklisted"
|
|
description: "Selected subscribers blacklisted"
|
|
- })
|
|
|
|
|
|
+ });
|
|
|
|
|
|
// Reload the table.
|
|
// Reload the table.
|
|
- this.fetchRecords()
|
|
|
|
|
|
+ this.fetchRecords();
|
|
})
|
|
})
|
|
.catch(e => {
|
|
.catch(e => {
|
|
- notification["error"]({ message: "Error", description: e.message })
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
|
|
+ notification["error"]({ message: "Error", description: e.message });
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
|
|
// Arbitrary query based calls.
|
|
// Arbitrary query based calls.
|
|
handleDeleteRecordsByQuery = (listIDs, query) => {
|
|
handleDeleteRecordsByQuery = (listIDs, query) => {
|
|
@@ -468,15 +468,15 @@ class Subscribers extends React.PureComponent {
|
|
notification["success"]({
|
|
notification["success"]({
|
|
message: "Subscriber(s) deleted",
|
|
message: "Subscriber(s) deleted",
|
|
description: "Selected subscribers have been deleted"
|
|
description: "Selected subscribers have been deleted"
|
|
- })
|
|
|
|
|
|
+ });
|
|
|
|
|
|
// Reload the table.
|
|
// Reload the table.
|
|
- this.fetchRecords()
|
|
|
|
|
|
+ this.fetchRecords();
|
|
})
|
|
})
|
|
.catch(e => {
|
|
.catch(e => {
|
|
- notification["error"]({ message: "Error", description: e.message })
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
|
|
+ notification["error"]({ message: "Error", description: e.message });
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
|
|
handleBlacklistSubscribersByQuery = (listIDs, query) => {
|
|
handleBlacklistSubscribersByQuery = (listIDs, query) => {
|
|
this.props
|
|
this.props
|
|
@@ -488,22 +488,22 @@ class Subscribers extends React.PureComponent {
|
|
notification["success"]({
|
|
notification["success"]({
|
|
message: "Subscriber(s) blacklisted",
|
|
message: "Subscriber(s) blacklisted",
|
|
description: "Selected subscribers have been blacklisted"
|
|
description: "Selected subscribers have been blacklisted"
|
|
- })
|
|
|
|
|
|
+ });
|
|
|
|
|
|
// Reload the table.
|
|
// Reload the table.
|
|
- this.fetchRecords()
|
|
|
|
|
|
+ this.fetchRecords();
|
|
})
|
|
})
|
|
.catch(e => {
|
|
.catch(e => {
|
|
- notification["error"]({ message: "Error", description: e.message })
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
|
|
+ notification["error"]({ message: "Error", description: e.message });
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
|
|
handleQuerySubscribersIntoLists = (query, sourceList, targetLists) => {
|
|
handleQuerySubscribersIntoLists = (query, sourceList, targetLists) => {
|
|
let params = {
|
|
let params = {
|
|
query: query,
|
|
query: query,
|
|
source_list: sourceList,
|
|
source_list: sourceList,
|
|
target_lists: targetLists
|
|
target_lists: targetLists
|
|
- }
|
|
|
|
|
|
+ };
|
|
|
|
|
|
this.props
|
|
this.props
|
|
.request(cs.Routes.QuerySubscribersIntoLists, cs.MethodPost, params)
|
|
.request(cs.Routes.QuerySubscribersIntoLists, cs.MethodPost, params)
|
|
@@ -511,75 +511,75 @@ class Subscribers extends React.PureComponent {
|
|
notification["success"]({
|
|
notification["success"]({
|
|
message: "Subscriber(s) added",
|
|
message: "Subscriber(s) added",
|
|
description: `${res.data.data.count} added`
|
|
description: `${res.data.data.count} added`
|
|
- })
|
|
|
|
- this.handleToggleListModal()
|
|
|
|
|
|
+ });
|
|
|
|
+ this.handleToggleListModal();
|
|
})
|
|
})
|
|
.catch(e => {
|
|
.catch(e => {
|
|
- notification["error"]({ message: "Error", description: e.message })
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
|
|
+ notification["error"]({ message: "Error", description: e.message });
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
|
|
handleHideForm = () => {
|
|
handleHideForm = () => {
|
|
- this.setState({ formType: null })
|
|
|
|
- }
|
|
|
|
|
|
+ this.setState({ formType: null });
|
|
|
|
+ };
|
|
|
|
|
|
handleShowCreateForm = () => {
|
|
handleShowCreateForm = () => {
|
|
- this.setState({ formType: cs.FormCreate, attribs: [], record: {} })
|
|
|
|
- }
|
|
|
|
|
|
+ this.setState({ formType: cs.FormCreate, attribs: [], record: {} });
|
|
|
|
+ };
|
|
|
|
|
|
handleShowEditForm = record => {
|
|
handleShowEditForm = record => {
|
|
- this.setState({ formType: cs.FormEdit, record: record })
|
|
|
|
- }
|
|
|
|
|
|
+ this.setState({ formType: cs.FormEdit, record: record });
|
|
|
|
+ };
|
|
|
|
|
|
handleToggleListsForm = () => {
|
|
handleToggleListsForm = () => {
|
|
- this.setState({ listsFormVisible: !this.state.listsFormVisible })
|
|
|
|
- }
|
|
|
|
|
|
+ this.setState({ listsFormVisible: !this.state.listsFormVisible });
|
|
|
|
+ };
|
|
|
|
|
|
handleSearch = q => {
|
|
handleSearch = q => {
|
|
- q = q.trim().toLowerCase()
|
|
|
|
|
|
+ q = q.trim().toLowerCase();
|
|
if (q === "") {
|
|
if (q === "") {
|
|
- this.fetchRecords({ query: null })
|
|
|
|
- return
|
|
|
|
|
|
+ this.fetchRecords({ query: null });
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
- q = q.replace(/'/g, "''")
|
|
|
|
- const query = `(name ~* '${q}' OR email ~* '${q}')`
|
|
|
|
- this.fetchRecords({ query: query })
|
|
|
|
- }
|
|
|
|
|
|
+ q = q.replace(/'/g, "''");
|
|
|
|
+ const query = `(name ~* '${q}' OR email ~* '${q}')`;
|
|
|
|
+ this.fetchRecords({ query: query });
|
|
|
|
+ };
|
|
|
|
|
|
handleSelectRow = (_, records) => {
|
|
handleSelectRow = (_, records) => {
|
|
- this.setState({ allRowsSelected: false, selectedRows: records })
|
|
|
|
- }
|
|
|
|
|
|
+ this.setState({ allRowsSelected: false, selectedRows: records });
|
|
|
|
+ };
|
|
|
|
|
|
handleSelectAllRows = () => {
|
|
handleSelectAllRows = () => {
|
|
this.setState({
|
|
this.setState({
|
|
allRowsSelected: true,
|
|
allRowsSelected: true,
|
|
selectedRows: this.props.data[cs.ModelSubscribers].results
|
|
selectedRows: this.props.data[cs.ModelSubscribers].results
|
|
- })
|
|
|
|
- }
|
|
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
|
|
clearSelectedRows = (_, records) => {
|
|
clearSelectedRows = (_, records) => {
|
|
- this.setState({ allRowsSelected: false, selectedRows: [] })
|
|
|
|
- }
|
|
|
|
|
|
+ this.setState({ allRowsSelected: false, selectedRows: [] });
|
|
|
|
+ };
|
|
|
|
|
|
handleToggleQueryForm = () => {
|
|
handleToggleQueryForm = () => {
|
|
- this.setState({ queryFormVisible: !this.state.queryFormVisible })
|
|
|
|
- }
|
|
|
|
|
|
+ this.setState({ queryFormVisible: !this.state.queryFormVisible });
|
|
|
|
+ };
|
|
|
|
|
|
handleToggleListModal = () => {
|
|
handleToggleListModal = () => {
|
|
- this.setState({ listModalVisible: !this.state.listModalVisible })
|
|
|
|
- }
|
|
|
|
|
|
+ this.setState({ listModalVisible: !this.state.listModalVisible });
|
|
|
|
+ };
|
|
|
|
|
|
render() {
|
|
render() {
|
|
const pagination = {
|
|
const pagination = {
|
|
...this.paginationOptions,
|
|
...this.paginationOptions,
|
|
...this.state.queryParams
|
|
...this.state.queryParams
|
|
- }
|
|
|
|
|
|
+ };
|
|
|
|
|
|
if (this.state.queryParams.list) {
|
|
if (this.state.queryParams.list) {
|
|
- this.props.pageTitle(this.state.queryParams.list.name + " / Subscribers")
|
|
|
|
|
|
+ this.props.pageTitle(this.state.queryParams.list.name + " / Subscribers");
|
|
} else {
|
|
} else {
|
|
- this.props.pageTitle("Subscribers")
|
|
|
|
|
|
+ this.props.pageTitle("Subscribers");
|
|
}
|
|
}
|
|
|
|
|
|
return (
|
|
return (
|
|
@@ -644,7 +644,7 @@ class Subscribers extends React.PureComponent {
|
|
...this.state.queryParams,
|
|
...this.state.queryParams,
|
|
query: e.target.value
|
|
query: e.target.value
|
|
}
|
|
}
|
|
- })
|
|
|
|
|
|
+ });
|
|
}}
|
|
}}
|
|
value={this.state.queryParams.query}
|
|
value={this.state.queryParams.query}
|
|
autosize={{ minRows: 2, maxRows: 10 }}
|
|
autosize={{ minRows: 2, maxRows: 10 }}
|
|
@@ -661,7 +661,7 @@ class Subscribers extends React.PureComponent {
|
|
type="primary"
|
|
type="primary"
|
|
icon="search"
|
|
icon="search"
|
|
onClick={() => {
|
|
onClick={() => {
|
|
- this.fetchRecords()
|
|
|
|
|
|
+ this.fetchRecords();
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
Query
|
|
Query
|
|
@@ -670,7 +670,7 @@ class Subscribers extends React.PureComponent {
|
|
disabled={this.state.queryParams.query === ""}
|
|
disabled={this.state.queryParams.query === ""}
|
|
icon="refresh"
|
|
icon="refresh"
|
|
onClick={() => {
|
|
onClick={() => {
|
|
- this.fetchRecords({ query: null })
|
|
|
|
|
|
+ this.fetchRecords({ query: null });
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
Reset
|
|
Reset
|
|
@@ -717,11 +717,11 @@ class Subscribers extends React.PureComponent {
|
|
? [this.state.queryParams.listID]
|
|
? [this.state.queryParams.listID]
|
|
: [],
|
|
: [],
|
|
this.state.queryParams.query
|
|
this.state.queryParams.query
|
|
- )
|
|
|
|
- this.clearSelectedRows()
|
|
|
|
|
|
+ );
|
|
|
|
+ this.clearSelectedRows();
|
|
} else {
|
|
} else {
|
|
- this.handleDeleteRecords(this.state.selectedRows)
|
|
|
|
- this.clearSelectedRows()
|
|
|
|
|
|
+ this.handleDeleteRecords(this.state.selectedRows);
|
|
|
|
+ this.clearSelectedRows();
|
|
}
|
|
}
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
@@ -738,13 +738,13 @@ class Subscribers extends React.PureComponent {
|
|
? [this.state.queryParams.listID]
|
|
? [this.state.queryParams.listID]
|
|
: [],
|
|
: [],
|
|
this.state.queryParams.query
|
|
this.state.queryParams.query
|
|
- )
|
|
|
|
- this.clearSelectedRows()
|
|
|
|
|
|
+ );
|
|
|
|
+ this.clearSelectedRows();
|
|
} else {
|
|
} else {
|
|
this.handleBlacklistSubscribers(
|
|
this.handleBlacklistSubscribers(
|
|
this.state.selectedRows
|
|
this.state.selectedRows
|
|
- )
|
|
|
|
- this.clearSelectedRows()
|
|
|
|
|
|
+ );
|
|
|
|
+ this.clearSelectedRows();
|
|
}
|
|
}
|
|
}}
|
|
}}
|
|
>
|
|
>
|
|
@@ -767,9 +767,9 @@ class Subscribers extends React.PureComponent {
|
|
!this.props.data[cs.ModelSubscribers] ||
|
|
!this.props.data[cs.ModelSubscribers] ||
|
|
!this.props.data[cs.ModelSubscribers].hasOwnProperty("results")
|
|
!this.props.data[cs.ModelSubscribers].hasOwnProperty("results")
|
|
) {
|
|
) {
|
|
- return []
|
|
|
|
|
|
+ return [];
|
|
}
|
|
}
|
|
- return this.props.data[cs.ModelSubscribers].results
|
|
|
|
|
|
+ return this.props.data[cs.ModelSubscribers].results;
|
|
})()}
|
|
})()}
|
|
loading={this.props.reqStates[cs.ModelSubscribers] !== cs.StateDone}
|
|
loading={this.props.reqStates[cs.ModelSubscribers] !== cs.StateDone}
|
|
pagination={pagination}
|
|
pagination={pagination}
|
|
@@ -789,16 +789,16 @@ class Subscribers extends React.PureComponent {
|
|
confirmLoading={this.state.modalWaiting}
|
|
confirmLoading={this.state.modalWaiting}
|
|
onOk={e => {
|
|
onOk={e => {
|
|
if (!this.state.modalForm) {
|
|
if (!this.state.modalForm) {
|
|
- return
|
|
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
// This submits the form embedded in the Subscriber component.
|
|
// This submits the form embedded in the Subscriber component.
|
|
this.state.modalForm.submitForm(e, ok => {
|
|
this.state.modalForm.submitForm(e, ok => {
|
|
if (ok) {
|
|
if (ok) {
|
|
- this.handleHideForm()
|
|
|
|
- this.fetchRecords()
|
|
|
|
|
|
+ this.handleHideForm();
|
|
|
|
+ this.fetchRecords();
|
|
}
|
|
}
|
|
- })
|
|
|
|
|
|
+ });
|
|
}}
|
|
}}
|
|
onCancel={this.handleHideForm}
|
|
onCancel={this.handleHideForm}
|
|
okButtonProps={{
|
|
okButtonProps={{
|
|
@@ -813,10 +813,10 @@ class Subscribers extends React.PureComponent {
|
|
record={this.state.record}
|
|
record={this.state.record}
|
|
ref={r => {
|
|
ref={r => {
|
|
if (!r) {
|
|
if (!r) {
|
|
- return
|
|
|
|
|
|
+ return;
|
|
}
|
|
}
|
|
|
|
|
|
- this.setState({ modalForm: r })
|
|
|
|
|
|
+ this.setState({ modalForm: r });
|
|
}}
|
|
}}
|
|
/>
|
|
/>
|
|
</Modal>
|
|
</Modal>
|
|
@@ -825,7 +825,7 @@ class Subscribers extends React.PureComponent {
|
|
{this.state.listsFormVisible && (
|
|
{this.state.listsFormVisible && (
|
|
<ListsForm
|
|
<ListsForm
|
|
{...this.props}
|
|
{...this.props}
|
|
- lists={this.props.data[cs.ModelLists]}
|
|
|
|
|
|
+ lists={this.props.data[cs.ModelLists].results}
|
|
allRowsSelected={this.state.allRowsSelected}
|
|
allRowsSelected={this.state.allRowsSelected}
|
|
selectedRows={this.state.selectedRows}
|
|
selectedRows={this.state.selectedRows}
|
|
selectedLists={
|
|
selectedLists={
|
|
@@ -840,8 +840,8 @@ class Subscribers extends React.PureComponent {
|
|
/>
|
|
/>
|
|
)}
|
|
)}
|
|
</section>
|
|
</section>
|
|
- )
|
|
|
|
|
|
+ );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-export default Subscribers
|
|
|
|
|
|
+export default Subscribers;
|