- Work-in-progress on the UI

This commit is contained in:
MrCasual
2015-11-12 09:07:50 -05:00
parent f2a0d4ce96
commit 0017df1c2d
3 changed files with 75 additions and 69 deletions

View File

@@ -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;
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);
}
});
/* .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)
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,25 +87,22 @@ 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);
}
});
/*
@@ -108,7 +116,7 @@ define(
'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,
'segments': (exportData.segments) ? segmentsContainerElement.select2('val') : false,
'columns': subscriberFieldsContainerElement.select2('data'),
'export_directory': export_directory
},

View File

@@ -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);
}

View File

@@ -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 = '',