diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 3cdf07069..4f3c450e3 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -80,6 +80,35 @@ abstract class cmdbAbstractObject extends CMDBObject implements iDisplay public const ENUM_OBJECT_MODE_STIMULUS = 'stimulus'; /** @var string ENUM_OBJECT_MODE_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 * @since 3.0.0 @@ -854,6 +883,7 @@ EOF if ((!$oAttDef->IsLinkSet()) && (($iFlags & OPT_ATT_HIDDEN) == 0) && !($oAttDef instanceof AttributeDashboard)) { $sInputId = $this->m_iFormId.'_'.$sAttCode; if ($oAttDef->IsWritable()) { + $sInputType = ''; if (($sStateAttCode === $sAttCode) && (MetaModel::HasLifecycle($sClass))) { // State attribute is always read-only from the UI $sHTMLValue = $this->GetAsHTML($sAttCode); @@ -887,15 +917,15 @@ EOF // Attribute is read-only $sHTMLValue = "".$this->GetAsHTML($sAttCode).''; - } - else - { + } else { $sValue = $this->Get($sAttCode); $sDisplayValue = $this->GetEditValue($sAttCode); $aArgs = array('this' => $this, 'formPrefix' => $sPrefix); - $sHTMLValue = "".self::GetFormElementForField($oPage, $sClass, $sAttCode, - $oAttDef, $sValue, $sDisplayValue, $sInputId, '', $iFlags, - $aArgs).''; + $sHTMLValue = "".self::GetFormElementForField( + $oPage, $sClass, $sAttCode, $oAttDef, $sValue, + $sDisplayValue, $sInputId, '', $iFlags, $aArgs, + true, $sInputType + ).''; } $aFieldsMap[$sAttCode] = $sInputId; @@ -908,6 +938,7 @@ EOF 'label' => ''.$oAttDef->GetLabel().'', 'value' => $sHTMLValue, 'input_id' => $sInputId, + 'input_type' => $sInputType, 'comments' => $sComments, 'infos' => $sInfos, ); @@ -1748,6 +1779,7 @@ HTML return $oSearchForm->GetSearchForm($oPage, $oSet, $aExtraParams); } + /** * @param \WebPage $oPage * @param string $sClass @@ -1760,38 +1792,43 @@ HTML * @param int $iFlags * @param array $aArgs * @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 + * * @throws \ArchivedObjectException + * @throws \ConfigException * @throws \CoreException + * @throws \CoreUnexpectedValue * @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'] : ''; $sFieldPrefix = isset($aArgs['prefix']) ? $sFormPrefix.$aArgs['prefix'] : $sFormPrefix; - if ($sDisplayValue == '') - { + if ($sDisplayValue == '') { $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) $value = $aArgs[$sAttCode]; } - if (!empty($iId)) - { + if (!empty($iId)) { $iInputId = $iId; - } - else { + } else { $iInputId = utils::GetUniqueId(); } $sHTMLValue = ''; - if (!$oAttDef->IsExternalField()) - { + if (!$oAttDef->IsExternalField()) { $bMandatory = 'false'; if ((!$oAttDef->IsNullAllowed()) || ($iFlags & OPT_ATT_MANDATORY)) { $bMandatory = 'true'; @@ -1813,6 +1850,7 @@ HTML switch ($oAttDef->GetEditClass()) { case 'Date': + $sInputType = self::ENUM_INPUT_TYPE_SINGLE_INPUT; $aEventsList[] = 'validate'; $aEventsList[] = 'keyup'; $aEventsList[] = 'change'; @@ -1824,6 +1862,7 @@ HTML break; case 'DateTime': + $sInputType = self::ENUM_INPUT_TYPE_SINGLE_INPUT; $aEventsList[] = 'validate'; $aEventsList[] = 'keyup'; $aEventsList[] = 'change'; @@ -1835,6 +1874,7 @@ HTML break; case 'Duration': + $sInputType = self::ENUM_INPUT_TYPE_MULTIPLE_INPUTS; $aEventsList[] = 'validate'; $aEventsList[] = 'change'; $oPage->add_ready_script("$('#{$iId}_d').bind('keyup change', function(evt, sFormId) { return UpdateDuration('$iId'); });"); @@ -1854,6 +1894,7 @@ HTML break; case 'Password': + $sInputType = self::ENUM_INPUT_TYPE_PASSWORD; $aEventsList[] = 'validate'; $aEventsList[] = 'keyup'; $aEventsList[] = 'change'; @@ -1863,6 +1904,7 @@ HTML case 'OQLExpression': case 'Text': + $sInputType = self::ENUM_INPUT_TYPE_TEXTAREA; $aEventsList[] = 'validate'; $aEventsList[] = 'keyup'; $aEventsList[] = 'change'; @@ -1871,22 +1913,19 @@ HTML $aStyles = array(); $sStyle = ''; $sWidth = $oAttDef->GetWidth(); - if (!empty($sWidth)) - { + if (!empty($sWidth)) { $aStyles[] = 'width:'.$sWidth; } $sHeight = $oAttDef->GetHeight(); - if (!empty($sHeight)) - { + if (!empty($sHeight)) { $aStyles[] = 'height:'.$sHeight; } - if (count($aStyles) > 0) - { + if (count($aStyles) > 0) { $sStyle = 'style="'.implode('; ', $aStyles).'"'; } if ($oAttDef->GetEditClass() == 'OQLExpression') { - // predefined queries N°3227 + // N°3227 button to open predefined queries dialog $sPredefinedBtnId = 'predef_btn_'.$sFieldPrefix.$sAttCode.$sNameSuffix; $sSearchQueryLbl = Dict::S('UI:Edit:SearchQuery'); $oPredefQueryButton = ButtonUIBlockFactory::MakeIconLink( @@ -1951,12 +1990,12 @@ JS } else { $sAdditionalStuff = ''; } - // Ok, the text area is drawn here - $sHTMLValue = "$sAdditionalStuff