Commit 5127c223 authored by Georg Ringer's avatar Georg Ringer Committed by Christian Kuhn
Browse files

[TASK] Render wizards of FormEngine elements only if needed

Reduce the HTML of a record form by rendering divs of wizards only
if those are required.

Resolves: #85577
Releases: master
Change-Id: I6ca6ad5c3ebd1a1aa949a9a0349bd7894e4532df
Reviewed-on: https://review.typo3.org/57614

Reviewed-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: Anja Leichsenring's avatarAnja Leichsenring <aleichsenring@ab-softlab.de>
Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Mona Muzaffar's avatarMona Muzaffar <mona.muzaffar@gmx.de>
Tested-by: Mona Muzaffar's avatarMona Muzaffar <mona.muzaffar@gmx.de>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent da0d842d
......@@ -146,7 +146,7 @@ class CheckboxElement extends AbstractFormElement
$html[] = '<div class="form-wizards-element">';
$html[] = $elementHtml;
$html[] = '</div>';
if (!$disabled) {
if (!$disabled && !empty($fieldWizardHtml)) {
$html[] = '<div class="form-wizards-items-bottom">';
$html[] = $fieldWizardHtml;
$html[] = '</div>';
......
......@@ -145,7 +145,7 @@ class CheckboxLabeledToggleElement extends AbstractFormElement
$html[] = '<div class="form-wizards-element">';
$html[] = $elementHtml;
$html[] = '</div>';
if (!$disabled) {
if (!$disabled && !empty($fieldWizardHtml)) {
$html[] = '<div class="form-wizards-items-bottom">';
$html[] = $fieldWizardHtml;
$html[] = '</div>';
......
......@@ -145,7 +145,7 @@ class CheckboxToggleElement extends AbstractFormElement
$html[] = '<div class="form-wizards-element">';
$html[] = $elementHtml;
$html[] = '</div>';
if (!$disabled) {
if (!$disabled && !empty($fieldWizardHtml)) {
$html[] = '<div class="form-wizards-items-bottom">';
$html[] = $fieldWizardHtml;
$html[] = '</div>';
......
......@@ -400,9 +400,11 @@ class GroupElement extends AbstractFormElement
$html[] = $fieldControlHtml;
$html[] = '</div>';
$html[] = '</div>';
$html[] = '<div class="form-wizards-items-bottom">';
$html[] = $fieldWizardHtml;
$html[] = '</div>';
if (!empty($fieldWizardHtml)) {
$html[] = '<div class="form-wizards-items-bottom">';
$html[] = $fieldWizardHtml;
$html[] = '</div>';
}
$html[] = '</div>';
$html[] = '<input type="hidden" name="' . htmlspecialchars($elementName) . '" value="' . htmlspecialchars(implode(',', $listOfSelectedValues)) . '" />';
$html[] = '</div>';
......
......@@ -186,9 +186,11 @@ class InputColorPickerElement extends AbstractFormElement
$mainFieldHtml[] = implode(LF, $valuePickerHtml);
$mainFieldHtml[] = '</div>';
$mainFieldHtml[] = '</div>';
$mainFieldHtml[] = '<div class="form-wizards-items-bottom">';
$mainFieldHtml[] = $fieldWizardHtml;
$mainFieldHtml[] = '</div>';
if (!empty($fieldWizardHtml)) {
$mainFieldHtml[] = '<div class="form-wizards-items-bottom">';
$mainFieldHtml[] = $fieldWizardHtml;
$mainFieldHtml[] = '</div>';
}
$mainFieldHtml[] = '</div>';
$mainFieldHtml[] = '</div>';
$mainFieldHtml = implode(LF, $mainFieldHtml);
......
......@@ -198,14 +198,18 @@ class InputDateTimeElement extends AbstractFormElement
$expansionHtml[] = '</span>';
$expansionHtml[] = '</div>';
$expansionHtml[] = '</div>';
$expansionHtml[] = '<div class="form-wizards-items-aside">';
$expansionHtml[] = '<div class="btn-group">';
$expansionHtml[] = $fieldControlHtml;
$expansionHtml[] = '</div>';
$expansionHtml[] = '</div>';
$expansionHtml[] = '<div class="form-wizards-items-bottom">';
$expansionHtml[] = $fieldWizardHtml;
$expansionHtml[] = '</div>';
if (!empty($fieldControlHtml)) {
$expansionHtml[] = '<div class="form-wizards-items-aside">';
$expansionHtml[] = '<div class="btn-group">';
$expansionHtml[] = $fieldControlHtml;
$expansionHtml[] = '</div>';
$expansionHtml[] = '</div>';
}
if (!empty($fieldWizardHtml)) {
$expansionHtml[] = '<div class="form-wizards-items-bottom">';
$expansionHtml[] = $fieldWizardHtml;
$expansionHtml[] = '</div>';
}
$expansionHtml[] = '</div>';
$expansionHtml[] = '</div>';
$expansionHtml = implode(LF, $expansionHtml);
......
......@@ -230,12 +230,14 @@ class InputLinkElement extends AbstractFormElement
$expansionHtml[] = '<input type="hidden" name="' . $parameterArray['itemFormElName'] . '" value="' . htmlspecialchars($itemValue) . '" />';
$expansionHtml[] = '</div>';
$expansionHtml[] = '</div>';
$expansionHtml[] = '<div class="form-wizards-items-aside">';
$expansionHtml[] = '<div class="btn-group">';
$expansionHtml[] = implode(LF, $valuePickerHtml);
$expansionHtml[] = $fieldControlHtml;
$expansionHtml[] = '</div>';
$expansionHtml[] = '</div>';
if (!empty($valuePickerHtml) || !empty($fieldControlHtml)) {
$expansionHtml[] = '<div class="form-wizards-items-aside">';
$expansionHtml[] = '<div class="btn-group">';
$expansionHtml[] = implode(LF, $valuePickerHtml);
$expansionHtml[] = $fieldControlHtml;
$expansionHtml[] = '</div>';
$expansionHtml[] = '</div>';
}
$expansionHtml[] = '<div class="form-wizards-items-bottom">';
$expansionHtml[] = $linkExplanation['additionalAttributes'];
$expansionHtml[] = $fieldWizardHtml;
......
......@@ -244,16 +244,20 @@ class InputTextElement extends AbstractFormElement
$mainFieldHtml[] = '<input type="' . $inputType . '"' . GeneralUtility::implodeAttributes($attributes, true) . ' />';
$mainFieldHtml[] = '<input type="hidden" name="' . $parameterArray['itemFormElName'] . '" value="' . htmlspecialchars($itemValue) . '" />';
$mainFieldHtml[] = '</div>';
$mainFieldHtml[] = '<div class="form-wizards-items-aside">';
$mainFieldHtml[] = '<div class="btn-group">';
$mainFieldHtml[] = implode(LF, $valuePickerHtml);
$mainFieldHtml[] = implode(LF, $valueSliderHtml);
$mainFieldHtml[] = $fieldControlHtml;
$mainFieldHtml[] = '</div>';
$mainFieldHtml[] = '</div>';
$mainFieldHtml[] = '<div class="form-wizards-items-bottom">';
$mainFieldHtml[] = $fieldWizardHtml;
$mainFieldHtml[] = '</div>';
if (!empty($valuePickerHtml) || !empty($valueSliderHtml) || !empty($fieldControlHtml)) {
$mainFieldHtml[] = '<div class="form-wizards-items-aside">';
$mainFieldHtml[] = '<div class="btn-group">';
$mainFieldHtml[] = implode(LF, $valuePickerHtml);
$mainFieldHtml[] = implode(LF, $valueSliderHtml);
$mainFieldHtml[] = $fieldControlHtml;
$mainFieldHtml[] = '</div>';
$mainFieldHtml[] = '</div>';
}
if (!empty($fieldWizardHtml)) {
$mainFieldHtml[] = '<div class="form-wizards-items-bottom">';
$mainFieldHtml[] = $fieldWizardHtml;
$mainFieldHtml[] = '</div>';
}
$mainFieldHtml[] = '</div>';
$mainFieldHtml[] = '</div>';
$mainFieldHtml = implode(LF, $mainFieldHtml);
......
......@@ -101,7 +101,7 @@ class RadioElement extends AbstractFormElement
$html[] = '</label>';
$html[] = '</div>';
}
if (!$disabled) {
if (!$disabled && !empty($fieldWizardHtml)) {
$html[] = '<div class="form-wizards-items-bottom">';
$html[] = $fieldWizardHtml;
$html[] = '</div>';
......
......@@ -242,7 +242,7 @@ class SelectCheckBoxElement extends AbstractFormElement
}
$html[] = '</div>';
if (!$disabled) {
if (!$disabled && !empty($fieldWizardHtml)) {
$html[] = '<div class="form-wizards-items-bottom">';
$html[] = $fieldWizardHtml;
$html[] = '</div>';
......
......@@ -307,19 +307,23 @@ class SelectMultipleSideBySideElement extends AbstractFormElement
$html[] = implode(LF, $selectableItemsHtml);
$html[] = '</select>';
$html[] = '</div>';
$html[] = '<div class="form-wizards-items-aside">';
$html[] = '<div class="btn-group-vertical">';
$html[] = $fieldControlHtml;
$html[] = '</div>';
$html[] = '</div>';
if (!empty($fieldControlHtml)) {
$html[] = '<div class="form-wizards-items-aside">';
$html[] = '<div class="btn-group-vertical">';
$html[] = $fieldControlHtml;
$html[] = '</div>';
$html[] = '</div>';
}
$html[] = '</div>';
$html[] = '</div>';
$html[] = '</div>';
$html[] = '<input type="hidden" name="' . htmlspecialchars($elementName) . '" value="' . htmlspecialchars(implode(',', $listOfSelectedValues)) . '" />';
$html[] = '</div>';
$html[] = '<div class="form-wizards-items-bottom">';
$html[] = $fieldWizardHtml;
$html[] = '</div>';
if (!empty($fieldWizardHtml)) {
$html[] = '<div class="form-wizards-items-bottom">';
$html[] = $fieldWizardHtml;
$html[] = '</div>';
}
$html[] = '</div>';
$html[] = '</div>';
......
......@@ -134,17 +134,20 @@ class SelectSingleBoxElement extends AbstractFormElement
$html[] = $selectElement;
$html[] = '</div>';
if (!$disabled) {
$html[] = '<div class="form-wizards-items-aside">';
$html[] = $fieldControlHtml;
$html[] = '</div>';
$html[] = '</div>';
if (!empty($fieldControlHtml)) {
$html[] = '<div class="form-wizards-items-aside">';
$html[] = $fieldControlHtml;
$html[] = '</div>';
$html[] = '</div>';
}
$html[] = '<p>';
$html[] = '<em>' . htmlspecialchars($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.holdDownCTRL')) . '</em>';
$html[] = '</p>';
$html[] = '<div class="form-wizards-items-bottom">';
$html[] = $fieldWizardHtml;
$html[] = '</div>';
if (!empty($fieldWizardHtml)) {
$html[] = '<div class="form-wizards-items-bottom">';
$html[] = $fieldWizardHtml;
$html[] = '</div>';
}
}
$html[] = '</div>';
$html[] = '</div>';
......
......@@ -228,7 +228,7 @@ class SelectSingleElement extends AbstractFormElement
$html[] = '</div>';
}
$html[] = '</div>';
if (!$disabled) {
if (!$disabled && !empty($fieldWizardHtml)) {
$html[] = '<div class="form-wizards-items-bottom">';
$html[] = $fieldWizardHtml;
$html[] = '</div>';
......
......@@ -167,7 +167,7 @@ class SelectTreeElement extends AbstractFormElement
$html[] = '<div id="' . $treeWrapperId . '" class="svg-tree-wrapper" style="height: ' . $heightInPx . 'px;"></div>';
$html[] = '<script type="text/javascript">var ' . $treeWrapperId . ' = ' . $this->getTreeOnChangeJs() . '</script>';
$html[] = '</div>';
if ($readOnly === 'false') {
if ($readOnly === 'false' && !empty($fieldWizardHtml)) {
$html[] = '<div class="form-wizards-items-bottom">';
$html[] = $fieldWizardHtml;
$html[] = '</div>';
......
......@@ -219,15 +219,19 @@ class TextElement extends AbstractFormElement
$mainFieldHtml[] = '<div class="form-wizards-element">';
$mainFieldHtml[] = '<textarea ' . GeneralUtility::implodeAttributes($attributes, true) . '>' . htmlspecialchars($itemValue) . '</textarea>';
$mainFieldHtml[] = '</div>';
$mainFieldHtml[] = '<div class="form-wizards-items-aside">';
$mainFieldHtml[] = '<div class="btn-group">';
$mainFieldHtml[] = implode(LF, $valuePickerHtml);
$mainFieldHtml[] = $fieldControlHtml;
$mainFieldHtml[] = '</div>';
$mainFieldHtml[] = '</div>';
$mainFieldHtml[] = '<div class="form-wizards-items-bottom">';
$mainFieldHtml[] = $fieldWizardHtml;
$mainFieldHtml[] = '</div>';
if (!empty($valuePickerHtml) || !empty($fieldControlHtml)) {
$mainFieldHtml[] = '<div class="form-wizards-items-aside">';
$mainFieldHtml[] = '<div class="btn-group">';
$mainFieldHtml[] = implode(LF, $valuePickerHtml);
$mainFieldHtml[] = $fieldControlHtml;
$mainFieldHtml[] = '</div>';
$mainFieldHtml[] = '</div>';
}
if (!empty($fieldWizardHtml)) {
$mainFieldHtml[] = '<div class="form-wizards-items-bottom">';
$mainFieldHtml[] = $fieldWizardHtml;
$mainFieldHtml[] = '</div>';
}
$mainFieldHtml[] = '</div>';
$mainFieldHtml[] = '</div>';
$mainFieldHtml = implode(LF, $mainFieldHtml);
......
......@@ -200,14 +200,18 @@ class TextTableElement extends AbstractFormElement
$html[] = '<div class="form-wizards-element">';
$html[] = '<textarea ' . GeneralUtility::implodeAttributes($attributes, true) . '>' . htmlspecialchars($itemValue) . '</textarea>';
$html[] = '</div>';
$html[] = '<div class="form-wizards-items-aside">';
$html[] = '<div class="btn-group">';
$html[] = $fieldControlHtml;
$html[] = '</div>';
$html[] = '</div>';
$html[] = '<div class="form-wizards-items-bottom">';
$html[] = $fieldWizardHtml;
$html[] = '</div>';
if (!empty($fieldControlHtml)) {
$html[] = '<div class="form-wizards-items-aside">';
$html[] = '<div class="btn-group">';
$html[] = $fieldControlHtml;
$html[] = '</div>';
$html[] = '</div>';
}
if (!empty($fieldWizardHtml)) {
$html[] = '<div class="form-wizards-items-bottom">';
$html[] = $fieldWizardHtml;
$html[] = '</div>';
}
$html[] = '</div>';
$html[] = '</div>';
$html[] = '</div>';
......
......@@ -129,9 +129,11 @@ class BackendLayoutWizardElement extends AbstractFormElement
$html[] = '</tr>';
$html[] = '</table>';
$html[] = '</div>';
$html[] = '<div class="form-wizards-items-bottom">';
$html[] = $fieldWizardHtml;
$html[] = '</div>';
if (!empty($fieldWizardHtml)) {
$html[] = '<div class="form-wizards-items-bottom">';
$html[] = $fieldWizardHtml;
$html[] = '</div>';
}
$html[] = '</div>';
$html[] = '</div>';
$html[] = '</div>';
......
......@@ -176,14 +176,18 @@ class RsaInputElement extends AbstractFormElement
$html[] = ' value="' . htmlspecialchars($itemValue) . '"';
$html[] = '/>';
$html[] = '</div>';
$html[] = '<div class="form-wizards-items-aside">';
$html[] = '<div class="btn-group">';
$html[] = $fieldControlHtml;
$html[] = '</div>';
$html[] = '</div>';
$html[] = '<div class="form-wizards-items-bottom">';
$html[] = $fieldWizardHtml;
$html[] = '</div>';
if (!empty($fieldControlHtml)) {
$html[] = '<div class="form-wizards-items-aside">';
$html[] = '<div class="btn-group">';
$html[] = $fieldControlHtml;
$html[] = '</div>';
$html[] = '</div>';
}
if (!empty($fieldWizardHtml)) {
$html[] = '<div class="form-wizards-items-bottom">';
$html[] = $fieldWizardHtml;
$html[] = '</div>';
}
$html[] = '</div>';
$html[] = '</div>';
$html[] = '</div>';
......
......@@ -115,14 +115,18 @@ class RichTextElement extends AbstractFormElement
$html[] = htmlspecialchars($value);
$html[] = '</textarea>';
$html[] = '</div>';
$html[] = '<div class="form-wizards-items-aside">';
$html[] = '<div class="btn-group">';
$html[] = $fieldControlHtml;
$html[] = '</div>';
$html[] = '</div>';
$html[] = '<div class="form-wizards-items-bottom">';
$html[] = $fieldWizardHtml;
$html[] = '</div>';
if (!empty($fieldControlHtml)) {
$html[] = '<div class="form-wizards-items-aside">';
$html[] = '<div class="btn-group">';
$html[] = $fieldControlHtml;
$html[] = '</div>';
$html[] = '</div>';
}
if (!empty($fieldWizardHtml)) {
$html[] = '<div class="form-wizards-items-bottom">';
$html[] = $fieldWizardHtml;
$html[] = '</div>';
}
$html[] = '</div>';
$html[] = '</div>';
$html[] = '</div>';
......
......@@ -159,14 +159,18 @@ class T3editorElement extends AbstractFormElement
$html[] = '<div class="form-wizards-element">';
$html[] = $editorHtml;
$html[] = '</div>';
$html[] = '<div class="form-wizards-items-aside">';
$html[] = '<div class="btn-group">';
$html[] = $fieldControlHtml;
$html[] = '</div>';
$html[] = '</div>';
$html[] = '<div class="form-wizards-items-bottom">';
$html[] = $fieldWizardHtml;
$html[] = '</div>';
if (!empty($fieldControlHtml)) {
$html[] = '<div class="form-wizards-items-aside">';
$html[] = '<div class="btn-group">';
$html[] = $fieldControlHtml;
$html[] = '</div>';
$html[] = '</div>';
}
if (!empty($fieldWizardHtml)) {
$html[] = '<div class="form-wizards-items-bottom">';
$html[] = $fieldWizardHtml;
$html[] = '</div>';
}
$html[] = '</div>';
$html[] = '</div>';
$html[] = '</div>';
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment