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