N°3914 - Fix "toolkit" actions not being displayed in the menu

This commit is contained in:
Molkobain
2021-05-04 11:47:37 +02:00
parent 18b2e54581
commit e488ec8c38
2 changed files with 32 additions and 19 deletions

View File

@@ -12,6 +12,7 @@ use Combodo\iTop\Application\UI\Base\Component\DataTable\DataTableUIBlockFactory
use Combodo\iTop\Application\UI\Base\Component\Html\Html;
use Combodo\iTop\Application\UI\Base\Component\Pill\PillFactory;
use Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenu;
use Combodo\iTop\Application\UI\Base\Component\PopoverMenu\PopoverMenuItem\PopoverMenuItemFactory;
use Combodo\iTop\Application\UI\Base\Component\Toolbar\Separator\ToolbarSeparatorUIBlockFactory;
use Combodo\iTop\Application\UI\Base\Component\Toolbar\ToolbarUIBlockFactory;
use Combodo\iTop\Application\UI\Base\iUIBlock;
@@ -1820,6 +1821,8 @@ class MenuBlock extends DisplayBlock
$aRegularActions = [];
/** @var array $aTransitionActions Only transitions */
$aTransitionActions = [];
/** @var array $aToolkitActions Any "legacy" toolkit menu item, which are now displayed in the same menu as the $aRegularActions, after them */
$aToolkitActions = [];
if ((!isset($aExtraParams['selection_mode']) || $aExtraParams['selection_mode'] == "") && $this->m_sStyle != 'listInObject') {
$oAppContext = new ApplicationContext();
$sContext = $oAppContext->GetForLink();
@@ -2144,7 +2147,7 @@ class MenuBlock extends DisplayBlock
$sLabel = Dict::S('UI:ConfigureThisList');
$aRegularActions['iTop::ConfigureList'] = ['label' => $sLabel, 'url' => '#', 'onclick' => "$('#datatable_dlg_datatable_{$sId}').dialog('open'); return false;"];
}
break;
break;
case 'details':
$oSet->Rewind();
@@ -2153,8 +2156,10 @@ class MenuBlock extends DisplayBlock
break;
}
$oPopupMenuItemsBlock = utils::GetPopupMenuItemsBlock($iMenuId, $param, $aRegularActions, $sId);
if($oPopupMenuItemsBlock->HasSubBlocks()) {
$oPopupMenuItemsBlock = new UIContentBlock();
utils::GetPopupMenuItemsBlock($oPopupMenuItemsBlock, $iMenuId, $param, $aRegularActions, $sId);
utils::GetPopupMenuItemsBlock($oPopupMenuItemsBlock, iPopupMenuExtension::MENU_OBJLIST_TOOLKIT, $param, $aToolkitActions, $sId);
if ($oPopupMenuItemsBlock->HasSubBlocks()) {
$oRenderBlock->AddSubBlock($oPopupMenuItemsBlock);
}
@@ -2287,7 +2292,7 @@ class MenuBlock extends DisplayBlock
}
// - Others
if (!empty($aRegularActions)) {
if (!empty($aRegularActions) || !empty($aToolkitActions)) {
if (count($aFavoriteRegularActions) > 0) {
$sName = 'UI:Menu:OtherActions';
} else {
@@ -2302,6 +2307,13 @@ class MenuBlock extends DisplayBlock
$oActionsToolbar->AddSubBlock($oActionButton)
->AddSubBlock($oRegularActionsMenu);
// Toolkit actions
if (!empty($aToolkitActions)) {
foreach ($aToolkitActions as $sActionId => $aActionData) {
$oRegularActionsMenu->AddItem('toolkit-actions', PopoverMenuItemFactory::MakeFromDisplayBlockAction($sActionId, $aActionData));
}
}
}
}

View File

@@ -17,6 +17,7 @@
* You should have received a copy of the GNU Affero General Public License
*/
use Combodo\iTop\Application\UI\Base\iUIBlock;
use Combodo\iTop\Application\UI\Base\Layout\UIContentBlock;
use ScssPhp\ScssPhp\Compiler;
@@ -1310,12 +1311,15 @@ class utils
*/
public static function GetPopupMenuItems($oPage, $iMenuId, $param, &$aActions, $sTableId = null, $sDataTableId = null)
{
$oPage->AddUiBlock(static::GetPopupMenuItemsBlock($iMenuId, $param, $aActions, $sDataTableId));
$oBlock = new UIContentBlock();
static::GetPopupMenuItemsBlock($oBlock, $iMenuId, $param, $aActions, $sDataTableId);
$oPage->AddUiBlock($oBlock);
}
/**
* Merge standard menu items with plugin provided menus items
*
* @param \Combodo\iTop\Application\UI\Base\iUIBlock $oContainerBlock The UIBlock containing the menu
* @param int $iMenuId
* @param \DBObjectSet $param
* @param array $aActions
@@ -1325,9 +1329,8 @@ class utils
* @throws \ArchivedObjectException
* @throws \CoreException
*/
public static function GetPopupMenuItemsBlock($iMenuId, $param, &$aActions, $sDataTableId = null)
public static function GetPopupMenuItemsBlock(iUIBlock &$oContainerBlock, $iMenuId, $param, &$aActions, $sDataTableId = null)
{
$oBlock = new UIContentBlock();
// 1st - add standard built-in menu items
//
switch($iMenuId)
@@ -1341,9 +1344,9 @@ class utils
$sOQL = addslashes($param->GetFilter()->ToOQL(true));
$sFilter = urlencode($param->GetFilter()->serialize());
$sUrl = utils::GetAbsoluteUrlAppRoot()."pages/$sUIPage?operation=search&filter=".$sFilter."&{$sContext}";
$oBlock->AddJsFileRelPath('js/tabularfieldsselector.js');
$oBlock->AddJsFileRelPath('js/jquery.dragtable.js');
$oBlock->AddCssFileRelPath('css/dragtable.css');
$oContainerBlock->AddJsFileRelPath('js/tabularfieldsselector.js');
$oContainerBlock->AddJsFileRelPath('js/jquery.dragtable.js');
$oContainerBlock->AddCssFileRelPath('css/dragtable.css');
$aResult = array();
if (strlen($sUrl) < SERVER_MAX_URL_LENGTH)
@@ -1376,12 +1379,12 @@ class utils
$oObj = $param;
$sOQL = "SELECT ".get_class($oObj)." WHERE id=".$oObj->GetKey();
$sUrl = ApplicationContext::MakeObjectUrl(get_class($oObj), $oObj->GetKey());
$oBlock->AddJsFileRelPath('js/tabularfieldsselector.js');
$oBlock->AddJsFileRelPath('js/jquery.dragtable.js');
$oBlock->AddCssFileRelPath('css/dragtable.css');
$oBlock->AddJsFileRelPath('js/tabularfieldsselector.js');
$oBlock->AddJsFileRelPath('js/jquery.dragtable.js');
$oBlock->AddCssFileRelPath('css/dragtable.css');
$oContainerBlock->AddJsFileRelPath('js/tabularfieldsselector.js');
$oContainerBlock->AddJsFileRelPath('js/jquery.dragtable.js');
$oContainerBlock->AddCssFileRelPath('css/dragtable.css');
$oContainerBlock->AddJsFileRelPath('js/tabularfieldsselector.js');
$oContainerBlock->AddJsFileRelPath('js/jquery.dragtable.js');
$oContainerBlock->AddCssFileRelPath('css/dragtable.css');
$aResult = array(
new SeparatorPopupMenuItem(),
@@ -1449,13 +1452,11 @@ class utils
foreach($oMenuItem->GetLinkedScripts() as $sLinkedScript)
{
$oBlock->AddJsFileRelPath($sLinkedScript);
$oContainerBlock->AddJsFileRelPath($sLinkedScript);
}
}
}
}
return $oBlock;
}
/**