diff --git a/application/ui.extkeywidget.class.inc.php b/application/ui.extkeywidget.class.inc.php index 5ca0e3a81..6426ddf51 100644 --- a/application/ui.extkeywidget.class.inc.php +++ b/application/ui.extkeywidget.class.inc.php @@ -636,14 +636,22 @@ HTML $oSet->SetShowObsoleteData(utils::ShowObsoleteData()); $sHKAttCode = MetaModel::IsHierarchicalClass($this->sTargetClass); - $this->DumpTree($oPage, $oSet, $sHKAttCode, $currValue); + $bHasChildLeafs = $this->DumpTree($oPage, $oSet, $sHKAttCode, $currValue); $oPage->add(''); $oPage->add(''); + + if ($bHasChildLeafs) + { + $oPage->add('
'); + } + $oPage->add("iId}\" value=\"".Dict::S('UI:Button:Cancel')."\" onClick=\"$('#dlg_tree_{$this->iId}').dialog('close');\"> "); $oPage->add("iId}\" value=\"".Dict::S('UI:Button:Ok')."\" onClick=\"oACWidget_{$this->iId}.DoHKOk();\">"); $oPage->add(''); + + $oPage->add_ready_script("\$('#tree_$this->iId ul').treeview({ control: '#treecontrolid', persist: 'false'});\n"); $oPage->add_ready_script("\$('#tree_$this->iId ul').treeview();\n"); $oPage->add_ready_script("\$('#dlg_tree_$this->iId').dialog({ width: 'auto', height: 'auto', autoOpen: true, modal: true, title: '$sDialogTitle', resizeStop: oACWidget_{$this->iId}.OnHKResize, close: oACWidget_{$this->iId}.OnHKClose });\n"); } @@ -673,6 +681,18 @@ HTML } } + /** + * @param WebPage $oP + * @param \DBObjectSet $oSet + * @param string $sParentAttCode + * @param string $currValue + * + * @return bool true if there are at least one child leaf, false if only roots nodes are present + * @throws \ArchivedObjectException + * @throws \CoreException + * @throws \CoreUnexpectedValue + * @throws \MySQLException + */ function DumpTree($oP, $oSet, $sParentAttCode, $currValue) { $aTree = array(); @@ -701,6 +721,9 @@ HTML { $this->DumpNodes($oP, $iRootId, $aTree, $aNodes, $currValue); } + + $bHasOnlyRootNodes = (count($aTree) === 1); + return !$bHasOnlyRootNodes; } function DumpNodes($oP, $iRootId, $aTree, $aNodes, $currValue) @@ -728,7 +751,7 @@ HTML $sSelect = ' '; } } - $oP->add('