diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index a0cbf37d5..37a6908da 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -475,6 +475,22 @@ abstract class cmdbAbstractObject extends CMDBObject } $sHtml .= ''; $sColspan = ''; + if ($bDisplayLimit && ($oSet->Count() > utils::GetConfig()->GetMaxDisplayLimit())) + { + // list truncated + $divId = $aExtraParams['block_id']; + $sFilter = $oSet->GetFilter()->serialize(); + $aExtraParams['display_limit'] = false; // To expand the full list + $sExtraParams = addslashes(str_replace('"', "'", json_encode($aExtraParams))); // JSON encode, change the style of the quotes and escape them + $sHtml .= ''; } @@ -1218,6 +1218,30 @@ EOF { $oObj = clone $oObjectToClone; } + // Pre-fill the object with default values, when there is only on possible choice + // AND the field is mandatory (otherwise there is always the possiblity to let it empty) + $aArgs['this'] = $oObj; + $aDetailsList = self::FLattenZList(MetaModel::GetZListItems($sClass, 'details')); + // TO DO: the list should be ordered based on the dependencies between fields + // i.e. if some fields depend on another field, the latter should be computed first... + // Right now we depend on the display order... anyhow if the display order does not + // reflect the dependency order, the UI will not be so intuitive to use... beware + foreach($aDetailsList as $sAttCode) + { + $bMandatory = false; + $aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, $aArgs); + if (count($aAllowedValues) == 1) + { + // If the field is mandatory, set it to the only possible value + $oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode); + $iFlags = $oObj->GetAttributeFlags($sAttCode); + if ( (!$oAttDef->IsNullAllowed()) || ($iFlags & OPT_ATT_MANDATORY)) + { + $aValues = array_keys($aAllowedValues); + $oObj->Set($sAttCode, $aValues[0]); + } + } + } return $oObj->DisplayModifyForm( $oPage, $aExtraParams = array()); }
'.Dict::Format('UI:TruncatedResults', utils::GetConfig()->GetMinDisplayLimit(), $oSet->Count()).'  '.Dict::S('UI:DisplayAll').''; + $oPage->add_ready_script("$('#{$divId} table.listResults').addClass('truncated');"); + $oPage->add_ready_script("$('#{$divId} table.listResults tr:last td').addClass('truncated');"); + } + else + { + // Full list + $sHtml .= '
 '.Dict::Format('UI:CountOfResults', $oSet->Count()).''; + } if ($bDisplayMenu) { $oMenuBlock = new MenuBlock($oSet->GetFilter()); @@ -485,22 +501,6 @@ abstract class cmdbAbstractObject extends CMDBObject //$aMenuExtraParams['linkage'] = $sLinkageAttribute; $aMenuExtraParams = $aExtraParams; } - if ($bDisplayLimit && ($oSet->Count() > utils::GetConfig()->GetMaxDisplayLimit())) - { - // list truncated - $divId = $aExtraParams['block_id']; - $sFilter = $oSet->GetFilter()->serialize(); - $aExtraParams['display_limit'] = false; // To expand the full list - $sExtraParams = addslashes(str_replace('"', "'", json_encode($aExtraParams))); // JSON encode, change the style of the quotes and escape them - $sHtml .= '
'.Dict::Format('UI:TruncatedResults', utils::GetConfig()->GetMinDisplayLimit(), $oSet->Count()).'  '.Dict::S('UI:DisplayAll').''; - $oPage->add_ready_script("$('#{$divId} table.listResults').addClass('truncated');"); - $oPage->add_ready_script("$('#{$divId} table.listResults tr:last td').addClass('truncated');"); - } - else - { - // Full list - $sHtml .= '
 '.Dict::Format('UI:CountOfResults', $oSet->Count()).''; - } $sHtml .= $oMenuBlock->GetRenderContent($oPage, $aMenuExtraParams); $sHtml .= '