Ask user to update existing subscribers
[MAILPOET-1809]
This commit is contained in:
@@ -15,32 +15,12 @@ import StepResults from './import/step_results.jsx';
|
|||||||
jQuery(document).ready(() => {
|
jQuery(document).ready(() => {
|
||||||
|
|
||||||
router.on('route:step_data_manipulation', () => {
|
router.on('route:step_data_manipulation', () => {
|
||||||
let fillerPosition;
|
|
||||||
|
|
||||||
// define reusable variables
|
// define reusable variables
|
||||||
const nextStepButton = jQuery('#next_step');
|
const nextStepButton = jQuery('#next_step');
|
||||||
|
|
||||||
// create a copy of subscribers object for further manipulation
|
// create a copy of subscribers object for further manipulation
|
||||||
const subscribers = jQuery.extend(true, {}, window.importData.step_method_selection);
|
|
||||||
const subscribersDataTemplate = Handlebars.compile(jQuery('#subscribers_data_template').html());
|
|
||||||
const subscribersDataTemplatePartial = Handlebars.compile(jQuery('#subscribers_data_template_partial').html());
|
|
||||||
const segmentSelectElement = jQuery('#mailpoet_segments_select');
|
const segmentSelectElement = jQuery('#mailpoet_segments_select');
|
||||||
const maxRowsToShow = 10;
|
|
||||||
const filler = '. . .';
|
|
||||||
// create an array of filler data with the same number of
|
|
||||||
// elements as in the subscribers' data row
|
|
||||||
const fillerArray = Array(...new Array(subscribers.subscribers[0].length))
|
|
||||||
.map(String.prototype.valueOf, filler);
|
|
||||||
|
|
||||||
function toggleNextStepButton(condition) {
|
|
||||||
const disabled = 'button-disabled';
|
|
||||||
if (condition === 'on') {
|
|
||||||
nextStepButton.removeClass(disabled);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
nextStepButton.addClass(disabled);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
nextStepButton.off().on('click', (event) => {
|
nextStepButton.off().on('click', (event) => {
|
||||||
|
@@ -5,6 +5,7 @@ import PreviousNextStepButtons from './previous_next_step_buttons.jsx';
|
|||||||
import Warnings from './step_data_manipulation/warnings.jsx';
|
import Warnings from './step_data_manipulation/warnings.jsx';
|
||||||
import MatchTable from './step_data_manipulation/match_table.jsx';
|
import MatchTable from './step_data_manipulation/match_table.jsx';
|
||||||
import SelectSegment from './step_data_manipulation/select_segment.jsx';
|
import SelectSegment from './step_data_manipulation/select_segment.jsx';
|
||||||
|
import UpdateExistingSubscribers from './step_data_manipulation/update_existing_subscribers.jsx';
|
||||||
|
|
||||||
function getPreviousStepLink(importData, subscribersLimitForValidation) {
|
function getPreviousStepLink(importData, subscribersLimitForValidation) {
|
||||||
if (importData === undefined) {
|
if (importData === undefined) {
|
||||||
@@ -25,6 +26,7 @@ function StepDataManipulation({
|
|||||||
subscribersLimitForValidation,
|
subscribersLimitForValidation,
|
||||||
}) {
|
}) {
|
||||||
const [selectedSegments, setSelectedSegments] = useState([]);
|
const [selectedSegments, setSelectedSegments] = useState([]);
|
||||||
|
const [updateExistingSubscribers, setUpdateExistingSubscribers] = useState(true);
|
||||||
useEffect(
|
useEffect(
|
||||||
() => {
|
() => {
|
||||||
if (typeof (stepMethodSelectionData) === 'undefined') {
|
if (typeof (stepMethodSelectionData) === 'undefined') {
|
||||||
@@ -49,6 +51,10 @@ function StepDataManipulation({
|
|||||||
header={stepMethodSelectionData.header}
|
header={stepMethodSelectionData.header}
|
||||||
/>
|
/>
|
||||||
<SelectSegment setSelectedSegments={setSelectedSegments} />
|
<SelectSegment setSelectedSegments={setSelectedSegments} />
|
||||||
|
<UpdateExistingSubscribers
|
||||||
|
setUpdateExistingSubscribers={setUpdateExistingSubscribers}
|
||||||
|
updateExistingSubscribers={updateExistingSubscribers}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
<PreviousNextStepButtons
|
<PreviousNextStepButtons
|
||||||
canGoNext={selectedSegments.length > 0}
|
canGoNext={selectedSegments.length > 0}
|
||||||
|
@@ -0,0 +1,38 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import MailPoet from 'mailpoet';
|
||||||
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
function UpdateExistingSubscribers({ updateExistingSubscribers, setUpdateExistingSubscribers }) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{MailPoet.I18n.t('updateExistingSubscribers')}
|
||||||
|
<label htmlFor="update_existing_subscribers">
|
||||||
|
<input
|
||||||
|
id="update_existing_subscribers"
|
||||||
|
type="radio"
|
||||||
|
name="update_existing_subscribers"
|
||||||
|
checked={updateExistingSubscribers}
|
||||||
|
onChange={() => setUpdateExistingSubscribers(true)}
|
||||||
|
/>
|
||||||
|
{MailPoet.I18n.t('updateExistingSubscribersYes')}
|
||||||
|
</label>
|
||||||
|
<label htmlFor="dont_update_existing_subscribers">
|
||||||
|
<input
|
||||||
|
id="dont_update_existing_subscribers"
|
||||||
|
type="radio"
|
||||||
|
name="update_existing_subscribers"
|
||||||
|
checked={!updateExistingSubscribers}
|
||||||
|
onChange={() => setUpdateExistingSubscribers(false)}
|
||||||
|
/>
|
||||||
|
{MailPoet.I18n.t('updateExistingSubscribersNo')}
|
||||||
|
</label>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateExistingSubscribers.propTypes = {
|
||||||
|
setUpdateExistingSubscribers: PropTypes.func.isRequired,
|
||||||
|
updateExistingSubscribers: PropTypes.bool.isRequired,
|
||||||
|
};
|
||||||
|
|
||||||
|
export default UpdateExistingSubscribers;
|
@@ -103,6 +103,9 @@
|
|||||||
'pickListsDescription': __('Pick the list that you want to import these subscribers to.'),
|
'pickListsDescription': __('Pick the list that you want to import these subscribers to.'),
|
||||||
'select': _x('Select', ' Verb'),
|
'select': _x('Select', ' Verb'),
|
||||||
'createANewList': __('Create a new list'),
|
'createANewList': __('Create a new list'),
|
||||||
|
'updateExistingSubscribers': __("Update existing subscribers' information"),
|
||||||
|
'updateExistingSubscribersYes': __('Yes'),
|
||||||
|
'updateExistingSubscribersNo': __('No'),
|
||||||
'addSubscribersToSegment': __(' To add subscribers to a mailing segment, [link]create a list[/link].'),
|
'addSubscribersToSegment': __(' To add subscribers to a mailing segment, [link]create a list[/link].'),
|
||||||
'methodUpload': __('Upload a file'),
|
'methodUpload': __('Upload a file'),
|
||||||
'methodMailChimp': __('Import from MailChimp'),
|
'methodMailChimp': __('Import from MailChimp'),
|
||||||
|
@@ -1,34 +1,5 @@
|
|||||||
<div id="step_data_manipulation" class="mailpoet_hidden">
|
<div id="step_data_manipulation" class="mailpoet_hidden">
|
||||||
<div id="subscribers_data_parse_results">
|
|
||||||
<!-- Template data -->
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="inside">
|
<div class="inside">
|
||||||
<br>
|
|
||||||
|
|
||||||
|
|
||||||
<table class="mailpoet_subscribers form-table">
|
|
||||||
|
|
||||||
<tr>
|
|
||||||
<th scope="row">
|
|
||||||
<label>
|
|
||||||
<%= __("Update existing subscribers' information") %>
|
|
||||||
</label>
|
|
||||||
</th>
|
|
||||||
<td>
|
|
||||||
<label>
|
|
||||||
<input type="radio" name="subscriber_update_option" value="yes"
|
|
||||||
checked><span><%= __('Yes') %></span>
|
|
||||||
</label>
|
|
||||||
<label>
|
|
||||||
<input type="radio" name="subscriber_update_option"
|
|
||||||
value="no"><span><%= __('No') %></span>
|
|
||||||
</label>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<!-- New segment template -->
|
<!-- New segment template -->
|
||||||
<script id="new_segment_template" type="text/x-handlebars-template">
|
<script id="new_segment_template" type="text/x-handlebars-template">
|
||||||
|
Reference in New Issue
Block a user