N°9167 Use ExtensionDetails UIBlocks instead of table

This commit is contained in:
Timmy38
2026-05-12 12:01:41 +02:00
parent fb7a38c83f
commit b3b7fef6e4
11 changed files with 189 additions and 122 deletions

View File

@@ -179,32 +179,37 @@ class ExtensionDetails extends UIContentBlock
protected function InitializeToggler()
{
$sName = 'aSelectedExtensions['.$this->GetCode().']';
$this->oToggler = new Toggler();
$this->oToggler->SetName('ExtensionToggler');
$this->oToggler->SetName($sName);
$this->oToggler->AddCSSClass('toggler-install');
}
protected function InitializePopoverMenu()
{
$sModalLabel = Dict::Format('UI:Layout:ExtensionsDetails:MenuAboutTitle', $this->sLabel);
$sModalText = $this->sAbout;
$oModifyButton = new JSButtonItem(
'extension_details',
Dict::S('UI:Layout:ExtensionsDetails:MenuAbout'),
<<<JS
CombodoModal.OpenModal({
title: '$sModalLabel',
content: '$sModalText',
});
JS,
);
$this->oPopoverMenu = new PopoverMenu();
$this->oPopoverMenu->AddItem('more-actions', PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem($oModifyButton));
$oPopoverOpenButton = ButtonUIBlockFactory::MakeIconAction('fas fa-ellipsis-v', 'Show more actions');
$this->oPopoverMenu->SetTogglerFromBlock($oPopoverOpenButton);
$this->oMoreActions = new UIContentBlock();
$this->oMoreActions->AddSubBlock($this->oPopoverMenu);
$this->oMoreActions->AddSubBlock($oPopoverOpenButton);
if (mb_strlen($this->sAbout) > 0) {
$sModalLabel = Dict::Format('UI:Layout:ExtensionsDetails:MenuAboutTitle', $this->sLabel);
$sModalText = $this->sAbout;
$oModifyButton = new JSButtonItem(
'extension_details',
Dict::S('UI:Layout:ExtensionsDetails:MenuAbout'),
<<<JS
CombodoModal.OpenModal({
title: '$sModalLabel',
content: '$sModalText',
});
JS,
);
$this->oPopoverMenu->AddItem('more-actions', PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem($oModifyButton));
}
}
public function AllowForceUninstall()
@@ -213,7 +218,8 @@ JS,
'force_uninstall',
Dict::S('UI:Layout:ExtensionsDetails:MenuForce'),
<<<JS
this.closest('.ibo-extension-details').querySelector('input[type=checkbox]').disabled = false
this.closest('.ibo-extension-details').querySelector('input[type=checkbox]').disabled = false;
this.remove();
JS,
);
$this->oPopoverMenu->AddItem('more-actions', PopoverMenuItemFactory::MakeFromApplicationPopupMenuItem($oForceUninstallButton));

View File

@@ -18,6 +18,8 @@ class ExtensionDetailsUIBlockFactory extends AbstractUIBlockFactory
$aBadges = [];
$bUninstallable = $aExtraFlags['uninstallable'] ?? true;
$bMissingFromDisk = $aExtraFlags['missing'] ?? false;
$bSelected = $aExtraFlags['selected'] ?? true;
$bDisabled = $aExtraFlags['disabled'] ?? false;
self::AddExtraBadges($aBadges, $bUninstallable, $bMissingFromDisk);
$oBadgeInstalled = BadgeUIBlockFactory::MakeGreen(Dict::S('UI:Layout:ExtensionsDetails:BadgeInstalled'));
$oBadgeInstalled->AddCSSClass('checked');
@@ -28,10 +30,23 @@ class ExtensionDetailsUIBlockFactory extends AbstractUIBlockFactory
$oExtensionDetails = new ExtensionDetails($sCode, $sLabel, $sDescription, $aMetaData, $aBadges, $sAbout);
$oExtensionDetails->GetToggler()->SetIsToggled(true);
if (!$bUninstallable) {
if ($bMissingFromDisk) {
$oExtensionDetails->GetToggler()->SetIsToggled(false);
$oExtensionDetails->GetToggler()->SetIsDisabled(true);
}
else if (!$bUninstallable) {
$oExtensionDetails->AllowForceUninstall();
$oExtensionDetails->GetToggler()->SetIsDisabled(true);
}
if (!$bSelected) {
$oExtensionDetails->GetToggler()->SetIsToggled(false);
}
if ($bDisabled) {
$oExtensionDetails->GetToggler()->SetIsDisabled(true);
$oExtensionDetails->GetToggler()->AddCSSClass('ibo-is-hidden');
}
return $oExtensionDetails;
}
@@ -39,6 +54,8 @@ class ExtensionDetailsUIBlockFactory extends AbstractUIBlockFactory
{
$aBadges = [];
$bUninstallable = $aExtraFlags['uninstallable'] ?? true;
$bSelected = $aExtraFlags['selected'] ?? false;
$bDisabled = $aExtraFlags['disabled'] ?? false;
self::AddExtraBadges($aBadges, $bUninstallable, false);
$oBadgeInstalled = BadgeUIBlockFactory::MakeGrey(Dict::S('UI:Layout:ExtensionsDetails:BadgeNotInstalled'));
$oBadgeInstalled->AddCSSClass('unchecked');
@@ -46,8 +63,17 @@ class ExtensionDetailsUIBlockFactory extends AbstractUIBlockFactory
$oBadgeToBeUninstalled = BadgeUIBlockFactory::MakeCyan(Dict::S('UI:Layout:ExtensionsDetails:BadgeToBeInstalled'));
$oBadgeToBeUninstalled->AddCSSClass('checked');
$aBadges[] = $oBadgeToBeUninstalled;
$oExtensionDetails = new ExtensionDetails($sCode, $sLabel, $sDescription, $aMetaData, $aBadges, $sAbout);
return new ExtensionDetails($sCode, $sLabel, $sDescription, $aMetaData, $aBadges, $sAbout);
if ($bSelected) {
$oExtensionDetails->GetToggler()->SetIsToggled(true);
}
if ($bDisabled) {
$oExtensionDetails->GetToggler()->SetIsDisabled(true);
$oExtensionDetails->GetToggler()->AddCSSClass('ibo-is-hidden');
}
return $oExtensionDetails;
}
private static function AddExtraBadges(array &$aBadges, bool $bUninstallable, bool $bMissingFromDisk)