Skip to content

Commit

Permalink
[TASK] Further reduce need to override partials and templates
Browse files Browse the repository at this point in the history
  • Loading branch information
garbast committed Dec 1, 2024
1 parent d61f376 commit 5868eff
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,7 @@ class BeforeContainerConfigurationIsAppliedListener
#[AsEventListener('collapsible-container-beforecontainer', BeforeContainerConfigurationIsAppliedEvent::class)]
public function __invoke(BeforeContainerConfigurationIsAppliedEvent $event): void
{
$containerConfiguration = $event->getContainerConfiguration();

$containerConfiguration->setGridTemplate(
'EXT:ew_collapsible_container/Resources/Private/Templates/Grid.html'
);

$containerConfiguration->setGridPartialPaths([
$event->getContainerConfiguration()->setGridPartialPaths([
'EXT:backend/Resources/Private/Partials/',
'EXT:container/Resources/Private/Partials/',
'EXT:ew_collapsible_container/Resources/Private/Partials/',
Expand Down
16 changes: 16 additions & 0 deletions Classes/EventListener/BeforeContainerPreviewIsRenderedListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@
use Evoweb\EwCollapsibleContainer\Xclass\ContainerGridColumn;
use TYPO3\CMS\Core\Attribute\AsEventListener;
use TYPO3\CMS\Core\Authentication\BackendUserAuthentication;
use TYPO3\CMS\Core\Page\JavaScriptModuleInstruction;
use TYPO3\CMS\Core\Page\PageRenderer;

class BeforeContainerPreviewIsRenderedListener
{
public function __construct(protected PageRenderer $pageRenderer)
{
}

#[AsEventListener('collapsible-container-beforepreview', BeforeContainerPreviewIsRenderedEvent::class)]
public function __invoke(BeforeContainerPreviewIsRenderedEvent $event): void
{
Expand All @@ -38,6 +44,8 @@ public function __invoke(BeforeContainerPreviewIsRenderedEvent $event): void
'showMinItemsWarning' => $this->getShowMinItemsWarning($column, $countOfHiddenItems)
]);
}

$this->addFrontendResources();
}

protected function getCountOfHiddenItems(ContainerGridColumn $columnObject): int
Expand Down Expand Up @@ -71,6 +79,14 @@ protected function getShowMinItemsWarning(ContainerGridColumn $columnObject, int
return $itemCount > 0 && ($itemCount - $hiddenItemCount) < $minItems;
}

protected function addFrontendResources(): void
{
$this->pageRenderer->addCssFile('EXT:ew_collapsible_container/Resources/Public/Css/container.css');
$this->pageRenderer->getJavaScriptRenderer()->addJavaScriptModuleInstruction(
JavaScriptModuleInstruction::create('@evoweb/ew-collapsible-container/container.js')
);
}

protected function getBackendUser(): BackendUserAuthentication
{
return $GLOBALS['BE_USER'];
Expand Down
44 changes: 20 additions & 24 deletions Resources/Private/Partials/PageLayout/Grid/ColumnHeader.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,22 +39,20 @@
<f:render section="collapsibleExpandIcon" arguments="{_all}"/>

<f:section name="collapsibleToggleIcon">
<f:if condition="{collapsable}">
<a href="#"
class="btn btn-sm btn-default btn-borderless t3js-toggle-container-column"
title="{f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:expandcontent')}"
data-toggle-title="{f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:collapsecontent')}"
data-collapse-state="collapsed">
<core:icon identifier="actions-view-list-expand" />
</a>
<a href="#"
class="btn btn-sm btn-default btn-borderless t3js-toggle-container-column"
title="{f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:collapsecontent')}"
data-toggle-title="{f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:expandcontent')}"
data-collapse-state="expanded">
<core:icon identifier="actions-view-list-collapse" />
</a>
</f:if>
<a href="#"
class="btn btn-sm btn-default btn-borderless t3js-toggle-container-column"
title="{f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:expandcontent')}"
data-toggle-title="{f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:collapsecontent')}"
data-collapse-state="collapsed">
<core:icon identifier="actions-view-list-expand" />
</a>
<a href="#"
class="btn btn-sm btn-default btn-borderless t3js-toggle-container-column"
title="{f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:collapsecontent')}"
data-toggle-title="{f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:expandcontent')}"
data-collapse-state="expanded">
<core:icon identifier="actions-view-list-collapse" />
</a>
</f:section>

<f:section name="collapsibleMinitemWarning">
Expand All @@ -73,14 +71,12 @@
</f:section>

<f:section name="collapsibleExpandIcon">
<f:if condition="{collapsable}">
<div class="m-3 container-collapsed-column-marker t3js-expand-column">
<button type="button" class="btn btn-default btn-sm me-2">
<core:icon identifier="actions-view-list-expand"/>
</button>
{f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:contentcollapsed')}
</div>
</f:if>
<div class="m-3 container-collapsed-column-marker t3js-expand-column">
<button type="button" class="btn btn-default btn-sm me-2">
<core:icon identifier="actions-view-list-expand"/>
</button>
{f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:contentcollapsed')}
</div>
</f:section>

</html>
15 changes: 0 additions & 15 deletions Resources/Private/Templates/Grid.html

This file was deleted.

0 comments on commit 5868eff

Please sign in to comment.