mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
N°3750 New data-input-typeattribute to fields container
This will allow easiest DOM manipulation in BeHat tests !
This commit is contained in:
@@ -80,6 +80,35 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay
|
|||||||
public const ENUM_OBJECT_MODE_STIMULUS = 'stimulus';
|
public const ENUM_OBJECT_MODE_STIMULUS = 'stimulus';
|
||||||
/** @var string ENUM_OBJECT_MODE_PRINT */
|
/** @var string ENUM_OBJECT_MODE_PRINT */
|
||||||
public const ENUM_OBJECT_MODE_PRINT = 'print';
|
public const ENUM_OBJECT_MODE_PRINT = 'print';
|
||||||
|
|
||||||
|
// N°3750 rendering used
|
||||||
|
/** @var string */
|
||||||
|
public const ENUM_INPUT_TYPE_SINGLE_INPUT = 'single_input';
|
||||||
|
/** @var string */
|
||||||
|
public const ENUM_INPUT_TYPE_MULTIPLE_INPUTS = 'multiple_inputs';
|
||||||
|
/** @var string */
|
||||||
|
public const ENUM_INPUT_TYPE_TEXTAREA = 'textarea';
|
||||||
|
/** @var string */
|
||||||
|
public const ENUM_INPUT_TYPE_HTML_EDITOR = 'html_editor';
|
||||||
|
/** @var string */
|
||||||
|
public const ENUM_INPUT_TYPE_DOCUMENT = 'document';
|
||||||
|
/** @var string */
|
||||||
|
public const ENUM_INPUT_TYPE_IMAGE = 'image';
|
||||||
|
/** @var string */
|
||||||
|
public const ENUM_INPUT_TYPE_PASSWORD = 'password';
|
||||||
|
/** @var string */
|
||||||
|
public const ENUM_INPUT_TYPE_TAGSET = 'tagset';
|
||||||
|
/** @var string */
|
||||||
|
public const ENUM_INPUT_TYPE_RADIO = 'radio';
|
||||||
|
/** @var string */
|
||||||
|
public const ENUM_INPUT_TYPE_DROPDOWN_RAW = 'dropdown_raw';
|
||||||
|
/** @var string */
|
||||||
|
public const ENUM_INPUT_TYPE_DROPDOWN_DECORATED = 'dropdown_decorated'; // now with the JQuery Selectize plugin
|
||||||
|
/** @var string */
|
||||||
|
public const ENUM_INPUT_TYPE_DROPDOWN_MULTIPLE_CHOICES = 'dropdown_multiple_choices';
|
||||||
|
/** @var string */
|
||||||
|
public const ENUM_INPUT_TYPE_AUTOCOMPLETE = 'autocomplete';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string DEFAULT_OBJECT_MODE
|
* @var string DEFAULT_OBJECT_MODE
|
||||||
* @since 3.0.0
|
* @since 3.0.0
|
||||||
@@ -854,6 +883,7 @@ EOF
|
|||||||
if ((!$oAttDef->IsLinkSet()) && (($iFlags & OPT_ATT_HIDDEN) == 0) && !($oAttDef instanceof AttributeDashboard)) {
|
if ((!$oAttDef->IsLinkSet()) && (($iFlags & OPT_ATT_HIDDEN) == 0) && !($oAttDef instanceof AttributeDashboard)) {
|
||||||
$sInputId = $this->m_iFormId.'_'.$sAttCode;
|
$sInputId = $this->m_iFormId.'_'.$sAttCode;
|
||||||
if ($oAttDef->IsWritable()) {
|
if ($oAttDef->IsWritable()) {
|
||||||
|
$sInputType = '';
|
||||||
if (($sStateAttCode === $sAttCode) && (MetaModel::HasLifecycle($sClass))) {
|
if (($sStateAttCode === $sAttCode) && (MetaModel::HasLifecycle($sClass))) {
|
||||||
// State attribute is always read-only from the UI
|
// State attribute is always read-only from the UI
|
||||||
$sHTMLValue = $this->GetAsHTML($sAttCode);
|
$sHTMLValue = $this->GetAsHTML($sAttCode);
|
||||||
@@ -887,15 +917,15 @@ EOF
|
|||||||
|
|
||||||
// Attribute is read-only
|
// Attribute is read-only
|
||||||
$sHTMLValue = "<span id=\"field_{$sInputId}\">".$this->GetAsHTML($sAttCode).'</span>';
|
$sHTMLValue = "<span id=\"field_{$sInputId}\">".$this->GetAsHTML($sAttCode).'</span>';
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$sValue = $this->Get($sAttCode);
|
$sValue = $this->Get($sAttCode);
|
||||||
$sDisplayValue = $this->GetEditValue($sAttCode);
|
$sDisplayValue = $this->GetEditValue($sAttCode);
|
||||||
$aArgs = array('this' => $this, 'formPrefix' => $sPrefix);
|
$aArgs = array('this' => $this, 'formPrefix' => $sPrefix);
|
||||||
$sHTMLValue = "".self::GetFormElementForField($oPage, $sClass, $sAttCode,
|
$sHTMLValue = "".self::GetFormElementForField(
|
||||||
$oAttDef, $sValue, $sDisplayValue, $sInputId, '', $iFlags,
|
$oPage, $sClass, $sAttCode, $oAttDef, $sValue,
|
||||||
$aArgs).'';
|
$sDisplayValue, $sInputId, '', $iFlags, $aArgs,
|
||||||
|
true, $sInputType
|
||||||
|
).'';
|
||||||
}
|
}
|
||||||
$aFieldsMap[$sAttCode] = $sInputId;
|
$aFieldsMap[$sAttCode] = $sInputId;
|
||||||
|
|
||||||
@@ -908,6 +938,7 @@ EOF
|
|||||||
'label' => '<span '.$sDescriptionHTMLTag.' >'.$oAttDef->GetLabel().'</span>',
|
'label' => '<span '.$sDescriptionHTMLTag.' >'.$oAttDef->GetLabel().'</span>',
|
||||||
'value' => $sHTMLValue,
|
'value' => $sHTMLValue,
|
||||||
'input_id' => $sInputId,
|
'input_id' => $sInputId,
|
||||||
|
'input_type' => $sInputType,
|
||||||
'comments' => $sComments,
|
'comments' => $sComments,
|
||||||
'infos' => $sInfos,
|
'infos' => $sInfos,
|
||||||
);
|
);
|
||||||
@@ -1748,6 +1779,7 @@ HTML
|
|||||||
return $oSearchForm->GetSearchForm($oPage, $oSet, $aExtraParams);
|
return $oSearchForm->GetSearchForm($oPage, $oSet, $aExtraParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param \WebPage $oPage
|
* @param \WebPage $oPage
|
||||||
* @param string $sClass
|
* @param string $sClass
|
||||||
@@ -1760,38 +1792,43 @@ HTML
|
|||||||
* @param int $iFlags
|
* @param int $iFlags
|
||||||
* @param array $aArgs
|
* @param array $aArgs
|
||||||
* @param bool $bPreserveCurrentValue Preserve the current value even if not allowed
|
* @param bool $bPreserveCurrentValue Preserve the current value even if not allowed
|
||||||
|
* @param string $sInputType type of rendering used, see ENUM_INPUT_TYPE_* const
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
|
*
|
||||||
* @throws \ArchivedObjectException
|
* @throws \ArchivedObjectException
|
||||||
|
* @throws \ConfigException
|
||||||
* @throws \CoreException
|
* @throws \CoreException
|
||||||
|
* @throws \CoreUnexpectedValue
|
||||||
* @throws \DictExceptionMissingString
|
* @throws \DictExceptionMissingString
|
||||||
|
* @throws \MySQLException
|
||||||
|
* @throws \OQLException
|
||||||
|
* @throws \ReflectionException
|
||||||
|
* @throws \Twig\Error\LoaderError
|
||||||
|
* @throws \Twig\Error\RuntimeError
|
||||||
|
* @throws \Twig\Error\SyntaxError
|
||||||
*/
|
*/
|
||||||
public static function GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $value = '', $sDisplayValue = '', $iId = '', $sNameSuffix = '', $iFlags = 0, $aArgs = array(), $bPreserveCurrentValue = true)
|
public static function GetFormElementForField($oPage, $sClass, $sAttCode, $oAttDef, $value = '', $sDisplayValue = '', $iId = '', $sNameSuffix = '', $iFlags = 0, $aArgs = array(), $bPreserveCurrentValue = true, &$sInputType = '')
|
||||||
{
|
{
|
||||||
$sFormPrefix = isset($aArgs['formPrefix']) ? $aArgs['formPrefix'] : '';
|
$sFormPrefix = isset($aArgs['formPrefix']) ? $aArgs['formPrefix'] : '';
|
||||||
$sFieldPrefix = isset($aArgs['prefix']) ? $sFormPrefix.$aArgs['prefix'] : $sFormPrefix;
|
$sFieldPrefix = isset($aArgs['prefix']) ? $sFormPrefix.$aArgs['prefix'] : $sFormPrefix;
|
||||||
if ($sDisplayValue == '')
|
if ($sDisplayValue == '') {
|
||||||
{
|
|
||||||
$sDisplayValue = $value;
|
$sDisplayValue = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($aArgs[$sAttCode]) && empty($value))
|
if (isset($aArgs[$sAttCode]) && empty($value)) {
|
||||||
{
|
|
||||||
// default value passed by the context (either the app context of the operation)
|
// default value passed by the context (either the app context of the operation)
|
||||||
$value = $aArgs[$sAttCode];
|
$value = $aArgs[$sAttCode];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($iId))
|
if (!empty($iId)) {
|
||||||
{
|
|
||||||
$iInputId = $iId;
|
$iInputId = $iId;
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$iInputId = utils::GetUniqueId();
|
$iInputId = utils::GetUniqueId();
|
||||||
}
|
}
|
||||||
|
|
||||||
$sHTMLValue = '';
|
$sHTMLValue = '';
|
||||||
if (!$oAttDef->IsExternalField())
|
if (!$oAttDef->IsExternalField()) {
|
||||||
{
|
|
||||||
$bMandatory = 'false';
|
$bMandatory = 'false';
|
||||||
if ((!$oAttDef->IsNullAllowed()) || ($iFlags & OPT_ATT_MANDATORY)) {
|
if ((!$oAttDef->IsNullAllowed()) || ($iFlags & OPT_ATT_MANDATORY)) {
|
||||||
$bMandatory = 'true';
|
$bMandatory = 'true';
|
||||||
@@ -1813,6 +1850,7 @@ HTML
|
|||||||
switch ($oAttDef->GetEditClass())
|
switch ($oAttDef->GetEditClass())
|
||||||
{
|
{
|
||||||
case 'Date':
|
case 'Date':
|
||||||
|
$sInputType = self::ENUM_INPUT_TYPE_SINGLE_INPUT;
|
||||||
$aEventsList[] = 'validate';
|
$aEventsList[] = 'validate';
|
||||||
$aEventsList[] = 'keyup';
|
$aEventsList[] = 'keyup';
|
||||||
$aEventsList[] = 'change';
|
$aEventsList[] = 'change';
|
||||||
@@ -1824,6 +1862,7 @@ HTML
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'DateTime':
|
case 'DateTime':
|
||||||
|
$sInputType = self::ENUM_INPUT_TYPE_SINGLE_INPUT;
|
||||||
$aEventsList[] = 'validate';
|
$aEventsList[] = 'validate';
|
||||||
$aEventsList[] = 'keyup';
|
$aEventsList[] = 'keyup';
|
||||||
$aEventsList[] = 'change';
|
$aEventsList[] = 'change';
|
||||||
@@ -1835,6 +1874,7 @@ HTML
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'Duration':
|
case 'Duration':
|
||||||
|
$sInputType = self::ENUM_INPUT_TYPE_MULTIPLE_INPUTS;
|
||||||
$aEventsList[] = 'validate';
|
$aEventsList[] = 'validate';
|
||||||
$aEventsList[] = 'change';
|
$aEventsList[] = 'change';
|
||||||
$oPage->add_ready_script("$('#{$iId}_d').bind('keyup change', function(evt, sFormId) { return UpdateDuration('$iId'); });");
|
$oPage->add_ready_script("$('#{$iId}_d').bind('keyup change', function(evt, sFormId) { return UpdateDuration('$iId'); });");
|
||||||
@@ -1854,6 +1894,7 @@ HTML
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'Password':
|
case 'Password':
|
||||||
|
$sInputType = self::ENUM_INPUT_TYPE_PASSWORD;
|
||||||
$aEventsList[] = 'validate';
|
$aEventsList[] = 'validate';
|
||||||
$aEventsList[] = 'keyup';
|
$aEventsList[] = 'keyup';
|
||||||
$aEventsList[] = 'change';
|
$aEventsList[] = 'change';
|
||||||
@@ -1863,6 +1904,7 @@ HTML
|
|||||||
|
|
||||||
case 'OQLExpression':
|
case 'OQLExpression':
|
||||||
case 'Text':
|
case 'Text':
|
||||||
|
$sInputType = self::ENUM_INPUT_TYPE_TEXTAREA;
|
||||||
$aEventsList[] = 'validate';
|
$aEventsList[] = 'validate';
|
||||||
$aEventsList[] = 'keyup';
|
$aEventsList[] = 'keyup';
|
||||||
$aEventsList[] = 'change';
|
$aEventsList[] = 'change';
|
||||||
@@ -1871,22 +1913,19 @@ HTML
|
|||||||
$aStyles = array();
|
$aStyles = array();
|
||||||
$sStyle = '';
|
$sStyle = '';
|
||||||
$sWidth = $oAttDef->GetWidth();
|
$sWidth = $oAttDef->GetWidth();
|
||||||
if (!empty($sWidth))
|
if (!empty($sWidth)) {
|
||||||
{
|
|
||||||
$aStyles[] = 'width:'.$sWidth;
|
$aStyles[] = 'width:'.$sWidth;
|
||||||
}
|
}
|
||||||
$sHeight = $oAttDef->GetHeight();
|
$sHeight = $oAttDef->GetHeight();
|
||||||
if (!empty($sHeight))
|
if (!empty($sHeight)) {
|
||||||
{
|
|
||||||
$aStyles[] = 'height:'.$sHeight;
|
$aStyles[] = 'height:'.$sHeight;
|
||||||
}
|
}
|
||||||
if (count($aStyles) > 0)
|
if (count($aStyles) > 0) {
|
||||||
{
|
|
||||||
$sStyle = 'style="'.implode('; ', $aStyles).'"';
|
$sStyle = 'style="'.implode('; ', $aStyles).'"';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($oAttDef->GetEditClass() == 'OQLExpression') {
|
if ($oAttDef->GetEditClass() == 'OQLExpression') {
|
||||||
// predefined queries N°3227
|
// N°3227 button to open predefined queries dialog
|
||||||
$sPredefinedBtnId = 'predef_btn_'.$sFieldPrefix.$sAttCode.$sNameSuffix;
|
$sPredefinedBtnId = 'predef_btn_'.$sFieldPrefix.$sAttCode.$sNameSuffix;
|
||||||
$sSearchQueryLbl = Dict::S('UI:Edit:SearchQuery');
|
$sSearchQueryLbl = Dict::S('UI:Edit:SearchQuery');
|
||||||
$oPredefQueryButton = ButtonUIBlockFactory::MakeIconLink(
|
$oPredefQueryButton = ButtonUIBlockFactory::MakeIconLink(
|
||||||
@@ -1951,12 +1990,12 @@ JS
|
|||||||
} else {
|
} else {
|
||||||
$sAdditionalStuff = '';
|
$sAdditionalStuff = '';
|
||||||
}
|
}
|
||||||
// Ok, the text area is drawn here
|
// Ok, the text area is drawn here
|
||||||
$sHTMLValue = "$sAdditionalStuff<div class=\"field_input_zone field_input_text\"><div class=\"f_i_text_header\"><span class=\"fullscreen_button\" title=\"".Dict::S('UI:ToggleFullScreen')."\"></span></div><textarea class=\"\" title=\"$sHelpText\" name=\"attr_{$sFieldPrefix}{$sAttCode}{$sNameSuffix}\" rows=\"8\" cols=\"40\" id=\"$iId\" $sStyle>".htmlentities($sEditValue,
|
$sHTMLValue = "$sAdditionalStuff<div class=\"field_input_zone field_input_text\"><div class=\"f_i_text_header\"><span class=\"fullscreen_button\" title=\"".Dict::S('UI:ToggleFullScreen')."\"></span></div><textarea class=\"\" title=\"$sHelpText\" name=\"attr_{$sFieldPrefix}{$sAttCode}{$sNameSuffix}\" rows=\"8\" cols=\"40\" id=\"$iId\" $sStyle>".htmlentities($sEditValue,
|
||||||
ENT_QUOTES, 'UTF-8')."</textarea></div>{$sValidationSpan}{$sReloadSpan}";
|
ENT_QUOTES, 'UTF-8')."</textarea></div>{$sValidationSpan}{$sReloadSpan}";
|
||||||
|
|
||||||
$oPage->add_ready_script(
|
$oPage->add_ready_script(
|
||||||
<<<EOF
|
<<<EOF
|
||||||
$('#$iId').closest('.field_input_text').find('.fullscreen_button').on('click', function(oEvent){
|
$('#$iId').closest('.field_input_text').find('.fullscreen_button').on('click', function(oEvent){
|
||||||
var oOriginField = $('#$iId').closest('.field_input_text');
|
var oOriginField = $('#$iId').closest('.field_input_text');
|
||||||
var oClonedField = oOriginField.clone();
|
var oClonedField = oOriginField.clone();
|
||||||
@@ -1975,20 +2014,18 @@ EOF
|
|||||||
|
|
||||||
// TODO 3.0.0: Isn't this part obsolete now that we have the activity panel or should we keep it for devs using it in custom extensions?
|
// TODO 3.0.0: Isn't this part obsolete now that we have the activity panel or should we keep it for devs using it in custom extensions?
|
||||||
case 'CaseLog':
|
case 'CaseLog':
|
||||||
|
$sInputType = self::ENUM_INPUT_TYPE_HTML_EDITOR;
|
||||||
$aStyles = array();
|
$aStyles = array();
|
||||||
$sStyle = '';
|
$sStyle = '';
|
||||||
$sWidth = $oAttDef->GetWidth();
|
$sWidth = $oAttDef->GetWidth();
|
||||||
if (!empty($sWidth))
|
if (!empty($sWidth)) {
|
||||||
{
|
|
||||||
$aStyles[] = 'width:'.$sWidth;
|
$aStyles[] = 'width:'.$sWidth;
|
||||||
}
|
}
|
||||||
$sHeight = $oAttDef->GetHeight();
|
$sHeight = $oAttDef->GetHeight();
|
||||||
if (!empty($sHeight))
|
if (!empty($sHeight)) {
|
||||||
{
|
|
||||||
$aStyles[] = 'height:'.$sHeight;
|
$aStyles[] = 'height:'.$sHeight;
|
||||||
}
|
}
|
||||||
if (count($aStyles) > 0)
|
if (count($aStyles) > 0) {
|
||||||
{
|
|
||||||
$sStyle = 'style="'.implode('; ', $aStyles).'"';
|
$sStyle = 'style="'.implode('; ', $aStyles).'"';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2005,8 +2042,7 @@ EOF
|
|||||||
|
|
||||||
// Note: This should be refactored for all types of attribute (see at the end of this function) but as we are doing this for a maintenance release, we are scheduling it for the next main release in to order to avoid regressions as much as possible.
|
// Note: This should be refactored for all types of attribute (see at the end of this function) but as we are doing this for a maintenance release, we are scheduling it for the next main release in to order to avoid regressions as much as possible.
|
||||||
$sNullValue = $oAttDef->GetNullValue();
|
$sNullValue = $oAttDef->GetNullValue();
|
||||||
if (!is_numeric($sNullValue))
|
if (!is_numeric($sNullValue)) {
|
||||||
{
|
|
||||||
$sNullValue = "'$sNullValue'"; // Add quotes to turn this into a JS string if it's not a number
|
$sNullValue = "'$sNullValue'"; // Add quotes to turn this into a JS string if it's not a number
|
||||||
}
|
}
|
||||||
$sOriginalValue = ($iFlags & OPT_ATT_MUSTCHANGE) ? json_encode($value->GetModifiedEntry('html')) : 'undefined';
|
$sOriginalValue = ($iFlags & OPT_ATT_MUSTCHANGE) ? json_encode($value->GetModifiedEntry('html')) : 'undefined';
|
||||||
@@ -2045,9 +2081,10 @@ $('#$iId').bind('update', function(evt){
|
|||||||
});
|
});
|
||||||
EOF
|
EOF
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'HTML':
|
case 'HTML':
|
||||||
|
$sInputType = self::ENUM_INPUT_TYPE_HTML_EDITOR;
|
||||||
$sEditValue = $oAttDef->GetEditValue($value);
|
$sEditValue = $oAttDef->GetEditValue($value);
|
||||||
$oWidget = new UIHTMLEditorWidget($iId, $oAttDef, $sNameSuffix, $sFieldPrefix, $sHelpText,
|
$oWidget = new UIHTMLEditorWidget($iId, $oAttDef, $sNameSuffix, $sFieldPrefix, $sHelpText,
|
||||||
$sValidationSpan.$sReloadSpan, $sEditValue, $bMandatory);
|
$sValidationSpan.$sReloadSpan, $sEditValue, $bMandatory);
|
||||||
@@ -2055,13 +2092,11 @@ EOF
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'LinkedSet':
|
case 'LinkedSet':
|
||||||
if ($oAttDef->IsIndirect())
|
$sInputType = ''; // TODO drop down VS autocomplete ?
|
||||||
{
|
if ($oAttDef->IsIndirect()) {
|
||||||
$oWidget = new UILinksWidget($sClass, $sAttCode, $iId, $sNameSuffix,
|
$oWidget = new UILinksWidget($sClass, $sAttCode, $iId, $sNameSuffix,
|
||||||
$oAttDef->DuplicatesAllowed());
|
$oAttDef->DuplicatesAllowed());
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$oWidget = new UILinksWidgetDirect($sClass, $sAttCode, $iId, $sNameSuffix);
|
$oWidget = new UILinksWidgetDirect($sClass, $sAttCode, $iId, $sNameSuffix);
|
||||||
}
|
}
|
||||||
$aEventsList[] = 'validate';
|
$aEventsList[] = 'validate';
|
||||||
@@ -2071,12 +2106,12 @@ EOF
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'Document':
|
case 'Document':
|
||||||
|
$sInputType = self::ENUM_INPUT_TYPE_DOCUMENT;
|
||||||
$aEventsList[] = 'validate';
|
$aEventsList[] = 'validate';
|
||||||
$aEventsList[] = 'change';
|
$aEventsList[] = 'change';
|
||||||
$oDocument = $value; // Value is an ormDocument object
|
$oDocument = $value; // Value is an ormDocument object
|
||||||
$sFileName = '';
|
$sFileName = '';
|
||||||
if (is_object($oDocument))
|
if (is_object($oDocument)) {
|
||||||
{
|
|
||||||
$sFileName = $oDocument->GetFileName();
|
$sFileName = $oDocument->GetFileName();
|
||||||
}
|
}
|
||||||
$iMaxFileSize = utils::ConvertToBytes(ini_get('upload_max_filesize'));
|
$iMaxFileSize = utils::ConvertToBytes(ini_get('upload_max_filesize'));
|
||||||
@@ -2088,20 +2123,20 @@ EOF
|
|||||||
ENT_QUOTES, 'UTF-8')."\"/>\n";
|
ENT_QUOTES, 'UTF-8')."\"/>\n";
|
||||||
$sHTMLValue .= "<span id=\"name_$iInputId\"' >".htmlentities($sFileName, ENT_QUOTES,
|
$sHTMLValue .= "<span id=\"name_$iInputId\"' >".htmlentities($sFileName, ENT_QUOTES,
|
||||||
'UTF-8')."</span>  ";
|
'UTF-8')."</span>  ";
|
||||||
$sHTMLValue .= "<div title=\"".htmlentities(Dict::S('UI:Button:RemoveDocument'), ENT_QUOTES, 'UTF-8'). "\" id=\"remove_attr_$iId\" class=\"button\" onClick=\"$('#file_$iId').val('');UpdateFileName('$iId', '');\" style=\"display: contents;\">";
|
$sHTMLValue .= "<div title=\"".htmlentities(Dict::S('UI:Button:RemoveDocument'), ENT_QUOTES, 'UTF-8')."\" id=\"remove_attr_$iId\" class=\"button\" onClick=\"$('#file_$iId').val('');UpdateFileName('$iId', '');\" style=\"display: contents;\">";
|
||||||
$sHTMLValue .= "<div class=\"ui-icon ui-icon-trash\"></div></div>";
|
$sHTMLValue .= "<div class=\"ui-icon ui-icon-trash\"></div></div>";
|
||||||
$sHTMLValue .= "</div>";
|
$sHTMLValue .= "</div>";
|
||||||
$sHTMLValue .= "<br/>\n";
|
$sHTMLValue .= "<br/>\n";
|
||||||
$sHTMLValue .= "<input title=\"$sHelpText\" name=\"attr_{$sFieldPrefix}{$sAttCode}{$sNameSuffix}[fcontents]\" type=\"file\" id=\"file_$iId\" onChange=\"UpdateFileName('$iId', this.value)\"/>\n";
|
$sHTMLValue .= "<input title=\"$sHelpText\" name=\"attr_{$sFieldPrefix}{$sAttCode}{$sNameSuffix}[fcontents]\" type=\"file\" id=\"file_$iId\" onChange=\"UpdateFileName('$iId', this.value)\"/>\n";
|
||||||
$sHTMLValue .= "</div>\n";
|
$sHTMLValue .= "</div>\n";
|
||||||
$sHTMLValue .= "{$sValidationSpan}{$sReloadSpan}\n";
|
$sHTMLValue .= "{$sValidationSpan}{$sReloadSpan}\n";
|
||||||
if ($sFileName == '')
|
if ($sFileName == '') {
|
||||||
{
|
|
||||||
$oPage->add_ready_script("$('#remove_attr_{$iId}').hide();");
|
$oPage->add_ready_script("$('#remove_attr_{$iId}').hide();");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'Image':
|
case 'Image':
|
||||||
|
$sInputType = self::ENUM_INPUT_TYPE_IMAGE;
|
||||||
$aEventsList[] = 'validate';
|
$aEventsList[] = 'validate';
|
||||||
$aEventsList[] = 'change';
|
$aEventsList[] = 'change';
|
||||||
$oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/edit_image.js');
|
$oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/edit_image.js');
|
||||||
@@ -2143,6 +2178,7 @@ EOF
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'One Way Password':
|
case 'One Way Password':
|
||||||
|
$sInputType = self::ENUM_INPUT_TYPE_PASSWORD;
|
||||||
$aEventsList[] = 'validate';
|
$aEventsList[] = 'validate';
|
||||||
$oWidget = new UIPasswordWidget($sAttCode, $iId, $sNameSuffix);
|
$oWidget = new UIPasswordWidget($sAttCode, $iId, $sNameSuffix);
|
||||||
$sHTMLValue = $oWidget->Display($oPage, $aArgs);
|
$sHTMLValue = $oWidget->Display($oPage, $aArgs);
|
||||||
@@ -2150,16 +2186,14 @@ EOF
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'ExtKey':
|
case 'ExtKey':
|
||||||
|
$sInputType = ''; // TODO
|
||||||
/** @var \AttributeExternalKey $oAttDef */
|
/** @var \AttributeExternalKey $oAttDef */
|
||||||
$aEventsList[] = 'validate';
|
$aEventsList[] = 'validate';
|
||||||
$aEventsList[] = 'change';
|
$aEventsList[] = 'change';
|
||||||
|
|
||||||
if ($bPreserveCurrentValue)
|
if ($bPreserveCurrentValue) {
|
||||||
{
|
|
||||||
$oAllowedValues = MetaModel::GetAllowedValuesAsObjectSet($sClass, $sAttCode, $aArgs, '', $value);
|
$oAllowedValues = MetaModel::GetAllowedValuesAsObjectSet($sClass, $sAttCode, $aArgs, '', $value);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$oAllowedValues = MetaModel::GetAllowedValuesAsObjectSet($sClass, $sAttCode, $aArgs);
|
$oAllowedValues = MetaModel::GetAllowedValuesAsObjectSet($sClass, $sAttCode, $aArgs);
|
||||||
}
|
}
|
||||||
$sFieldName = $sFieldPrefix.$sAttCode.$sNameSuffix;
|
$sFieldName = $sFieldPrefix.$sAttCode.$sNameSuffix;
|
||||||
@@ -2167,15 +2201,14 @@ EOF
|
|||||||
$aExtKeyParams['iFieldSize'] = $oAttDef->GetMaxSize();
|
$aExtKeyParams['iFieldSize'] = $oAttDef->GetMaxSize();
|
||||||
$aExtKeyParams['iMinChars'] = $oAttDef->GetMinAutoCompleteChars();
|
$aExtKeyParams['iMinChars'] = $oAttDef->GetMinAutoCompleteChars();
|
||||||
$sHTMLValue = UIExtKeyWidget::DisplayFromAttCode($oPage, $sAttCode, $sClass, $oAttDef->GetLabel(),
|
$sHTMLValue = UIExtKeyWidget::DisplayFromAttCode($oPage, $sAttCode, $sClass, $oAttDef->GetLabel(),
|
||||||
$oAllowedValues, $value, $iId, $bMandatory, $sFieldName, $sFormPrefix, $aExtKeyParams);
|
$oAllowedValues, $value, $iId, $bMandatory, $sFieldName, $sFormPrefix, $aExtKeyParams, false, $sInputType);
|
||||||
$sHTMLValue .= "<!-- iFlags: $iFlags bMandatory: $bMandatory -->\n";
|
$sHTMLValue .= "<!-- iFlags: $iFlags bMandatory: $bMandatory -->\n";
|
||||||
|
|
||||||
$bHasExtKeyUpdatingRemoteClassFields = (
|
$bHasExtKeyUpdatingRemoteClassFields = (
|
||||||
array_key_exists('replaceDependenciesByRemoteClassFields', $aArgs)
|
array_key_exists('replaceDependenciesByRemoteClassFields', $aArgs)
|
||||||
&& ($aArgs['replaceDependenciesByRemoteClassFields'])
|
&& ($aArgs['replaceDependenciesByRemoteClassFields'])
|
||||||
);
|
);
|
||||||
if ($bHasExtKeyUpdatingRemoteClassFields)
|
if ($bHasExtKeyUpdatingRemoteClassFields) {
|
||||||
{
|
|
||||||
// On this field update we need to update all the corresponding remote class fields
|
// On this field update we need to update all the corresponding remote class fields
|
||||||
// Used when extkey widget is in a linkedset indirect
|
// Used when extkey widget is in a linkedset indirect
|
||||||
$sWizardHelperJsVarName = $aArgs['wizHelperRemote'];
|
$sWizardHelperJsVarName = $aArgs['wizHelperRemote'];
|
||||||
@@ -2257,6 +2290,7 @@ JS
|
|||||||
|
|
||||||
case 'Set':
|
case 'Set':
|
||||||
case 'TagSet':
|
case 'TagSet':
|
||||||
|
$sInputType = self::ENUM_INPUT_TYPE_TAGSET;
|
||||||
$oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'/js/selectize.min.js');
|
$oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'/js/selectize.min.js');
|
||||||
$oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/selectize.default.css');
|
$oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/selectize.default.css');
|
||||||
$oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'/js/jquery.itop-set-widget.js');
|
$oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'/js/jquery.itop-set-widget.js');
|
||||||
@@ -2297,6 +2331,7 @@ JS
|
|||||||
case 'radio':
|
case 'radio':
|
||||||
case 'radio_horizontal':
|
case 'radio_horizontal':
|
||||||
case 'radio_vertical':
|
case 'radio_vertical':
|
||||||
|
$sInputType = self::ENUM_INPUT_TYPE_RADIO;
|
||||||
$aEventsList[] = 'change';
|
$aEventsList[] = 'change';
|
||||||
$sHTMLValue = "<div class=\"field_input_zone field_input_{$sDisplayStyle}\">";
|
$sHTMLValue = "<div class=\"field_input_zone field_input_{$sDisplayStyle}\">";
|
||||||
$bVertical = ($sDisplayStyle != 'radio_horizontal');
|
$bVertical = ($sDisplayStyle != 'radio_horizontal');
|
||||||
@@ -2307,16 +2342,14 @@ JS
|
|||||||
|
|
||||||
case 'select':
|
case 'select':
|
||||||
default:
|
default:
|
||||||
|
$sInputType = self::ENUM_INPUT_TYPE_DROPDOWN_RAW;
|
||||||
$aEventsList[] = 'change';
|
$aEventsList[] = 'change';
|
||||||
$sHTMLValue = "<div class=\"field_input_zone field_input_string ibo-input-wrapper ibo-input-select-wrapper\" data-validation=\"untouched\"><select class=\"ibo-input ibo-input-select\" title=\"$sHelpText\" name=\"attr_{$sFieldPrefix}{$sAttCode}{$sNameSuffix}\" id=\"$iId\">\n";
|
$sHTMLValue = "<div class=\"field_input_zone field_input_string ibo-input-wrapper ibo-input-select-wrapper\" data-validation=\"untouched\"><select class=\"ibo-input ibo-input-select\" title=\"$sHelpText\" name=\"attr_{$sFieldPrefix}{$sAttCode}{$sNameSuffix}\" id=\"$iId\">\n";
|
||||||
$sHTMLValue .= "<option value=\"\">".Dict::S('UI:SelectOne')."</option>\n";
|
$sHTMLValue .= "<option value=\"\">".Dict::S('UI:SelectOne')."</option>\n";
|
||||||
foreach($aAllowedValues as $key => $display_value)
|
foreach ($aAllowedValues as $key => $display_value) {
|
||||||
{
|
if ((count($aAllowedValues) == 1) && ($bMandatory == 'true')) {
|
||||||
if ((count($aAllowedValues) == 1) && ($bMandatory == 'true'))
|
|
||||||
{
|
|
||||||
// When there is only once choice, select it by default
|
// When there is only once choice, select it by default
|
||||||
if($value != $key)
|
if ($value != $key) {
|
||||||
{
|
|
||||||
$oPage->add_ready_script(
|
$oPage->add_ready_script(
|
||||||
<<<EOF
|
<<<EOF
|
||||||
$('#$iId').attr('data-validate','dependencies');
|
$('#$iId').attr('data-validate','dependencies');
|
||||||
@@ -2324,9 +2357,7 @@ EOF
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
$sSelected = ' selected';
|
$sSelected = ' selected';
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$sSelected = ($value == $key) ? ' selected' : '';
|
$sSelected = ($value == $key) ? ' selected' : '';
|
||||||
}
|
}
|
||||||
$sHTMLValue .= "<option value=\"$key\"$sSelected>$display_value</option>\n";
|
$sHTMLValue .= "<option value=\"$key\"$sSelected>$display_value</option>\n";
|
||||||
@@ -2337,10 +2368,10 @@ EOF
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$sInputType = self::ENUM_INPUT_TYPE_SINGLE_INPUT;
|
||||||
$sTip = '';
|
$sTip = '';
|
||||||
// Adding tooltip so we can read the whole value when its very long (eg. URL)
|
// Adding tooltip so we can read the whole value when its very long (eg. URL)
|
||||||
if (!empty($sDisplayValue))
|
if (!empty($sDisplayValue)) {
|
||||||
{
|
|
||||||
$sTip = ' data-tooltip-content="'.utils::HtmlEntities($sDisplayValue).'"';
|
$sTip = ' data-tooltip-content="'.utils::HtmlEntities($sDisplayValue).'"';
|
||||||
$oPage->add_ready_script(
|
$oPage->add_ready_script(
|
||||||
<<<EOF
|
<<<EOF
|
||||||
|
|||||||
@@ -70,10 +70,29 @@ class UIExtKeyWidget
|
|||||||
protected $sAttCode;
|
protected $sAttCode;
|
||||||
protected $bSearchMode;
|
protected $bSearchMode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \WebPage $oPage
|
||||||
|
* @param string $sAttCode
|
||||||
|
* @param string $sClass
|
||||||
|
* @param string $sTitle
|
||||||
|
* @param object $oAllowedValues
|
||||||
|
* @param mixed $value
|
||||||
|
* @param int $iInputId
|
||||||
|
* @param boolean $bMandatory
|
||||||
|
* @param string $sFieldName
|
||||||
|
* @param string $sFormPrefix
|
||||||
|
* @param array $aArgs
|
||||||
|
* @param boolean $bSearchMode
|
||||||
|
* @param string $sInputType type of field rendering, contains one of the \cmdbAbstractObject::ENUM_INPUT_TYPE_* constants
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @throws \Exception
|
||||||
|
*
|
||||||
|
* @since 3.0.0 N°3750 new $sInputType parameter
|
||||||
|
*/
|
||||||
public static function DisplayFromAttCode(
|
public static function DisplayFromAttCode(
|
||||||
$oPage, $sAttCode, $sClass, $sTitle, $oAllowedValues, $value, $iInputId, $bMandatory, $sFieldName = '', $sFormPrefix = '',
|
$oPage, $sAttCode, $sClass, $sTitle, $oAllowedValues, $value, $iInputId, $bMandatory, $sFieldName = '', $sFormPrefix = '',
|
||||||
$aArgs = [],
|
$aArgs = [], $bSearchMode = false, &$sInputType = ''
|
||||||
$bSearchMode = false
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
|
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
|
||||||
@@ -92,21 +111,20 @@ class UIExtKeyWidget
|
|||||||
case 'radio':
|
case 'radio':
|
||||||
case 'radio_horizontal':
|
case 'radio_horizontal':
|
||||||
case 'radio_vertical':
|
case 'radio_vertical':
|
||||||
|
$sInputType = CmdbAbstractObject::ENUM_INPUT_TYPE_RADIO;
|
||||||
|
|
||||||
return $oWidget->DisplayRadio($oPage, $iMaxComboLength, $bAllowTargetCreation, $oAllowedValues, $value, $sFieldName, $sDisplayStyle);
|
return $oWidget->DisplayRadio($oPage, $iMaxComboLength, $bAllowTargetCreation, $oAllowedValues, $value, $sFieldName, $sDisplayStyle);
|
||||||
break;
|
|
||||||
|
|
||||||
case 'select':
|
case 'select':
|
||||||
case 'list':
|
case 'list':
|
||||||
default:
|
default:
|
||||||
return $oWidget->DisplaySelect($oPage, $iMaxComboLength, $bAllowTargetCreation, $sTitle, $oAllowedValues, $value,
|
return $oWidget->DisplaySelect($oPage, $iMaxComboLength, $bAllowTargetCreation, $sTitle, $oAllowedValues, $value,
|
||||||
$bMandatory, $sFieldName, $sFormPrefix, $aArgs);
|
$bMandatory, $sFieldName, $sFormPrefix, $aArgs, $sInputType);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return $oWidget->Display($oPage, $iMaxComboLength, $bAllowTargetCreation, $sTitle, $oAllowedValues, $value, $iInputId,
|
return $oWidget->Display($oPage, $iMaxComboLength, $bAllowTargetCreation, $sTitle, $oAllowedValues, $value, $iInputId,
|
||||||
$bMandatory, $sFieldName, $sFormPrefix, $aArgs, null, $sDisplayStyle);
|
$bMandatory, $sFieldName, $sFormPrefix, $aArgs, null, $sDisplayStyle, true, $sInputType);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __construct($sTargetClass, $iInputId, $sAttCode = '', $bSearchMode = false, $sFilter = null)
|
public function __construct($sTargetClass, $iInputId, $sAttCode = '', $bSearchMode = false, $sFilter = null)
|
||||||
@@ -119,13 +137,32 @@ class UIExtKeyWidget
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 3.0.0 N°2508 - Include Obsolescence icon within list and autocomplete
|
* @param \WebPage $oPage
|
||||||
* Get the HTML fragment corresponding to the ext key editing widget
|
* @param int $iMaxComboLength
|
||||||
* @param WebPage $oP The web page used for all the output
|
* @param bool $bAllowTargetCreation
|
||||||
|
* @param string $sTitle
|
||||||
|
* @param \DBObjectset $oAllowedValues
|
||||||
|
* @param mixed $value
|
||||||
|
* @param bool $bMandatory
|
||||||
|
* @param string $sFieldName
|
||||||
|
* @param string $sFormPrefix
|
||||||
* @param array $aArgs Extra context arguments
|
* @param array $aArgs Extra context arguments
|
||||||
* @return string The HTML fragment to be inserted into the page
|
* @param string $sInputType type of field rendering, contains one of the \cmdbAbstractObject::ENUM_INPUT_TYPE_* constants
|
||||||
|
*
|
||||||
|
* @return string the HTML fragment corresponding to the ext key editing widget
|
||||||
|
* @throws \ArchivedObjectException
|
||||||
|
* @throws \ConfigException
|
||||||
|
* @throws \CoreException
|
||||||
|
* @throws \CoreUnexpectedValue
|
||||||
|
* @throws \DictExceptionMissingString
|
||||||
|
* @throws \MissingQueryArgument
|
||||||
|
* @throws \MySQLException
|
||||||
|
* @throws \MySQLHasGoneAwayException
|
||||||
|
*
|
||||||
|
* @since 3.0.0 N°2508 - Include Obsolescence icon within list and autocomplete
|
||||||
|
* @since 3.0.0 N°3750 new $sInputType parameter
|
||||||
*/
|
*/
|
||||||
public function DisplaySelect(WebPage $oPage, $iMaxComboLength, $bAllowTargetCreation, $sTitle, DBObjectset $oAllowedValues, $value, $bMandatory, $sFieldName, $sFormPrefix = '', $aArgs = array())
|
public function DisplaySelect(WebPage $oPage, $iMaxComboLength, $bAllowTargetCreation, $sTitle, DBObjectset $oAllowedValues, $value, $bMandatory, $sFieldName, $sFormPrefix = '', $aArgs = array(), &$sInputType = '')
|
||||||
{
|
{
|
||||||
$sTitle = addslashes($sTitle);
|
$sTitle = addslashes($sTitle);
|
||||||
$oPage->add_linked_script('../js/extkeywidget.js');
|
$oPage->add_linked_script('../js/extkeywidget.js');
|
||||||
@@ -208,30 +245,27 @@ class UIExtKeyWidget
|
|||||||
$value=$oObj->GetKey();
|
$value=$oObj->GetKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
if ((is_array($value) && in_array($oObj->GetKey(), $value)) || ($value == $oObj->GetKey())) {
|
||||||
if ((is_array($value) && in_array($oObj->GetKey(), $value)) || ($value == $oObj->GetKey()))
|
$sDisplayValue = $oObj->GetKey();
|
||||||
{
|
// $sHTMLValue.="<div class='item' data-value='".$oObj->GetKey)."'>".$oObj->GetName()."</div>";
|
||||||
$sDisplayValue=$oObj->GetKey();
|
|
||||||
// $sHTMLValue.="<div class='item' data-value='".$oObj->GetKey)."'>".$oObj->GetName()."</div>";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($oObj->IsObsolete()){
|
if ($oObj->IsObsolete()) {
|
||||||
$aOption['obsolescence_flag'] ="1";
|
$aOption['obsolescence_flag'] = "1";
|
||||||
}
|
}
|
||||||
if ($bAddingValue)
|
if ($bAddingValue) {
|
||||||
{
|
|
||||||
$aArguments = [];
|
$aArguments = [];
|
||||||
foreach ($aAdditionalField as $sAdditionalField)
|
foreach ($aAdditionalField as $sAdditionalField) {
|
||||||
{
|
array_push($aArguments, $oObj->Get($sAdditionalField));
|
||||||
array_push($aArguments,$oObj->Get($sAdditionalField));
|
|
||||||
}
|
}
|
||||||
$aOption['additional_field'] = vsprintf($sFormatAdditionalField, $aArguments);
|
$aOption['additional_field'] = vsprintf($sFormatAdditionalField, $aArguments);
|
||||||
}
|
}
|
||||||
array_push($aOptions,$aOption);
|
array_push($aOptions, $aOption);
|
||||||
}
|
}
|
||||||
|
$sInputType = CmdbAbstractObject::ENUM_INPUT_TYPE_DROPDOWN_DECORATED;
|
||||||
$sHTMLValue .= "<select title=\"$sHelpText\" name=\"{$sAttrFieldPrefix}{$sFieldName}\" id=\"$this->iId\"></select>";
|
$sHTMLValue .= "<select title=\"$sHelpText\" name=\"{$sAttrFieldPrefix}{$sFieldName}\" id=\"$this->iId\"></select>";
|
||||||
$sJsonOptions=json_encode($aOptions);
|
$sJsonOptions = json_encode($aOptions);
|
||||||
$oPage->add_ready_script(
|
$oPage->add_ready_script(
|
||||||
<<<EOF
|
<<<EOF
|
||||||
oACWidget_{$this->iId} = new ExtKeyWidget('{$this->iId}', '{$this->sTargetClass}', '$sFilter', '$sTitle', true, $sWizHelper, '{$this->sAttCode}', $sJSSearchMode, $sJSDoSearch);
|
oACWidget_{$this->iId} = new ExtKeyWidget('{$this->iId}', '{$this->sTargetClass}', '$sFilter', '$sTitle', true, $sWizHelper, '{$this->sAttCode}', $sJSSearchMode, $sJSDoSearch);
|
||||||
@@ -272,14 +306,13 @@ EOF
|
|||||||
if (is_null($value) || ($value == 0)) // Null values are displayed as ''
|
if (is_null($value) || ($value == 0)) // Null values are displayed as ''
|
||||||
{
|
{
|
||||||
$sDisplayValue = isset($aArgs['sDefaultValue']) ? $aArgs['sDefaultValue'] : '';
|
$sDisplayValue = isset($aArgs['sDefaultValue']) ? $aArgs['sDefaultValue'] : '';
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$sDisplayValue = $this->GetObjectName($value);
|
$sDisplayValue = $this->GetObjectName($value);
|
||||||
}
|
}
|
||||||
$iMinChars = isset($aArgs['iMinChars']) ? $aArgs['iMinChars'] : 2; //@@@ $this->oAttDef->GetMinAutoCompleteChars();
|
$iMinChars = isset($aArgs['iMinChars']) ? $aArgs['iMinChars'] : 2; //@@@ $this->oAttDef->GetMinAutoCompleteChars();
|
||||||
|
|
||||||
// the input for the auto-complete
|
// the input for the auto-complete
|
||||||
|
$sInputType = CmdbAbstractObject::ENUM_INPUT_TYPE_AUTOCOMPLETE;
|
||||||
$sHTMLValue .= "<input class=\"field_autocomplete ibo-input ibo-input-select ibo-input-select-autocomplete\" type=\"text\" id=\"label_$this->iId\" value=\"$sDisplayValue\"/>";
|
$sHTMLValue .= "<input class=\"field_autocomplete ibo-input ibo-input-select ibo-input-select-autocomplete\" type=\"text\" id=\"label_$this->iId\" value=\"$sDisplayValue\"/>";
|
||||||
|
|
||||||
// another hidden input to store & pass the object's Id
|
// another hidden input to store & pass the object's Id
|
||||||
@@ -419,17 +452,40 @@ JS
|
|||||||
|
|
||||||
return $sHTMLValue;
|
return $sHTMLValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use DisplayBob
|
* @deprecated Use DisplayBob
|
||||||
* Get the HTML fragment corresponding to the ext key editing widget
|
* Get the HTML fragment corresponding to the ext key editing widget
|
||||||
* @param WebPage $oP The web page used for all the output
|
*
|
||||||
|
* @param \WebPage $oPage
|
||||||
|
* @param int $iMaxComboLength
|
||||||
|
* @param boolean $bAllowTargetCreation
|
||||||
|
* @param string $sTitle
|
||||||
|
* @param \DBObjectset $oAllowedValues
|
||||||
|
* @param mixed $value
|
||||||
|
* @param int $iInputId
|
||||||
|
* @param boolean $bMandatory
|
||||||
|
* @param strin $sFieldName
|
||||||
|
* @param string $sFormPrefix
|
||||||
* @param array $aArgs Extra context arguments
|
* @param array $aArgs Extra context arguments
|
||||||
|
* @param null $bSearchMode
|
||||||
|
* @param string $sDisplayStyle
|
||||||
|
* @param boolean $bSearchMultiple
|
||||||
|
* @param string $sInputType type of field rendering, contains one of the \cmdbAbstractObject::ENUM_INPUT_TYPE_* constants
|
||||||
|
*
|
||||||
* @return string The HTML fragment to be inserted into the page
|
* @return string The HTML fragment to be inserted into the page
|
||||||
|
* @throws \ConfigException
|
||||||
|
* @throws \CoreException
|
||||||
|
* @throws \CoreUnexpectedValue
|
||||||
|
* @throws \MissingQueryArgument
|
||||||
|
* @throws \MySQLException
|
||||||
|
* @throws \MySQLHasGoneAwayException
|
||||||
|
*
|
||||||
|
* @since 3.0.0 N°3750 new $sInputType parameter
|
||||||
*/
|
*/
|
||||||
public function Display(WebPage $oPage, $iMaxComboLength, $bAllowTargetCreation, $sTitle, DBObjectset $oAllowedValues, $value, $iInputId, $bMandatory, $sFieldName, $sFormPrefix = '', $aArgs = array(), $bSearchMode = null, $sDisplayStyle = 'select', $bSearchMultiple = true)
|
public function Display(WebPage $oPage, $iMaxComboLength, $bAllowTargetCreation, $sTitle, DBObjectset $oAllowedValues, $value, $iInputId, $bMandatory, $sFieldName, $sFormPrefix = '', $aArgs = array(), $bSearchMode = null, $sDisplayStyle = 'select', $bSearchMultiple = true, &$sInputType = '')
|
||||||
{
|
{
|
||||||
if (!is_null($bSearchMode))
|
if (!is_null($bSearchMode)) {
|
||||||
{
|
|
||||||
$this->bSearchMode = $bSearchMode;
|
$this->bSearchMode = $bSearchMode;
|
||||||
}
|
}
|
||||||
$sTitle = addslashes($sTitle);
|
$sTitle = addslashes($sTitle);
|
||||||
@@ -443,27 +499,20 @@ JS
|
|||||||
|
|
||||||
$sHTMLValue = "<div class=\"field_input_zone field_input_extkey\">";
|
$sHTMLValue = "<div class=\"field_input_zone field_input_extkey\">";
|
||||||
$sFilter = addslashes($oAllowedValues->GetFilter()->ToOQL());
|
$sFilter = addslashes($oAllowedValues->GetFilter()->ToOQL());
|
||||||
if($this->bSearchMode)
|
if ($this->bSearchMode) {
|
||||||
{
|
|
||||||
$sWizHelper = 'null';
|
$sWizHelper = 'null';
|
||||||
$sWizHelperJSON = "''";
|
$sWizHelperJSON = "''";
|
||||||
$sJSSearchMode = 'true';
|
$sJSSearchMode = 'true';
|
||||||
}
|
} else {
|
||||||
else
|
if (isset($aArgs['wizHelper'])) {
|
||||||
{
|
|
||||||
if (isset($aArgs['wizHelper']))
|
|
||||||
{
|
|
||||||
$sWizHelper = $aArgs['wizHelper'];
|
$sWizHelper = $aArgs['wizHelper'];
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$sWizHelper = 'oWizardHelper'.$sFormPrefix;
|
$sWizHelper = 'oWizardHelper'.$sFormPrefix;
|
||||||
}
|
}
|
||||||
$sWizHelperJSON = $sWizHelper.'.UpdateWizardToJSON()';
|
$sWizHelperJSON = $sWizHelper.'.UpdateWizardToJSON()';
|
||||||
$sJSSearchMode = 'false';
|
$sJSSearchMode = 'false';
|
||||||
}
|
}
|
||||||
if (is_null($oAllowedValues))
|
if (is_null($oAllowedValues)) {
|
||||||
{
|
|
||||||
throw new Exception('Implementation: null value for allowed values definition');
|
throw new Exception('Implementation: null value for allowed values definition');
|
||||||
}
|
}
|
||||||
$oAllowedValues->SetShowObsoleteData(utils::ShowObsoleteData());
|
$oAllowedValues->SetShowObsoleteData(utils::ShowObsoleteData());
|
||||||
@@ -472,84 +521,71 @@ JS
|
|||||||
$sJSDoSearch = $bDoSearch ? 'true' : 'false';
|
$sJSDoSearch = $bDoSearch ? 'true' : 'false';
|
||||||
|
|
||||||
// We just need to compare the number of entries with MaxComboLength, so no need to get the real count.
|
// We just need to compare the number of entries with MaxComboLength, so no need to get the real count.
|
||||||
if (!$oAllowedValues->CountExceeds($iMaxComboLength))
|
if (!$oAllowedValues->CountExceeds($iMaxComboLength)) {
|
||||||
{
|
// Discrete list of values, use a SELECT or RADIO buttons depending on the config
|
||||||
// Discrete list of values, use a SELECT or RADIO buttons depending on the config
|
switch ($sDisplayStyle) {
|
||||||
switch($sDisplayStyle)
|
|
||||||
{
|
|
||||||
case 'radio':
|
case 'radio':
|
||||||
case 'radio_horizontal':
|
case 'radio_horizontal':
|
||||||
case 'radio_vertical':
|
case 'radio_vertical':
|
||||||
$sValidationField = null;
|
$sInputType = CmdbAbstractObject::ENUM_INPUT_TYPE_RADIO;
|
||||||
|
$sValidationField = null;
|
||||||
|
|
||||||
$bVertical = ($sDisplayStyle != 'radio_horizontal');
|
$bVertical = ($sDisplayStyle != 'radio_horizontal');
|
||||||
$bExtensions = false;
|
$bExtensions = false;
|
||||||
$oAllowedValues->Rewind();
|
$oAllowedValues->Rewind();
|
||||||
$aAllowedValues = array();
|
$aAllowedValues = array();
|
||||||
while($oObj = $oAllowedValues->Fetch())
|
while ($oObj = $oAllowedValues->Fetch()) {
|
||||||
{
|
$aAllowedValues[$oObj->GetKey()] = $oObj->GetName();
|
||||||
$aAllowedValues[$oObj->GetKey()] = $oObj->GetName();
|
}
|
||||||
}
|
$sHTMLValue .= $oPage->GetRadioButtons($aAllowedValues, $value, $this->iId, "{$sAttrFieldPrefix}{$sFieldName}", false /* $bMandatory will be placed manually */, $bVertical, $sValidationField);
|
||||||
$sHTMLValue .= $oPage->GetRadioButtons($aAllowedValues, $value, $this->iId, "{$sAttrFieldPrefix}{$sFieldName}", false /* $bMandatory will be placed manually */, $bVertical, $sValidationField);
|
$aEventsList[] = 'change';
|
||||||
$aEventsList[] ='change';
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
case 'select':
|
case 'select':
|
||||||
case 'list':
|
case 'list':
|
||||||
default:
|
default:
|
||||||
|
$sHelpText = '';
|
||||||
|
$sHTMLValue .= "<div class=\"field_select_wrapper\">\n";
|
||||||
|
|
||||||
$sHelpText = ''; //$this->oAttDef->GetHelpOnEdition();
|
if ($this->bSearchMode) {
|
||||||
$sHTMLValue .= "<div class=\"field_select_wrapper\">\n";
|
if ($bSearchMultiple) {
|
||||||
|
$sHTMLValue .= "<select class=\"multiselect\" multiple title=\"$sHelpText\" name=\"{$sAttrFieldPrefix}{$sFieldName}[]\" id=\"$this->iId\">\n";
|
||||||
if ($this->bSearchMode)
|
} else {
|
||||||
{
|
$sHTMLValue .= "<select title=\"$sHelpText\" name=\"{$sAttrFieldPrefix}{$sFieldName}\" id=\"$this->iId\">\n";
|
||||||
if ($bSearchMultiple)
|
$sDisplayValue = isset($aArgs['sDefaultValue']) ? $aArgs['sDefaultValue'] : Dict::S('UI:SearchValue:Any');
|
||||||
{
|
$sHTMLValue .= "<option value=\"\">$sDisplayValue</option>\n";
|
||||||
$sHTMLValue .= "<select class=\"multiselect\" multiple title=\"$sHelpText\" name=\"{$sAttrFieldPrefix}{$sFieldName}[]\" id=\"$this->iId\">\n";
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$sHTMLValue .= "<select title=\"$sHelpText\" name=\"{$sAttrFieldPrefix}{$sFieldName}\" id=\"$this->iId\">\n";
|
$sHTMLValue .= "<select title=\"$sHelpText\" name=\"{$sAttrFieldPrefix}{$sFieldName}\" id=\"$this->iId\">\n";
|
||||||
$sDisplayValue = isset($aArgs['sDefaultValue']) ? $aArgs['sDefaultValue'] : Dict::S('UI:SearchValue:Any');
|
$sHTMLValue .= "<option value=\"\">".Dict::S('UI:SelectOne')."</option>\n";
|
||||||
$sHTMLValue .= "<option value=\"\">$sDisplayValue</option>\n";
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$sHTMLValue .= "<select title=\"$sHelpText\" name=\"{$sAttrFieldPrefix}{$sFieldName}\" id=\"$this->iId\">\n";
|
|
||||||
$sHTMLValue .= "<option value=\"\">".Dict::S('UI:SelectOne')."</option>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$oAllowedValues->Rewind();
|
$oAllowedValues->Rewind();
|
||||||
while($oObj = $oAllowedValues->Fetch())
|
while ($oObj = $oAllowedValues->Fetch()) {
|
||||||
{
|
$key = $oObj->GetKey();
|
||||||
$key = $oObj->GetKey();
|
$display_value = $oObj->GetName();
|
||||||
$display_value = $oObj->GetName();
|
|
||||||
|
|
||||||
if (($oAllowedValues->Count() == 1) && ($bMandatory == 'true') )
|
if (($oAllowedValues->Count() == 1) && ($bMandatory == 'true')) {
|
||||||
{
|
// When there is only once choice, select it by default
|
||||||
// When there is only once choice, select it by default
|
$sSelected = 'selected';
|
||||||
$sSelected = 'selected';
|
if ($value != $key) {
|
||||||
if($value != $key)
|
$oPage->add_ready_script(
|
||||||
{
|
<<<EOF
|
||||||
$oPage->add_ready_script(
|
|
||||||
<<<EOF
|
|
||||||
$('#$this->iId').attr('data-validate','dependencies');
|
$('#$this->iId').attr('data-validate','dependencies');
|
||||||
EOF
|
EOF
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$sSelected = (is_array($value) && in_array($key, $value)) || ($value == $key) ? 'selected' : '';
|
||||||
}
|
}
|
||||||
|
$sHTMLValue .= "<option value=\"$key\" $sSelected>$display_value</option>\n";
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$sSelected = (is_array($value) && in_array($key, $value)) || ($value == $key) ? 'selected' : '';
|
|
||||||
}
|
|
||||||
$sHTMLValue .= "<option value=\"$key\" $sSelected>$display_value</option>\n";
|
|
||||||
}
|
|
||||||
$sHTMLValue .= "</select>\n";
|
$sHTMLValue .= "</select>\n";
|
||||||
$sHTMLValue .= "</div>\n";
|
$sHTMLValue .= "</div>\n";
|
||||||
|
|
||||||
if (($this->bSearchMode) && $bSearchMultiple)
|
$sInputType = CmdbAbstractObject::ENUM_INPUT_TYPE_DROPDOWN_RAW;
|
||||||
{
|
if (($this->bSearchMode) && $bSearchMultiple) {
|
||||||
|
$sInputType = CmdbAbstractObject::ENUM_INPUT_TYPE_DROPDOWN_MULTIPLE_CHOICES;
|
||||||
$aOptions = array(
|
$aOptions = array(
|
||||||
'header' => true,
|
'header' => true,
|
||||||
'checkAllText' => Dict::S('UI:SearchValue:CheckAll'),
|
'checkAllText' => Dict::S('UI:SearchValue:CheckAll'),
|
||||||
@@ -560,36 +596,32 @@ EOF
|
|||||||
);
|
);
|
||||||
$sJSOptions = json_encode($aOptions);
|
$sJSOptions = json_encode($aOptions);
|
||||||
$oPage->add_ready_script("$('.multiselect').multiselect($sJSOptions);");
|
$oPage->add_ready_script("$('.multiselect').multiselect($sJSOptions);");
|
||||||
}
|
}
|
||||||
$oPage->add_ready_script(
|
$oPage->add_ready_script(
|
||||||
<<<EOF
|
<<<EOF
|
||||||
oACWidget_{$this->iId} = new ExtKeyWidget('{$this->iId}', '{$this->sTargetClass}', '$sFilter', '$sTitle', true, $sWizHelper, '{$this->sAttCode}', $sJSSearchMode, $sJSDoSearch);
|
oACWidget_{$this->iId} = new ExtKeyWidget('{$this->iId}', '{$this->sTargetClass}', '$sFilter', '$sTitle', true, $sWizHelper, '{$this->sAttCode}', $sJSSearchMode, $sJSDoSearch);
|
||||||
oACWidget_{$this->iId}.emptyHtml = "<div style=\"background: #fff; border:0; text-align:center; vertical-align:middle;\"><p>$sMessage</p></div>";
|
oACWidget_{$this->iId}.emptyHtml = "<div style=\"background: #fff; border:0; text-align:center; vertical-align:middle;\"><p>$sMessage</p></div>";
|
||||||
$('#$this->iId').bind('update', function() { oACWidget_{$this->iId}.Update(); } );
|
$('#$this->iId').bind('update', function() { oACWidget_{$this->iId}.Update(); } );
|
||||||
$('#$this->iId').bind('change', function() { $(this).trigger('extkeychange') } );
|
$('#$this->iId').bind('change', function() { $(this).trigger('extkeychange') } );
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
);
|
);
|
||||||
} // Switch
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
// Too many choices, use an autocomplete
|
// Too many choices, use an autocomplete
|
||||||
|
$sInputType = CmdbAbstractObject::ENUM_INPUT_TYPE_AUTOCOMPLETE;
|
||||||
// Check that the given value is allowed
|
// Check that the given value is allowed
|
||||||
$oSearch = $oAllowedValues->GetFilter();
|
$oSearch = $oAllowedValues->GetFilter();
|
||||||
$oSearch->AddCondition('id', $value);
|
$oSearch->AddCondition('id', $value);
|
||||||
$oSet = new DBObjectSet($oSearch);
|
$oSet = new DBObjectSet($oSearch);
|
||||||
if ($oSet->Count() == 0)
|
if ($oSet->Count() == 0) {
|
||||||
{
|
|
||||||
$value = null;
|
$value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($value) || ($value == 0)) // Null values are displayed as ''
|
if (is_null($value) || ($value == 0)) // Null values are displayed as ''
|
||||||
{
|
{
|
||||||
$sDisplayValue = isset($aArgs['sDefaultValue']) ? $aArgs['sDefaultValue'] : '';
|
$sDisplayValue = isset($aArgs['sDefaultValue']) ? $aArgs['sDefaultValue'] : '';
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
$sDisplayValue = $this->GetObjectName($value);
|
$sDisplayValue = $this->GetObjectName($value);
|
||||||
}
|
}
|
||||||
$iMinChars = isset($aArgs['iMinChars']) ? $aArgs['iMinChars'] : 2; //@@@ $this->oAttDef->GetMinAutoCompleteChars();
|
$iMinChars = isset($aArgs['iMinChars']) ? $aArgs['iMinChars'] : 2; //@@@ $this->oAttDef->GetMinAutoCompleteChars();
|
||||||
@@ -615,33 +647,31 @@ EOF
|
|||||||
EOF
|
EOF
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ($bExtensions && MetaModel::IsHierarchicalClass($this->sTargetClass) !== false)
|
if ($bExtensions && MetaModel::IsHierarchicalClass($this->sTargetClass) !== false) {
|
||||||
{
|
|
||||||
$sHTMLValue .= "<span class=\"field_input_btn\"><div class=\"ibo-input-select--action-button\" id=\"mini_tree_{$this->iId}\" onClick=\"oACWidget_{$this->iId}.HKDisplay();\"><i class=\"fas fa-sitemap\"></i></div></span>";
|
$sHTMLValue .= "<span class=\"field_input_btn\"><div class=\"ibo-input-select--action-button\" id=\"mini_tree_{$this->iId}\" onClick=\"oACWidget_{$this->iId}.HKDisplay();\"><i class=\"fas fa-sitemap\"></i></div></span>";
|
||||||
$oPage->add_ready_script(
|
$oPage->add_ready_script(
|
||||||
<<<JS
|
<<<JS
|
||||||
if ($('#ac_tree_{$this->iId}').length == 0)
|
if ($('#ac_tree_{$this->iId}').length == 0)
|
||||||
{
|
{
|
||||||
$('body').append('<div id="ac_tree_{$this->iId}"></div>');
|
$('body').append('<div id="ac_tree_{$this->iId}"></div>');
|
||||||
}
|
}
|
||||||
JS
|
JS
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if ($bCreate && $bExtensions)
|
if ($bCreate && $bExtensions) {
|
||||||
{
|
|
||||||
$sCallbackName = (MetaModel::IsAbstract($this->sTargetClass)) ? 'SelectObjectClass' : 'CreateObject';
|
$sCallbackName = (MetaModel::IsAbstract($this->sTargetClass)) ? 'SelectObjectClass' : 'CreateObject';
|
||||||
|
|
||||||
$sHTMLValue .= "<span class=\"field_input_btn\"><div class=\"ibo-input-select--action-button\" id=\"mini_add_{$this->iId}\" onClick=\"oACWidget_{$this->iId}.{$sCallbackName}();\"><i class=\"fas fa-plus\"></i></div></span>";
|
$sHTMLValue .= "<span class=\"field_input_btn\"><div class=\"ibo-input-select--action-button\" id=\"mini_add_{$this->iId}\" onClick=\"oACWidget_{$this->iId}.{$sCallbackName}();\"><i class=\"fas fa-plus\"></i></div></span>";
|
||||||
$oPage->add_ready_script(
|
$oPage->add_ready_script(
|
||||||
<<<JS
|
<<<JS
|
||||||
if ($('#ajax_{$this->iId}').length == 0)
|
if ($('#ajax_{$this->iId}').length == 0)
|
||||||
{
|
{
|
||||||
$('body').append('<div id="ajax_{$this->iId}"></div>');
|
$('body').append('<div id="ajax_{$this->iId}"></div>');
|
||||||
}
|
}
|
||||||
JS
|
JS
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$sHTMLValue .= "</div>";
|
$sHTMLValue .= "</div>";
|
||||||
$sHTMLValue .= "<span class=\"form_validation ibo-field-validation\" id=\"v_{$this->iId}\"></span><span class=\"field_status\" id=\"fstatus_{$this->iId}\"></span>";
|
$sHTMLValue .= "<span class=\"form_validation ibo-field-validation\" id=\"v_{$this->iId}\"></span><span class=\"field_status\" id=\"fstatus_{$this->iId}\"></span>";
|
||||||
|
|
||||||
return $sHTMLValue;
|
return $sHTMLValue;
|
||||||
|
|||||||
@@ -345,4 +345,9 @@ class Field extends UIContentBlock
|
|||||||
{
|
{
|
||||||
$this->AddDataAttribute('input-id', $sInputId);
|
$this->AddDataAttribute('input-id', $sInputId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function SetInputType(string $sInputType)
|
||||||
|
{
|
||||||
|
$this->AddDataAttribute('input-type', $sInputType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -32,6 +32,7 @@ class FieldUIBlockFactory extends AbstractUIBlockFactory
|
|||||||
'value_raw' => 'SetValueRaw',
|
'value_raw' => 'SetValueRaw',
|
||||||
'comments' => 'SetComments',
|
'comments' => 'SetComments',
|
||||||
'input_id' => 'SetInputId',
|
'input_id' => 'SetInputId',
|
||||||
|
'input_type' => 'SetInputType',
|
||||||
];
|
];
|
||||||
foreach ($aParamsMapping as $sParamKey => $sFieldMethod) {
|
foreach ($aParamsMapping as $sParamKey => $sFieldMethod) {
|
||||||
self::UpdateFieldFromParams($oField, $sFieldMethod, $aParams, $sParamKey);
|
self::UpdateFieldFromParams($oField, $sFieldMethod, $aParams, $sParamKey);
|
||||||
|
|||||||
Reference in New Issue
Block a user