Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/code/Magento/Email/Model/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ public function getVariablesOptionArray($withGroup = false)
$optionArray[] = ['value' => '{{' . $value . '}}', 'label' => __('%1', $label)];
}
if ($withGroup) {
$optionArray = ['label' => __('Template Variables'), 'value' => $optionArray];
$optionArray = [['label' => __('Template Variables'), 'value' => $optionArray]];
}
}
return $optionArray;
Expand Down
28 changes: 15 additions & 13 deletions app/code/Magento/Email/Test/Unit/Model/TemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -595,19 +595,21 @@ public function getVariablesOptionArrayDataProvider()
'templateVariables' => '{"store url=\"\"":"Store Url","var logo_url":"Email Logo Image Url",'
. '"var customer.name":"Customer Name"}',
'expectedResult' => [
'label' => __('Template Variables'),
'value' => [
[
'value' => '{{store url=""}}',
'label' => __('%1', 'Store Url'),
],
[
'value' => '{{var logo_url}}',
'label' => __('%1', 'Email Logo Image Url'),
],
[
'value' => '{{var customer.name}}',
'label' => __('%1', 'Customer Name'),
[
'label' => __('Template Variables'),
'value' => [
[
'value' => '{{store url=""}}',
'label' => __('%1', 'Store Url'),
],
[
'value' => '{{var logo_url}}',
'label' => __('%1', 'Email Logo Image Url'),
],
[
'value' => '{{var customer.name}}',
'label' => __('%1', 'Customer Name'),
],
],
],
],
Expand Down
17 changes: 11 additions & 6 deletions app/code/Magento/Email/view/adminhtml/web/js/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,17 @@ define([
variables.each(function (variableGroup) {
if (variableGroup.label && variableGroup.value) {
this.variablesContent += '<li><b>' + variableGroup.label + '</b></li>';
variableGroup.value.each(function (variable) {
if (variable.value && variable.label) {
this.variablesContent += '<li>' +
this.prepareVariableRow(variable.value, variable.label) + '</li>';
}
}.bind(this));
if (typeof variableGroup.value === 'object' && !!variableGroup.value) {
variableGroup.value.each(function (variable) {
if (variable.value && variable.label) {
this.variablesContent += '<li>' +
this.prepareVariableRow(variable.value, variable.label) + '</li>';
}
}.bind(this));
} else {
this.variablesContent += '<li>' +
this.prepareVariableRow(variableGroup.value, variableGroup.label) + '</li>';
}
}
}.bind(this));
this.variablesContent += '</ul>';
Expand Down