Commit 0f11338b authored by Carsten  Rose's avatar Carsten Rose
Browse files

#3773 / Button: Info / Unlock / ShowPassword

Implemented: date,time,datetime,editor,radio,select,upload
parent b729443d
......@@ -841,7 +841,6 @@ abstract class AbstractBuildForm {
$attribute = '';
$class = 'form-control';
$elementCharacterCount = '';
$extraButton = '';
$typeAheadUrlParam = $this->typeAheadBuildParam($formElement);
if ($typeAheadUrlParam != '') {
......@@ -896,7 +895,8 @@ abstract class AbstractBuildForm {
$colsRows = explode(',', $formElement['size'], 2);
$flagTextarea = (count($colsRows) === 2);
$formElement = HelperFormElement::prepareExtraButton($formElement, !$flagTextarea, $extraButton);
// $formElement = HelperFormElement::prepareExtraButton($formElement, !$flagTextarea, $extraButton);
$formElement = HelperFormElement::prepareExtraButton($formElement, !$flagTextarea);
if ($flagTextarea) {
// <textarea>
$htmlTag = '<textarea';
......@@ -922,12 +922,12 @@ abstract class AbstractBuildForm {
$input = "$htmlTag $attribute>$textarea" . $this->getHelpBlock();
if ($extraButton !== '') {
if ($formElement[FE_TMP_EXTRA_BUTTON_HTML] !== '') {
if ($flagTextarea) {
$input .= $extraButton;
$input .= $formElement[FE_TMP_EXTRA_BUTTON_HTML];
} else {
$input = Support::wrapTag('<div class="input-group">', $input . $extraButton);
$input = Support::wrapTag('<div class="input-group">', $input . $formElement[FE_TMP_EXTRA_BUTTON_HTML]);
}
}
......@@ -1295,7 +1295,9 @@ abstract class AbstractBuildForm {
throw new UserFormException('checkBoxMode: \'' . $formElement['checkBoxMode'] . '\' is unknown.', ERROR_CHECKBOXMODE_UNKNOWN);
}
return $html . $this->getHelpBlock() . HelperFormElement::buildExtraButton($formElement);
$formElement = HelperFormElement::prepareExtraButton($formElement, false);
return $html . $formElement[FE_TMP_EXTRA_BUTTON_HTML] . $this->getHelpBlock() . $formElement[FE_INPUT_EXTRA_BUTTON_INFO];
}
/**
......@@ -1844,7 +1846,10 @@ abstract class AbstractBuildForm {
$html = $this->constructRadioPlain($formElement, $htmlFormElementName, $value, $json, $mode);
}
return $html . $this->getHelpBlock() . HelperFormElement::buildExtraButton($formElement);
$formElement = HelperFormElement::prepareExtraButton($formElement, false);
return $html . $formElement[FE_TMP_EXTRA_BUTTON_HTML] . $this->getHelpBlock() . $formElement[FE_INPUT_EXTRA_BUTTON_INFO];
}
/**
......@@ -2078,7 +2083,11 @@ abstract class AbstractBuildForm {
$json = $this->getFormElementForJson($htmlFormElementName, $jsonValues, $formElement);
return '<select ' . $attribute . '>' . $option . '</select>' . $this->getHelpBlock() . HelperFormElement::buildExtraButton($formElement);
$html = '<select ' . $attribute . '>' . $option . '</select>';
$formElement = HelperFormElement::prepareExtraButton($formElement, false);
$html = $html . $this->getHelpBlock() . $formElement[FE_TMP_EXTRA_BUTTON_HTML];
return $html . $formElement[FE_INPUT_EXTRA_BUTTON_INFO];
}
/**
......@@ -2565,7 +2574,9 @@ abstract class AbstractBuildForm {
$json = $this->getFormElementForJson($htmlFormElementName, $value, $formElement);
return $htmlTextDelete . $htmlInputFile . $hiddenSipUpload;
$formElement = HelperFormElement::prepareExtraButton($formElement, false);
return $htmlTextDelete . $htmlInputFile . $hiddenSipUpload . $formElement[FE_TMP_EXTRA_BUTTON_HTML] . $formElement[FE_INPUT_EXTRA_BUTTON_INFO];
}
/**
......@@ -2671,7 +2682,10 @@ abstract class AbstractBuildForm {
$json = $this->getFormElementForJson($htmlFormElementName, $value, $formElement);
return "<input $attribute>" . $this->getHelpBlock();
$formElement = HelperFormElement::prepareExtraButton($formElement, true);
$input = Support::wrapTag('<div class="input-group">', "<input $attribute>" . $this->getHelpBlock() . $formElement[FE_TMP_EXTRA_BUTTON_HTML]);
return $input . $formElement[FE_INPUT_EXTRA_BUTTON_INFO];
}
......@@ -2803,9 +2817,10 @@ abstract class AbstractBuildForm {
$json = $this->getFormElementForJson($htmlFormElementName, $value, $formElement);
$element = Support::wrapTag("<textarea $attribute>", htmlentities($value), false);
$html = Support::wrapTag("<textarea $attribute>", htmlentities($value), false);
$formElement = HelperFormElement::prepareExtraButton($formElement, false);
return $element . $this->getHelpBlock() . HelperFormElement::buildExtraButton($formElement);
return $html . $this->getHelpBlock() . $formElement[FE_TMP_EXTRA_BUTTON_HTML] . $formElement[FE_INPUT_EXTRA_BUTTON_INFO];
}
/**
......
......@@ -766,6 +766,7 @@ const FE_CHARACTER_COUNT_WRAP = 'characterCountWrap';
const FE_INPUT_EXTRA_BUTTON_LOCK = 'extraButtonLock';
const FE_INPUT_EXTRA_BUTTON_PASSWORD = 'extraButtonPassword';
const FE_INPUT_EXTRA_BUTTON_INFO = 'extraButtonInfo';
const FE_TMP_EXTRA_BUTTON_HTML = '_extraButtonHtml'; // will be filled on the fly during building extrabutton
const RETYPE_FE_NAME_EXTENSION = 'RETYPE';
......
......@@ -199,33 +199,6 @@ class HelperFormElement {
return $fe;
}
/**
* @param array $formElement
* @return string
* @throws CodeException
*/
public static function buildExtraButton(array $formElement) {
$inline = true;
switch ($formElement[FE_TYPE]) {
case FE_TYPE_CHECKBOX:
case FE_TYPE_EDITOR:
case FE_TYPE_RADIO:
case FE_TYPE_UPLOAD:
$inline = false;
break;
default:
return '';
}
$extraButton = '';
$formElement = self::prepareExtraButton($formElement, $inline, $extraButton);
$info = isset($formElement[FE_INPUT_EXTRA_BUTTON_INFO]) ? $formElement[FE_INPUT_EXTRA_BUTTON_INFO] : '';
return $extraButton . $info;
}
/**
* Prepare code of 'lock', 'password', 'info' to extend a FormElement.
* The 'info' will always be added, 'lock' and 'password' only on FE with mode=show|required
......@@ -241,17 +214,17 @@ class HelperFormElement {
*
* @param array $formElement
* @param bool $showInline
* @param string $rcExtraButton
* @return array
*/
public static function prepareExtraButton(array $formElement, $showInline, &$rcExtraButton) {
public static function prepareExtraButton(array $formElement, $showInline) {
$rcExtraButton = '';
$extraButton = '';
$id = $formElement[FE_HTML_ID];
$formElement[FE_TMP_EXTRA_BUTTON_HTML] = '';
// INFO: $showinline =- TRUE ('input' elemente)
if (isset($formElement[FE_INPUT_EXTRA_BUTTON_INFO]) && $showInline) {
$rcExtraButton .= <<<EOF
$extraButton .= <<<EOF
<div class="input-group-btn">
<button class="btn btn-info" onclick="$('#$id-extra-info').slideToggle('swing')">
<span class="glyphicon glyphicon-info-sign" aria-hidden="true"></span>
......@@ -269,7 +242,7 @@ EOF;
// INFO: $showinline == FALSE (z.B. 'textarea' elemente)
if (isset($formElement[FE_INPUT_EXTRA_BUTTON_INFO]) && !$showInline) {
$rcExtraButton .= <<<EOF
$extraButton .= <<<EOF
<span class="glyphicon glyphicon-info-sign text-info" aria-hidden="true" onclick="$('#$id-extra-info').slideToggle('swing')"></span>
EOF;
......@@ -281,18 +254,14 @@ EOF;
EOF;
}
// Check if remaining 'lock' and 'password' buttons appliable
if (!($formElement[FE_MODE] == FE_MODE_SHOW || $formElement[FE_MODE] == FE_MODE_REQUIRED)) {
return $formElement;
}
$skip = (!($formElement[FE_MODE] == FE_MODE_SHOW || $formElement[FE_MODE] == FE_MODE_REQUIRED));
// LOCK
if (isset($formElement[FE_INPUT_EXTRA_BUTTON_LOCK])) {
if (!$skip && isset($formElement[FE_INPUT_EXTRA_BUTTON_LOCK])) {
$formElement[FE_MODE] = FE_MODE_READONLY;
$rcExtraButton .= <<<EOF
$extraButton .= <<<EOF
<div class="input-group-btn">
<button class="btn btn-info"
onclick="$('#$id').prop('readonly',!$('#$id').prop('readonly'))">
......@@ -303,11 +272,11 @@ EOF;
}
// PASSWORD
if (isset($formElement[FE_INPUT_EXTRA_BUTTON_PASSWORD])) {
if (!$skip && isset($formElement[FE_INPUT_EXTRA_BUTTON_PASSWORD])) {
$formElement[FE_TYPE] = 'password';
$rcExtraButton .= <<<EOF
$extraButton .= <<<EOF
<div class="input-group-btn">
<button class="btn btn-info"
onclick="$('#$id').attr('type',$('#$id').attr('type')==='password' ? 'text': 'password')">
......@@ -317,6 +286,9 @@ EOF;
EOF;
}
$formElement[FE_TMP_EXTRA_BUTTON_HTML] = $extraButton;
Support::setIfNotSet($formElement, FE_INPUT_EXTRA_BUTTON_INFO);
return $formElement;
}
......
Markdown is supported
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