Commit b5510306 authored by Carsten  Rose's avatar Carsten Rose
Browse files

#3773 / Button: Info / Unlock / ShowPassword

FE_PARAMETER: extraButtonLock / extraButtonPassword:
parent 42514380
......@@ -841,6 +841,7 @@ abstract class AbstractBuildForm {
$attribute = '';
$class = 'form-control';
$elementCharacterCount = '';
$extraButton = '';
$typeAheadUrlParam = $this->typeAheadBuildParam($formElement);
if ($typeAheadUrlParam != '') {
......@@ -902,8 +903,8 @@ abstract class AbstractBuildForm {
$textarea = htmlentities($value) . '</textarea>';
} else {
$formElement = $this->inputExtraButton($formElement, $extraButton);
$htmlTag = '<input';
$attribute .= $this->getAttributeList($formElement, ['type', 'size']);
$attribute .= Support::doAttribute('value', htmlentities($value), false);
}
......@@ -914,14 +915,73 @@ abstract class AbstractBuildForm {
$attribute .= Support::doAttribute('title', $formElement['tooltip']);
$attribute .= $this->getInputCheckPattern($formElement[FE_CHECK_TYPE], $formElement[FE_CHECK_PATTERN]);
$attribute .= $this->getAttributeFeMode($formElement[FE_MODE]);
$attribute .= $this->getAttributeFeMode($formElement[FE_MODE], false);
$json = $this->getFormElementForJson($htmlFormElementName, $value, $formElement);
return "$htmlTag $attribute>$textarea" . $elementCharacterCount . $this->getHelpBlock();
$input = "$htmlTag $attribute>$textarea";
if ($extraButton !== '') {
$input = Support::wrapTag('<div class="input-group">', $input . $extraButton);
}
return $input . $elementCharacterCount . $this->getHelpBlock();
}
/**
* @param array $formElement
* @param $rcExtraButton
* @return array
*/
private function inputExtraButton(array $formElement, &$rcExtraButton) {
if (!($formElement[FE_MODE] == FE_MODE_SHOW || $formElement[FE_MODE] == FE_MODE_REQUIRED)) {
return $formElement;
}
$rcExtraButton = '';
$id = $formElement[FE_HTML_ID];
// LOCK
if (isset($formElement[FE_INPUT_EXTRA_BUTTON_LOCK])) {
$formElement[FE_MODE] = FE_MODE_READONLY;
$rcExtraButton .= <<<EOF
<div class="input-group-btn">
<button class="btn btn-success"
onclick="$('#$id').prop('readonly',!$('#$id').prop('readonly'))">
<span class="glyphicon glyphicon-lock" aria-hidden="true"></span>
</button>
</div>
EOF;
}
// PASSWORD
if (isset($formElement[FE_INPUT_EXTRA_BUTTON_PASSWORD])) {
$formElement[FE_TYPE] = 'password';
$rcExtraButton .= <<<EOF
<div class="input-group-btn">
<button class="btn btn-info"
onclick="$('#$id').attr('type',$('#$id').attr('type')==='password' ? 'text': 'password')">
<span class="glyphicon glyphicon-eye-close" aria-hidden="true"></span>
</button>
</div>
EOF;
}
// INFO
if (isset($formElement[FE_INPUT_EXTRA_BUTTON_INFO])) {
}
return $formElement;
}
/**
* Check $formElement for FE_TYPE_AHEAD_SQL or FE_TYPE_AHEAD_LDAP_SERVER.
* If one of them is given: build $urlParam with typeAhead Params.
......@@ -1186,7 +1246,7 @@ abstract class AbstractBuildForm {
* @return string
* @throws UserFormException
*/
private function getAttributeFeMode($feMode) {
private function getAttributeFeMode($feMode, $cssDisable = true) {
$attribute = '';
$this->getFeMode($feMode, $hidden, $disabled, $required);
......@@ -1206,7 +1266,9 @@ abstract class AbstractBuildForm {
// Attributes: data-...
$attribute .= Support::doAttribute(DATA_HIDDEN, $hidden);
$attribute .= Support::doAttribute(DATA_DISABLED, $disabled);
if ($cssDisable) {
$attribute .= Support::doAttribute(DATA_DISABLED, $disabled);
}
$attribute .= Support::doAttribute(DATA_REQUIRED, $required);
return $attribute;
......
......@@ -692,7 +692,6 @@ const FE_PARAMETER = 'parameter';
const FE_ENCODE = 'encode';
const FE_CHECK_TYPE = 'checkType';
const FE_CHECK_PATTERN = 'checkPattern';
const FE_TYPE_CHECKBOX = 'checkbox';
// FormElement columns: via parameter field
......@@ -765,6 +764,10 @@ const FE_TYPEAHEAD_LDAP_SEARCH_PREFETCH = F_TYPEAHEAD_LDAP_SEARCH_PREFETCH;
const FE_TYPEAHEAD_LDAP_SEARCH_PER_TOKEN = F_TYPEAHEAD_LDAP_SEARCH_PER_TOKEN;
const FE_FILL_STORE_LDAP = 'fillStoreLdap';
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 RETYPE_FE_NAME_EXTENSION = 'RETYPE';
const TYPEAHEAD_PLACEHOLDER = '?';
......
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