Restore default select2 search behavior
The select2 data format requires that all option objects include both an `id` and `text`. See https://select2.org/data-sources/formats By restoring these duplicate properties, we avoid having to write and maintain a custom matcher method, and we're protecting ourselves against any other unexpected behavior in the future resulting from these options not having the required `text` property. [MAILPOET-3958]
This commit is contained in:
committed by
Veljko V
parent
f193957096
commit
22e3686810
@@ -72,6 +72,7 @@ class ImportExportFactory {
|
||||
return [
|
||||
'id' => $fieldId,
|
||||
'name' => $fieldName,
|
||||
'text' => $fieldName, // Required for select2 default functionality
|
||||
'type' => ($fieldId === 'confirmed_at' || $fieldId === 'created_at') ? 'date' : null,
|
||||
'custom' => false,
|
||||
];
|
||||
@@ -87,6 +88,7 @@ class ImportExportFactory {
|
||||
return [
|
||||
'id' => $field['id'],
|
||||
'name' => $field['name'],
|
||||
'text' => $field['name'], // Required for select2 default functionality
|
||||
'type' => $field['type'],
|
||||
'params' => unserialize($field['params']),
|
||||
'custom' => true,
|
||||
@@ -103,35 +105,42 @@ class ImportExportFactory {
|
||||
[
|
||||
'id' => 'ignore',
|
||||
'name' => __('Ignore field...', 'mailpoet'),
|
||||
'text' => __('Ignore field...', 'mailpoet'), // Required for select2 default functionality
|
||||
],
|
||||
[
|
||||
'id' => 'create',
|
||||
'name' => __('Create new field...', 'mailpoet'),
|
||||
'text' => __('Create new field...', 'mailpoet'), // Required for select2 default functionality
|
||||
],
|
||||
] :
|
||||
[
|
||||
[
|
||||
'id' => 'select',
|
||||
'name' => __('Select all...', 'mailpoet'),
|
||||
'text' => __('Select all...', 'mailpoet'), // Required for select2 default functionality
|
||||
],
|
||||
[
|
||||
'id' => 'deselect',
|
||||
'name' => __('Deselect all...', 'mailpoet'),
|
||||
'text' => __('Deselect all...', 'mailpoet'), // Required for select2 default functionality
|
||||
],
|
||||
];
|
||||
$select2Fields = [
|
||||
[
|
||||
'name' => __('Actions', 'mailpoet'),
|
||||
'text' => __('Actions', 'mailpoet'), // Required for select2 default functionality
|
||||
'children' => $actions,
|
||||
],
|
||||
[
|
||||
'name' => __('System fields', 'mailpoet'),
|
||||
'text' => __('System fields', 'mailpoet'), // Required for select2 default functionality
|
||||
'children' => $this->formatSubscriberFields($subscriberFields),
|
||||
],
|
||||
];
|
||||
if ($subscriberCustomFields) {
|
||||
array_push($select2Fields, [
|
||||
'name' => __('User fields', 'mailpoet'),
|
||||
'text' => __('User fields', 'mailpoet'), // Required for select2 default functionality
|
||||
'children' => $this->formatSubscriberCustomFields(
|
||||
$subscriberCustomFields
|
||||
),
|
||||
|
Reference in New Issue
Block a user