From 5d2a1bbb56b80ac99547691af40cb6df769c0134 Mon Sep 17 00:00:00 2001
From: Carsten  Rose <carsten.rose@math.uzh.ch>
Date: Sat, 30 Nov 2019 23:43:21 +0100
Subject: [PATCH] Implements #9666: min-width for extraButtonInfo

---
 Documentation/Manual.rst                            |  9 +++++++--
 extension/Classes/Core/Constants.php                |  2 ++
 extension/Classes/Core/Helper/HelperFormElement.php | 12 ++++++++----
 extension/Classes/Core/QuickFormQuery.php           |  1 +
 4 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/Documentation/Manual.rst b/Documentation/Manual.rst
index 7499486bf..33698a687 100644
--- a/Documentation/Manual.rst
+++ b/Documentation/Manual.rst
@@ -2600,6 +2600,8 @@ Parameter
 +-----------------------------+--------+----------------------------------------------------------------------------------------------------------+
 | extraButtonInfoClass        | string | Overwrite default from configuration_                                                                    |
 +-----------------------------+--------+----------------------------------------------------------------------------------------------------------+
+| extraButtonInfoMinWidth     | string | See extraButtonInfo_                                                                                     |
++-----------------------------+--------+----------------------------------------------------------------------------------------------------------+
 | fillStoreVar                | string | Fill the STORE_VAR with custom values. See `STORE_VARS`_.                                                |
 +-----------------------------+--------+----------------------------------------------------------------------------------------------------------+
 | showIdInFormTitle           | string | Overwrite default from configuration_                                                                    |
@@ -3086,6 +3088,8 @@ See also at specific *FormElement* definitions.
 +------------------------+--------+----------------------------------------------------------------------------------------------------------+
 | extraButtonInfoClass   | string | By default empty. Specify any class to be assigned to wrap extraButtonInfo                               |
 +------------------------+--------+----------------------------------------------------------------------------------------------------------+
+| extraButtonInfoMinWidth| string | See `extraButtonInfo`_                                                                                   |
++------------------------+--------+----------------------------------------------------------------------------------------------------------+
 | editor-plugins,        | string | See `input-editor`_                                                                                      |
 | editor-toolbar,        |        |                                                                                                          |
 | editor-statusbar,      |        |                                                                                                          |
@@ -3146,9 +3150,9 @@ See also at specific *FormElement* definitions.
 +------------------------+--------+----------------------------------------------------------------------------------------------------------+
 | dataReference          | string | Optional. See `applicationTest`_                                                                         |
 +------------------------+--------+----------------------------------------------------------------------------------------------------------+
-| requiredPosition       | int    | See requiredPosition_ .                                                                                  |
+| requiredPosition       | int    | See `requiredPosition`_.                                                                                 |
 +------------------------+--------+----------------------------------------------------------------------------------------------------------+
-| minWidth               | int    | See checkboxRadioMinWidth .                                                                              |
+| minWidth               | int    | See `checkboxRadioMinWidth`_.                                                                            |
 +------------------------+--------+----------------------------------------------------------------------------------------------------------+
 
 
@@ -3215,6 +3219,7 @@ extraButtonInfo
 
   * `below`: below the FormElement for all types.
 
+* `extraButtonInfoMinWidth`: default is 250 and defines a minimal width.
 * For `FormElement` with mode `below`, a `span` element with the given class in `extraButtonInfoClass` (FE, F, configuration_)
   will be applied. E.g. this might be `pull-right` to align the `info` button/icon on the right side below the input element.
 
diff --git a/extension/Classes/Core/Constants.php b/extension/Classes/Core/Constants.php
index 030de75af..6bcad4407 100644
--- a/extension/Classes/Core/Constants.php
+++ b/extension/Classes/Core/Constants.php
@@ -1246,6 +1246,8 @@ const FE_INPUT_EXTRA_BUTTON_LOCK = 'extraButtonLock';
 const FE_INPUT_EXTRA_BUTTON_PASSWORD = 'extraButtonPassword';
 const FE_INPUT_EXTRA_BUTTON_INFO = 'extraButtonInfo';
 const FE_INPUT_EXTRA_BUTTON_INFO_CLASS = SYSTEM_EXTRA_BUTTON_INFO_CLASS;
+const FE_INPUT_EXTRA_BUTTON_INFO_MIN_WIDTH = 'extraButtonMinWidth';
+const FE_INPUT_EXTRA_BUTTON_INFO_MIN_WIDTH_DEFAULT = '250';
 const FE_INPUT_AUTOCOMPLETE = 'autocomplete';
 const FE_TMP_EXTRA_BUTTON_HTML = '_extraButtonHtml'; // will be filled on the fly during building extrabutton
 const FE_CHECKBOX_CHECKED = 'checked';
