N°2847 - Code clean up

* Fix TWIG exceptions due non existent JS templates for ajax tab
* Fix DisplayBlock::GetRenderContent and HistoryBlock::GetRenderContent signature mismatch warning
* Add return type hinting on ButtonFactory methods
* Rename ButtonFactory::MakeAlternativeNeutralActionButton() to ButtonFactory::MakeLinkNeutral()
* Add ButtonFactory::MakeLinkNeutral() to visual test page
* Fix button spacing/padding when only icon or label
This commit is contained in:
Molkobain
2020-09-28 17:47:27 +02:00
parent 2b0bdda1e0
commit 3dc7b66f6f
6 changed files with 107 additions and 86 deletions

View File

@@ -1367,7 +1367,7 @@ class HistoryBlock extends DisplayBlock
$this->iLimitCount = $iCount;
}
public function GetRenderContent(WebPage $oPage, $aExtraParams = array(), string $sId = null): iUIBlock
public function GetRenderContent(WebPage $oPage, array $aExtraParams = [], string $sId = null): iUIBlock
{
$sHtml = '';
$bTruncated = false;
@@ -1804,10 +1804,10 @@ class MenuBlock extends DisplayBlock
} else {
$sName = 'UI:Menu:Actions';
}
$oActionButton = ButtonFactory::MakeAlternativeNeutralActionButton('', $sName, 'fas fa-ellipsis-v', '', '', $sMenuTogglerId);
$oActionButton = ButtonFactory::MakeLinkNeutral('', '', 'fas fa-ellipsis-v', $sName, '', $sMenuTogglerId);
// TODO Add Js
$oActionsBlock->AddSubBlock($oActionButton);
$oActionsBlock->AddSubBlock($oPage->GetPopoverMenu($sPopoverMenuId, $aActions));
$oActionsBlock->AddSubBlock($oActionButton)
->AddSubBlock($oPage->GetPopoverMenu($sPopoverMenuId, $aActions));
$oActionButton->AddCSSClasses('ibo-action-button')
->SetJsCode(<<<JS
$("#{$sPopoverMenuId}").popover_menu({toggler: "#{$sMenuTogglerId}"});
@@ -1829,7 +1829,7 @@ JS
);
if ($this->m_sStyle == 'details') {
$oActionButton = ButtonFactory::MakeAlternativeNeutralActionButton('', 'UI:SearchFor_Class', 'fas fa-search', "{$sRootUrl}pages/UI.php?operation=search_form&do_search=0&class=$sClass{$sContext}");
$oActionButton = ButtonFactory::MakeLinkNeutral("{$sRootUrl}pages/UI.php?operation=search_form&do_search=0&class=$sClass{$sContext}", '', 'fas fa-search', 'UI:SearchFor_Class');
$oActionButton->SetTooltip(Dict::Format('UI:SearchFor_Class', MetaModel::GetName($sClass)))
->AddCSSClasses('ibo-action-button');
$oActionsBlock->AddSubBlock($oActionButton);
@@ -1840,8 +1840,9 @@ JS
$sRefreshAction = "window.location.reload();";
}
if (!$oPage->IsPrintableVersion() && ($sRefreshAction != '')) {
$oActionButton = ButtonFactory::MakeAlternativeNeutralActionButton('', 'UI:Button:Refresh', 'fas fa-sync');
$oActionButton->SetOnClickJsCode($sRefreshAction)
$oActionButton = ButtonFactory::MakeAlternativeNeutral('', 'UI:Button:Refresh');
$oActionButton->SetIconClass('fas fa-sync')
->SetOnClickJsCode($sRefreshAction)
->SetTooltip(Dict::S('UI:Button:Refresh'))
->AddCSSClasses('ibo-action-button');
$oActionsBlock->AddSubBlock($oActionButton);
@@ -1882,7 +1883,7 @@ JS
}
$sTarget = isset($aAction['target']) ? $aAction['target'] : '';
$oActionButton = ButtonFactory::MakeAlternativeNeutralActionButton($sLabel, $sActionId, $sIconClass, $sUrl, $sTarget);
$oActionButton = ButtonFactory::MakeLinkNeutral($sUrl, $sLabel, $sIconClass, $sActionId, $sTarget);
$oActionButton->AddCSSClasses('ibo-action-button');
$oActionsBlock->AddSubBlock($oActionButton);
}