- Work-in-progress on the UI
This commit is contained in:
@@ -16,10 +16,11 @@ define(
|
||||
return;
|
||||
}
|
||||
jQuery(document).ready(function () {
|
||||
// halt operation if there are no lists with subscribers found
|
||||
if (!exportData.lists) return;
|
||||
|
||||
var subscribers_export_template = Handlebars.compile($('#mailpoet_subscribers_export_template').html());
|
||||
if (!exportData.segments) {
|
||||
return;
|
||||
}
|
||||
var subscribers_export_template =
|
||||
Handlebars.compile(jQuery('#mailpoet_subscribers_export_template').html());
|
||||
|
||||
//render template
|
||||
jQuery('#mailpoet_subscribers_export > div.inside').html(subscribers_export_template(exportData));
|
||||
@@ -53,18 +54,28 @@ define(
|
||||
})
|
||||
.on('select2:selecting', function (selectEvent) {
|
||||
var selectElement = this,
|
||||
selectedOptionId = selectEvent.params.args.data.id;
|
||||
|
||||
});
|
||||
/* .change(function (event) {
|
||||
var trigger_element = this;
|
||||
|
||||
if (event.added && event.added.id === 'deselect_all') jQuery(trigger_element).select2('val', '');
|
||||
if (event.added && event.added.id === 'select_all') jQuery(trigger_element).select2('val', columns_ids);
|
||||
|
||||
if ((exportData.lists && segmentsContainerElement.select2('data').length && subscriberFieldsContainerElement.select2('data').length)
|
||||
selectedOptionId = selectEvent.params.args.data.id,
|
||||
fieldsToExclude = ['select', 'deselect'];
|
||||
if (_.contains(fieldsToExclude, selectedOptionId)) {
|
||||
selectEvent.preventDefault();
|
||||
if (selectedOptionId === 'deselect') {
|
||||
jQuery(selectElement).select2('val', '');
|
||||
} else {
|
||||
var allOptions = [];
|
||||
_.each(container.find('option'), function (field) {
|
||||
if (!_.contains(fieldsToExclude, field.value)) {
|
||||
allOptions.push(field.value);
|
||||
}
|
||||
});
|
||||
jQuery(selectElement).select2('val', allOptions);
|
||||
}
|
||||
jQuery(selectElement).select2('close');
|
||||
}
|
||||
})
|
||||
.on('change', function() {
|
||||
if ((exportData.segments && segmentsContainerElement.select2('data').length && subscriberFieldsContainerElement.select2('data').length)
|
||||
||
|
||||
(!exportData.lists && subscriberFieldsContainerElement.select2('data').length)
|
||||
(!exportData.segments && subscriberFieldsContainerElement.select2('data').length)
|
||||
) {
|
||||
jQuery(nextStepElement).removeClass('button-disabled');
|
||||
}
|
||||
@@ -76,62 +87,59 @@ define(
|
||||
jQuery('.mailpoet_group_by_list').show();
|
||||
}
|
||||
else if (exportData.group_by_list) jQuery('.mailpoet_group_by_list').hide();
|
||||
})*/
|
||||
});
|
||||
};
|
||||
|
||||
// render lists and columns
|
||||
renderSegmentsAndFields(subscriberFieldsContainerElement, columns);
|
||||
renderSegmentsAndFields(segmentsContainerElement, lists);
|
||||
renderSegmentsAndFields(subscriberFieldsContainerElement, subscriberFieldsSelect2);
|
||||
renderSegmentsAndFields(segmentsContainerElement, segments);
|
||||
|
||||
// pre-select columns
|
||||
// subscriberFieldsContainerElement.select2('val', ['subscriber_state', 'subscriber_email', 'subscriber_firstname', 'subscriber_lastname']);
|
||||
subscriberFieldsContainerElement.select2('val', ['status', 'email', 'first_name', 'last_name']);
|
||||
|
||||
// handle confirmed/unconfirmed behavior
|
||||
exportConfirmedOptionElement.change(function () {
|
||||
if (this.value == 1) {
|
||||
exportData.confirmed_option = true;
|
||||
renderSegmentsAndFields(segmentsContainerElement, lists_confirmed);
|
||||
renderSegmentsAndFields(segmentsContainerElement, segmentsWithConfirmedSubscribers);
|
||||
}
|
||||
else {
|
||||
exportData.confirmed_option = false;
|
||||
renderSegmentsAndFields(segmentsContainerElement, lists);
|
||||
renderSegmentsAndFields(segmentsContainerElement, segments);
|
||||
}
|
||||
});
|
||||
/*
|
||||
// process export
|
||||
nextStepElement.click(function () {
|
||||
if (jQuery(this).hasClass('button-disabled')) return;
|
||||
MailPoet.Modal.loading(true);
|
||||
mailpoet_post_json(
|
||||
'subscribers_export.php',
|
||||
{
|
||||
'option_confirmed': exportData.confirmed_option,
|
||||
'option_format': jQuery(':radio[name="option_format"]:checked').val(),
|
||||
'option_group_by_list': (groupBySegmentOptionElement.is(":visible")) ? groupBySegmentOptionElement.prop('checked') : false,
|
||||
'lists': (exportData.lists) ? segmentsContainerElement.select2('val') : false,
|
||||
'columns': subscriberFieldsContainerElement.select2('data'),
|
||||
'export_directory': export_directory
|
||||
},
|
||||
function (response) {
|
||||
if (response.result === true) {
|
||||
response.message = "<?php _e('%1$s subscribers were exported. Get the exported file [link]here[/link].'); ?>"
|
||||
.replace('%1$s', '<strong>' + response.total + '</strong>')
|
||||
.replace('[link]', '<a href="' + export_url + response.filename + '" target="_blank" >')
|
||||
.replace('[/link]', '</a>')
|
||||
jQuery('#export_result_notice > ul > li').html(response.message)
|
||||
jQuery('#export_result_notice').show();
|
||||
window.location.href = export_url + response.filename;
|
||||
}
|
||||
else {
|
||||
MailPoet.Notice.error(response.message);
|
||||
}
|
||||
MailPoet.Modal.loading(false);
|
||||
},
|
||||
function (response) {
|
||||
MailPoet.Modal.loading(false);
|
||||
MailPoet.Notice.error('<?php _e("Server error:"); ?> ' + response.statusText.toLowerCase() + '.', {scroll: true});
|
||||
}
|
||||
)
|
||||
})*/
|
||||
/*
|
||||
// process export
|
||||
nextStepElement.click(function () {
|
||||
if (jQuery(this).hasClass('button-disabled')) return;
|
||||
MailPoet.Modal.loading(true);
|
||||
mailpoet_post_json(
|
||||
'subscribers_export.php',
|
||||
{
|
||||
'option_confirmed': exportData.confirmed_option,
|
||||
'option_format': jQuery(':radio[name="option_format"]:checked').val(),
|
||||
'option_group_by_list': (groupBySegmentOptionElement.is(":visible")) ? groupBySegmentOptionElement.prop('checked') : false,
|
||||
'segments': (exportData.segments) ? segmentsContainerElement.select2('val') : false,
|
||||
'columns': subscriberFieldsContainerElement.select2('data'),
|
||||
'export_directory': export_directory
|
||||
},
|
||||
function (response) {
|
||||
if (response.result === true) {
|
||||
response.message = "<?php _e('%1$s subscribers were exported. Get the exported file [link]here[/link].'); ?>"
|
||||
.replace('%1$s', '<strong>' + response.total + '</strong>')
|
||||
.replace('[link]', '<a href="' + export_url + response.filename + '" target="_blank" >')
|
||||
.replace('[/link]', '</a>')
|
||||
jQuery('#export_result_notice > ul > li').html(response.message)
|
||||
jQuery('#export_result_notice').show();
|
||||
window.location.href = export_url + response.filename;
|
||||
}
|
||||
else {
|
||||
MailPoet.Notice.error(response.message);
|
||||
}
|
||||
MailPoet.Modal.loading(false);
|
||||
},
|
||||
function (response) {
|
||||
MailPoet.Modal.loading(false);
|
||||
MailPoet.Notice.error('<?php _e("Server error:"); ?> ' + response.statusText.toLowerCase() + '.', {scroll: true});
|
||||
}
|
||||
)
|
||||
})*/
|
||||
});
|
||||
});
|
@@ -146,7 +146,7 @@ class BootStrapMenuCest {
|
||||
array(
|
||||
'name' => 'System columns',
|
||||
'children' => $bootStrapMenu->formatSubscriberFields(
|
||||
$bootStrapMenu->subscriberFields
|
||||
$bootStrapMenu->getSubscriberFields()
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -156,7 +156,7 @@ class BootStrapMenuCest {
|
||||
array(
|
||||
'name' => __('User columns'),
|
||||
'children' => $bootStrapMenu->formatSubscriberCustomFields(
|
||||
$bootStrapMenu->subscriberCustomFields
|
||||
$bootStrapMenu->getSubscriberCustomFields()
|
||||
)
|
||||
)
|
||||
));
|
||||
@@ -165,10 +165,9 @@ class BootStrapMenuCest {
|
||||
$bootStrapMenu->getSubscriberCustomFields()
|
||||
);
|
||||
expect($formattedFieldsForSelect2)->equals($select2FieldsWithCustomFields);
|
||||
$bootStrapMenu->subscriberCustomFields = false;
|
||||
$formattedFieldsForSelect2 = $bootStrapMenu->formatFieldsForSelect2(
|
||||
$bootStrapMenu->getSubscriberFields(),
|
||||
$bootStrapMenu->getSubscriberCustomFields()
|
||||
array()
|
||||
);
|
||||
expect($formattedFieldsForSelect2)->equals($select2FieldsWithoutCustomFields);
|
||||
}
|
||||
@@ -192,7 +191,7 @@ class BootStrapMenuCest {
|
||||
array(
|
||||
'name' => 'System columns',
|
||||
'children' => $bootStrapMenu->formatSubscriberFields(
|
||||
$bootStrapMenu->subscriberFields
|
||||
$bootStrapMenu->getSubscriberFields()
|
||||
)
|
||||
)
|
||||
);
|
||||
@@ -202,7 +201,7 @@ class BootStrapMenuCest {
|
||||
array(
|
||||
'name' => __('User columns'),
|
||||
'children' => $bootStrapMenu->formatSubscriberCustomFields(
|
||||
$bootStrapMenu->subscriberCustomFields
|
||||
$bootStrapMenu->getSubscriberCustomFields()
|
||||
)
|
||||
)
|
||||
));
|
||||
@@ -211,10 +210,9 @@ class BootStrapMenuCest {
|
||||
$bootStrapMenu->getSubscriberCustomFields()
|
||||
);
|
||||
expect($formattedFieldsForSelect2)->equals($select2FieldsWithCustomFields);
|
||||
$bootStrapMenu->subscriberCustomFields = false;
|
||||
$formattedFieldsForSelect2 = $bootStrapMenu->formatFieldsForSelect2(
|
||||
$bootStrapMenu->getSubscriberFields(),
|
||||
$bootStrapMenu->getSubscriberCustomFields()
|
||||
array()
|
||||
);
|
||||
expect($formattedFieldsForSelect2)->equals($select2FieldsWithoutCustomFields);
|
||||
}
|
||||
|
@@ -118,7 +118,7 @@
|
||||
exportData = {
|
||||
segments: segments.length || null,
|
||||
segmentsWithConfirmedSubscribers: segmentsWithConfirmedSubscribers.length || null,
|
||||
exportConfirmedOption: false,
|
||||
exportConfirmedOption: true,
|
||||
groupBySegmentOption: (segments.length > 1 || segmentsWithConfirmedSubscribers.length > 1) ? true : null
|
||||
},
|
||||
export_location = '',
|
||||
|
Reference in New Issue
Block a user