diff --git a/extension/Classes/Core/Helper/HelperFormElement.php b/extension/Classes/Core/Helper/HelperFormElement.php
index 36dc4220e..ea636054a 100644
--- a/extension/Classes/Core/Helper/HelperFormElement.php
+++ b/extension/Classes/Core/Helper/HelperFormElement.php
@@ -291,6 +291,7 @@ class HelperFormElement {
             }
             Support::setIfNotSet($feSpecNative[$key], F_FE_REQUIRED_POSITION, $formSpec[F_FE_REQUIRED_POSITION]);
             Support::setIfNotSet($feSpecNative[$key], F_FE_MIN_WIDTH, $formSpec[F_FE_MIN_WIDTH]);
+            Support::setIfNotSet($feSpecNative[$key], FE_INPUT_EXTRA_BUTTON_INFO_MIN_WIDTH, $formSpec[FE_INPUT_EXTRA_BUTTON_INFO_MIN_WIDTH]);
         }
 
         return $feSpecNative;
@@ -377,8 +378,11 @@ class HelperFormElement {
         }
 
         $formElement[FE_TMP_EXTRA_BUTTON_HTML] = '';
+        $minWidth = $formElement[FE_INPUT_EXTRA_BUTTON_INFO_MIN_WIDTH] ?? '';
+        $minWidth .= 'px';
 
-        // INFO: $showinline =- TRUE ('input' elemente)
+
+        // INFO: $showinline =- TRUE ('input' elements)
         if (isset($formElement[FE_INPUT_EXTRA_BUTTON_INFO]) && $showInline) {
             $extraButton .= <<<EOF
             <button type="button" class="btn btn-info" onclick="$('#$id-extra-info').slideToggle('swing')">
@@ -388,7 +392,7 @@ EOF;
 
             $value = $formElement[FE_INPUT_EXTRA_BUTTON_INFO];
             $formElement[FE_INPUT_EXTRA_BUTTON_INFO] = <<<EOF
-            <div class="alert alert-info" id="$id-extra-info" style="display: none;">
+            <div class="alert alert-info" id="$id-extra-info" style="display: none; min-width: $minWidth;">
                 <p>$value</p>
             </div>
 EOF;
@@ -400,7 +404,7 @@ EOF;
         $arr = explode(' ', $infoSymbolOutside, 2);
         $infoSymbolOutside = $arr[0] . $js . $arr[1];
 
-        // INFO: $showinline == FALSE (e.g. 'textarea' elemente)
+        // INFO: $showinline == FALSE (e.g. 'textarea' elements)
         if (isset($formElement[FE_INPUT_EXTRA_BUTTON_INFO]) && !$showInline) {
             $class = $formElement[FE_INPUT_EXTRA_BUTTON_INFO_CLASS];
             $extraButton .= <<<EOF
@@ -409,7 +413,7 @@ EOF;
 
             $value = $formElement[FE_INPUT_EXTRA_BUTTON_INFO];
             $formElement[FE_INPUT_EXTRA_BUTTON_INFO] = <<<EOF
-            <div class="alert alert-info" id="$id-extra-info" style="display: none;">
+            <div class="alert alert-info" id="$id-extra-info" style="display: none; min-width: $minWidth;">
                 <p>$value</p>
             </div>
 EOF;
diff --git a/extension/Classes/Core/QuickFormQuery.php b/extension/Classes/Core/QuickFormQuery.php
index 4cb97acf1..712c93377 100644
--- a/extension/Classes/Core/QuickFormQuery.php
+++ b/extension/Classes/Core/QuickFormQuery.php
@@ -1441,6 +1441,7 @@ class QuickFormQuery {
         Support::setIfNotSet($formSpec, F_FE_REQUIRED_POSITION, F_FE_REQUIRED_POSITION_LABEL_RIGHT);
         Support::setIfNotSet($formSpec, F_MULTI_MSG_NO_RECORD, F_MULTI_MSG_NO_RECORD_TEXT);
         Support::setIfNotSet($formSpec, F_FE_MIN_WIDTH, F_FE_MIN_WIDTH_DEFAULT);
+        Support::setIfNotSet($formSpec, FE_INPUT_EXTRA_BUTTON_INFO_MIN_WIDTH, FE_INPUT_EXTRA_BUTTON_INFO_MIN_WIDTH_DEFAULT);
 
         // In case there is no F_MODE defined on the form, check if there is one in STORE_SIP.
         if ($formSpec[F_MODE] == '') {
-- 
GitLab