mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-18 23:08:46 +02:00
N°3123 - Moved Popup Menu Items JS parts to UIBlocks
This commit is contained in:
@@ -1510,6 +1510,8 @@ class MenuBlock extends DisplayBlock
|
||||
*/
|
||||
public function GetRenderContent(WebPage $oPage, array $aExtraParams = [], string $sId = null): iUIBlock
|
||||
{
|
||||
$oRenderBlock = new UIContentBlock();
|
||||
|
||||
if ($this->m_sStyle == 'popup') // popup is a synonym of 'list' for backward compatibility
|
||||
{
|
||||
$this->m_sStyle = 'list';
|
||||
@@ -1517,7 +1519,7 @@ class MenuBlock extends DisplayBlock
|
||||
$sClass = $this->m_oFilter->GetClass();
|
||||
$oSet = new CMDBObjectSet($this->m_oFilter);
|
||||
$sRefreshAction = '';
|
||||
if ((!isset($aExtraParams['selection_mode']) || $aExtraParams['selection_mode'] == "") && $this->m_sStyle!= 'listInObject') {
|
||||
if ((!isset($aExtraParams['selection_mode']) || $aExtraParams['selection_mode'] == "") && $this->m_sStyle != 'listInObject') {
|
||||
$oAppContext = new ApplicationContext();
|
||||
$sContext = $oAppContext->GetForLink();
|
||||
if (!empty($sContext)) {
|
||||
@@ -1813,8 +1815,7 @@ class MenuBlock extends DisplayBlock
|
||||
//for the detail page this var is defined way beyond this line
|
||||
$sRefreshAction = "window.location.reload();";
|
||||
}
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
//it's easier just display configure this list and MENU_OBJLIST_TOOLKIT
|
||||
}
|
||||
$param = null;
|
||||
@@ -1837,7 +1838,7 @@ class MenuBlock extends DisplayBlock
|
||||
if ($bToolkitMenu) {
|
||||
$sLabel = Dict::S('UI:ConfigureThisList');
|
||||
$aActions['iTop::ConfigureList'] = ['label' => $sLabel, 'url' => '#', 'onclick' => "$('#datatable_dlg_datatable_{$sId}').dialog('open');"];
|
||||
utils::GetPopupMenuItems($oPage, iPopupMenuExtension::MENU_OBJLIST_TOOLKIT, $param, $aActions);
|
||||
$oRenderBlock->AddSubBlock(utils::GetPopupMenuItemsBlock(iPopupMenuExtension::MENU_OBJLIST_TOOLKIT, $param, $aActions));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1848,7 +1849,7 @@ class MenuBlock extends DisplayBlock
|
||||
break;
|
||||
|
||||
}
|
||||
utils::GetPopupMenuItems($oPage, $iMenuId, $param, $aActions);
|
||||
$oRenderBlock->AddSubBlock(utils::GetPopupMenuItemsBlock($iMenuId, $param, $aActions));
|
||||
|
||||
$aFavoriteActions = array();
|
||||
$aCallSpec = array($sClass, 'GetShortcutActions');
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
*/
|
||||
|
||||
use Combodo\iTop\Application\UI\Layout\UIContentBlock;
|
||||
use ScssPhp\ScssPhp\Compiler;
|
||||
|
||||
|
||||
@@ -1158,13 +1159,33 @@ class utils
|
||||
* @param int $iMenuId
|
||||
* @param \DBObjectSet $param
|
||||
* @param array $aActions
|
||||
* @param string $sTableId
|
||||
* @param string $sDataTableId
|
||||
* @param string|null $sTableId
|
||||
* @param string|null $sDataTableId
|
||||
*
|
||||
* @throws \Exception
|
||||
* @throws \ArchivedObjectException
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public static function GetPopupMenuItems($oPage, $iMenuId, $param, &$aActions, $sTableId = null, $sDataTableId = null)
|
||||
{
|
||||
$oPage->AddUiBlock(static::GetPopupMenuItemsBlock($iMenuId, $param, $aActions, $sDataTableId));
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge standard menu items with plugin provided menus items
|
||||
*
|
||||
* @param int $iMenuId
|
||||
* @param \DBObjectSet $param
|
||||
* @param array $aActions
|
||||
* @param string|null $sDataTableId
|
||||
*
|
||||
* @return \Combodo\iTop\Application\UI\Layout\UIContentBlock
|
||||
* @throws \ArchivedObjectException
|
||||
* @throws \CoreException
|
||||
*/
|
||||
public static function GetPopupMenuItemsBlock($iMenuId, $param, &$aActions, $sDataTableId = null)
|
||||
{
|
||||
$oBlock = new UIContentBlock();
|
||||
$aActions = [];
|
||||
// 1st - add standard built-in menu items
|
||||
//
|
||||
switch($iMenuId)
|
||||
@@ -1178,9 +1199,9 @@ class utils
|
||||
$sOQL = addslashes($param->GetFilter()->ToOQL(true));
|
||||
$sFilter = urlencode($param->GetFilter()->serialize());
|
||||
$sUrl = utils::GetAbsoluteUrlAppRoot()."pages/$sUIPage?operation=search&filter=".$sFilter."&{$sContext}";
|
||||
$oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/tabularfieldsselector.js');
|
||||
$oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery.dragtable.js');
|
||||
$oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/dragtable.css');
|
||||
$oBlock->AddJsFileRelPath(utils::GetAbsoluteUrlAppRoot().'js/tabularfieldsselector.js');
|
||||
$oBlock->AddJsFileRelPath(utils::GetAbsoluteUrlAppRoot().'js/jquery.dragtable.js');
|
||||
$oBlock->AddCssFileRelPath(utils::GetAbsoluteUrlAppRoot().'css/dragtable.css');
|
||||
|
||||
$aResult = array();
|
||||
if (strlen($sUrl) < SERVER_MAX_URL_LENGTH)
|
||||
@@ -1213,12 +1234,12 @@ class utils
|
||||
$oObj = $param;
|
||||
$sOQL = "SELECT ".get_class($oObj)." WHERE id=".$oObj->GetKey();
|
||||
$sUrl = ApplicationContext::MakeObjectUrl(get_class($oObj), $oObj->GetKey());
|
||||
$oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/tabularfieldsselector.js');
|
||||
$oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery.dragtable.js');
|
||||
$oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/dragtable.css');
|
||||
$oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/tabularfieldsselector.js');
|
||||
$oPage->add_linked_script(utils::GetAbsoluteUrlAppRoot().'js/jquery.dragtable.js');
|
||||
$oPage->add_linked_stylesheet(utils::GetAbsoluteUrlAppRoot().'css/dragtable.css');
|
||||
$oBlock->AddJsFileRelPath(utils::GetAbsoluteUrlAppRoot().'js/tabularfieldsselector.js');
|
||||
$oBlock->AddJsFileRelPath(utils::GetAbsoluteUrlAppRoot().'js/jquery.dragtable.js');
|
||||
$oBlock->AddCssFileRelPath(utils::GetAbsoluteUrlAppRoot().'css/dragtable.css');
|
||||
$oBlock->AddJsFileRelPath(utils::GetAbsoluteUrlAppRoot().'js/tabularfieldsselector.js');
|
||||
$oBlock->AddJsFileRelPath(utils::GetAbsoluteUrlAppRoot().'js/jquery.dragtable.js');
|
||||
$oBlock->AddCssFileRelPath(utils::GetAbsoluteUrlAppRoot().'css/dragtable.css');
|
||||
|
||||
$aResult = array(
|
||||
new SeparatorPopupMenuItem(),
|
||||
@@ -1287,11 +1308,13 @@ class utils
|
||||
|
||||
foreach($oMenuItem->GetLinkedScripts() as $sLinkedScript)
|
||||
{
|
||||
$oPage->add_linked_script($sLinkedScript);
|
||||
$oBlock->AddJsFileRelPath($sLinkedScript);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $oBlock;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -64,6 +64,11 @@ abstract class UIBlock implements iUIBlock
|
||||
/** @var string $sId */
|
||||
protected $sId;
|
||||
|
||||
/** @var array */
|
||||
protected $aJsFilesRelPath;
|
||||
/** @var array */
|
||||
protected $aCssFilesRelPath;
|
||||
|
||||
/**
|
||||
* UIBlock constructor.
|
||||
*
|
||||
@@ -72,6 +77,8 @@ abstract class UIBlock implements iUIBlock
|
||||
public function __construct(?string $sId = null)
|
||||
{
|
||||
$this->sId = $sId ?? $this->GenerateId();
|
||||
$this->aJsFilesRelPath = [];
|
||||
$this->aCssFilesRelPath = [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -99,7 +106,7 @@ abstract class UIBlock implements iUIBlock
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function GetJsFilesRelPaths() {
|
||||
public function GetJsFilesRelPaths() {
|
||||
return static::JS_FILES_REL_PATH;
|
||||
}
|
||||
|
||||
@@ -114,9 +121,9 @@ abstract class UIBlock implements iUIBlock
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public static function GetCssFilesRelPaths()
|
||||
public function GetCssFilesRelPaths()
|
||||
{
|
||||
return static::CSS_FILES_REL_PATH;
|
||||
return array_merge(static::CSS_FILES_REL_PATH, $this->aCssFilesRelPath);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,6 +208,24 @@ abstract class UIBlock implements iUIBlock
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function AddJsFileRelPath(string $sPath)
|
||||
{
|
||||
$this->aJsFilesRelPath[] = $sPath;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function AddCssFileRelPath(string $sPath)
|
||||
{
|
||||
$this->aCssFilesRelPath[] = $sPath;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* **Warning**, this shouldn't generate any dot as this will be used in CSS and JQuery selectors !
|
||||
*
|
||||
@@ -229,7 +254,7 @@ abstract class UIBlock implements iUIBlock
|
||||
$sFilesRelPathMethodName = 'Get'.ucfirst($sFileType).'FilesRelPaths';
|
||||
|
||||
// Files from the block itself
|
||||
foreach ($this::$sFilesRelPathMethodName() as $sFilePath) {
|
||||
foreach ($this->$sFilesRelPathMethodName() as $sFilePath) {
|
||||
$aFiles[] = (($bAbsoluteUrl === true) ? utils::GetAbsoluteUrlAppRoot() : '').$sFilePath;
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ interface iUIBlock {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function GetJsFilesRelPaths();
|
||||
public function GetJsFilesRelPaths();
|
||||
|
||||
/**
|
||||
* Return the relative path (from <ITOP>/templates/) of the CSS template to use or null if there is no inline CSS to render
|
||||
@@ -69,7 +69,7 @@ interface iUIBlock {
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function GetCssFilesRelPaths();
|
||||
public function GetCssFilesRelPaths();
|
||||
|
||||
/**
|
||||
* Return the ID of the block
|
||||
@@ -130,4 +130,23 @@ interface iUIBlock {
|
||||
* @return array
|
||||
*/
|
||||
public function GetParameters(): array;
|
||||
|
||||
/**
|
||||
* Add a JS file to a block
|
||||
*
|
||||
* @param string $sPath
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function AddJsFileRelPath(string $sPath);
|
||||
|
||||
/**
|
||||
* Add a CSS file to a block
|
||||
*
|
||||
* @param string $sPath
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function AddCssFileRelPath(string $sPath);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user