Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Fischer committed Apr 3, 2024
2 parents ee8bb28 + 76cba10 commit 2e6a719
Show file tree
Hide file tree
Showing 10 changed files with 256 additions and 22 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.idea/
public/
vendor/
/public/
/vendor/
composer.lock
18 changes: 8 additions & 10 deletions Classes/Xclass/ContainerConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,20 @@ class ContainerConfiguration extends BaseContainerConfiguration
*/
protected $gridTemplate = 'EXT:ew_collapsible_container/Resources/Private/Templates/Container/Grid.html';

/**
* @var array
*/
protected $gridPartialPaths = [
'EXT:backend/Resources/Private/Partials/',
'EXT:container/Resources/Private/Partials/',
'EXT:ew_collapsible_container/Resources/Private/Partials/',
];

public function __construct(
string $cType,
string $label,
string $description,
array $grid
) {
parent::__construct($cType, $label, $description, $grid);
$this->addGridPartialPath('EXT:ew_collapsible_container/Resources/Private/Partials/');
if ((GeneralUtility::makeInstance(Typo3Version::class))->getMajorVersion() < 12) {
$this->addGridPartialPath('EXT:ew_collapsible_container/Resources/Private/PartialsPre12/');
$this->setGridTemplate(
'EXT:ew_collapsible_container/Resources/Private/Templates/Container/GridPre12.html'
);
} else {
$this->addGridPartialPath('EXT:ew_collapsible_container/Resources/Private/Partials/');
}
}
}
4 changes: 2 additions & 2 deletions Classes/Xclass/ContainerPreviewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string
foreach ($cols as $col) {
$newContentElementAtTopTarget = $this->containerService->getNewContentElementAtTopTargetInColumn($container, $col['colPos']);
$allowNewContentElements = !$this->containerColumnConfigurationService->isMaxitemsReached($container, $col['colPos']);
$collapsed = $this->getColumnCollapsedState((int)$record['uid'], (int)$col['colPos']);
$collapsed = $this->getColumnCollapsedState((int)$record['uid'], (int)$col['colPos'], $col);
$columnObject = GeneralUtility::makeInstance(
ContainerGridColumn::class,
$context,
Expand Down Expand Up @@ -85,7 +85,7 @@ public function renderPageModulePreviewContent(GridColumnItem $item): string
return $content . $rendered;
}

protected function getColumnCollapsedState(int $recordUid, int $colPos): bool
protected function getColumnCollapsedState(int $recordUid, int $colPos, array $col): bool
{
$collapseId = $recordUid . ContainerGridColumn::CONTAINER_COL_POS_DELIMITER_V12 . $colPos;
if (isset($this->getBackendUser()->uc['moduleData']['list']['containerExpanded'][$collapseId])) {
Expand Down
20 changes: 20 additions & 0 deletions Resources/Private/Language/de.locallang.xlf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<xliff version="1.2" xmlns="urn:oasis:names:tc:xliff:document:1.2">
<file source-language="en" datatype="plaintext" original="messages" date="2023-02-07T14:19:01Z">
<header/>
<body>
<trans-unit id="collapsecontent">
<source>Collapse content in column</source>
<target>Spalte zuklappen</target>
</trans-unit>
<trans-unit id="expandcontent">
<source>Expand content in column</source>
<target>Spalte ausklappen</target>
</trans-unit>
<trans-unit id="contentcollapsed">
<source>This column is collapsed!</source>
<target>Diese Spalte ist zugeklappt</target>
</trans-unit>
</body>
</file>
</xliff>
106 changes: 106 additions & 0 deletions Resources/Private/PartialsPre12/PageLayout/Grid/Column.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:core="http://typo3.org/ns/TYPO3/CMS/Core/ViewHelpers"
data-namespace-typo3-fluid="true">
<f:comment>remove class t3-grid-cell (for tests)</f:comment>
<f:comment>change data-colpos attr</f:comment>
<td valign="top" colspan="{column.colSpan}" rowspan="{column.rowSpan}"
data-colpos="{column.dataColPos}" data-language-uid="{column.context.siteLanguage.languageId}"
class="t3-grid-cell t3js-page-lang-column-{column.context.siteLanguage.languageId} t3js-page-column t3-page-column t3-page-column-{column.columnNumber}
{f:if(condition: column.active, else: 't3-grid-cell-unassigned')}
{f:if(condition: column.collapsed, then: 'collapsed')}
t3-gridCell-width{column.colSpan}
t3-gridCell-height{column.rowSpan}">
<div class="t3-page-column-header">
<f:if condition="{column.active}">
<f:then>
<div class="t3-page-column-header-icons">
<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>
<f:if condition="{allowEditContent} && {column.editUrl}">
<a href="{column.editUrl}" title="{column.editLinkTitle}"><core:icon identifier="actions-document-open" /></a>
</f:if>
</div>
{column.title}
</f:then>
<f:else if="{column.unassigned}">
{column.title} (<f:format.raw>{column.titleUnassigned}</f:format.raw>)
</f:else>
<f:else if="!{hideRestrictedColumns}">
<f:format.raw>{column.titleInaccessible}</f:format.raw>
</f:else>
<f:else>
<f:format.raw>{column.titleInaccessible}</f:format.raw>
</f:else>
</f:if>
</div>
<f:comment>use column.allowNewContent instead of pageContext</f:comment>
<f:if condition="{allowEditContent} && {column.contentEditable} && {column.allowNewContent}">
<div class="t3-page-ce t3js-page-ce" data-page="{column.context.pageId}" id="{column.uniqueId}">
<div class="t3js-page-new-ce t3-page-ce-wrapper-new-ce" id="colpos-{column.columnNumber}-page-{column.context.pageId}-{column.uniqueId}">
<f:if condition="{column.context.drawingConfiguration.showNewContentWizard}">
<f:then>
<typo3-backend-new-content-element-wizard-button url="{column.newContentUrl}" title="{newContentTitle}">
<button type="button" class="btn btn-default btn-sm">
<core:icon identifier="actions-add" />
{newContentTitleShort}
</button>
</typo3-backend-new-content-element-wizard-button>
</f:then>
<f:else>
<a href="{column.newContentUrl}" title="{newContentTitle}" class="btn btn-default btn-sm">
<core:icon identifier="actions-add" />
{newContentTitleShort}
</a>
</f:else>
</f:if>
</div>
<div class="t3-page-ce-dropzone-available t3js-page-ce-dropzone-available"></div>
</div>
</f:if>
<f:if condition="{collapsable}">
<div class="t3-page-ce container-collapsed-column-marker">
{f:translate(key: 'LLL:EXT:ew_collapsible_container/Resources/Private/Language/locallang.xlf:contentcollapsed')}
</div>
</f:if>
<f:if condition="{column.unassigned}">
<div class="t3-page-ce">
<div class="t3-page-ce-header">Empty Colpos</div>
<div class="t3-page-ce-body">
<div class="t3-page-ce-body-inner">
<div class="row">
<div class="col-xs-12">
This column has no "colPos". This is only for display Purposes.
</div>
</div>
</div>
</div>
</div>
</f:if>
<f:if condition="{column.items}">
<f:comment>change data-colpos attr</f:comment>
<div data-colpos="{column.dataColPos}" data-language-uid="{column.context.siteLanguage.languageId}"
class="t3js-sortable t3js-sortable-lang t3js-sortable-lang-{column.context.siteLanguage.languageId} t3-page-ce-wrapper
{f:if(condition: column.items, else: 't3-page-ce-empty')}">
<f:for each="{column.items}" as="item">
<f:if condition="{item.deletePlaceholder} == 0">
<f:render partial="PageLayout/Record" arguments="{_all}" />
</f:if>
</f:for>
</div>
</f:if>
</td>
</html>
31 changes: 31 additions & 0 deletions Resources/Private/Templates/Container/GridPre12.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<html
xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:container="http://typo3.org/ns/B13/Container/ViewHelpers"
data-namespace-typo3-fluid="true"
>

<f:be.pageRenderer
includeCssFiles="{0: 'EXT:ew_collapsible_container/Resources/Public/Css/container.css'}"
includeRequireJsModules="{0: 'TYPO3/CMS/EwCollapsibleContainer/ContainerPre12'}" />

<f:if condition="{grid}">
<f:comment>View\ContainerLayoutView</f:comment>
<table style="width: 100%; table-layout: fixed;">
<f:for each="{grid}" as="row">
<tr>
<f:for each="{row}" as="column">
<td class="t3-grid-cell" valign="top"{f:if(condition:"{column.colspan}", then: ' colspan="{column.colspan}"')}{f:if(condition:"{column.rowspan}", then: ' rowspan="{column.rowspan}"')}>
<container:drawChildren uid="{uid}" colPos="{column.colPos}" />
</td>
</f:for>
</tr>
</f:for>
</table>
</f:if>

<f:if condition="{containerGrid}">
<f:comment>Backend\Preview\ContainerLayoutView (Fluid based page module)</f:comment>
<f:render partial="PageLayout/Grid" arguments="{grid: containerGrid, hideRestrictedColumns: hideRestrictedColumns, newContentTitle: newContentTitle, newContentTitleShort: newContentTitleShort, allowEditContent: allowEditContent, collapsable: 1}" />
</f:if>

</html>
4 changes: 4 additions & 0 deletions Resources/Public/Css/container.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
display: inline-block;
}

.collapsed > .t3-page-ce-wrapper {
min-height: 0;
}

.collapsed > .t3-page-ce-wrapper * {
display: none;
}
Expand Down
71 changes: 71 additions & 0 deletions Resources/Public/JavaScript/ContainerPre12.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
class ContainerToggle {
containerColumnToggle = '.t3js-toggle-container-column';

persistentStorage = null;

storageKey = 'moduleData.list.containerExpanded';

constructor(PersistentStorage) {
this.persistentStorage = PersistentStorage;
this.initializeContainerToggle();
}

/**
* initialize the toggle icons to open listings of nested grid container structure in the list module
*/
initializeContainerToggle() {
const containers = Array.from(document.querySelectorAll(this.containerColumnToggle));
containers.forEach(container=> {
container.addEventListener('click', event => this.toggleClicked(event));
});
}

toggleClicked(event) {
event.preventDefault();

let column = event.currentTarget,
container = column.closest('td').dataset['colpos'],
isExpanded = column.dataset['collapseState'] === 'expanded';

// Store collapse state in UC
let storedModuleDataList = {};

if (this.persistentStorage.isset(this.storageKey)) {
storedModuleDataList = this.persistentStorage.get(this.storageKey);
}

let expandConfig = {};
expandConfig[container] = isExpanded ? '1' : '0';

storedModuleDataList = Object.assign(storedModuleDataList, expandConfig);

this.persistentStorage.set(this.storageKey, storedModuleDataList).then(() => {
if (isExpanded) {
column.closest('td').classList.add('collapsed');
} else {
column.closest('td').classList.remove('collapsed');
}
});
}
}

define(
[
'TYPO3/CMS/Backend/Storage/Persistent'
],
function(PersistentStorage) {
return new ContainerToggle(PersistentStorage);
}
);
18 changes: 11 additions & 7 deletions Resources/Public/JavaScript/container.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@
* The TYPO3 project - inspiring people to share!
*/

import PersistentStorage from "@typo3/backend/storage/persistent.js";
import PersistentStorage from '@typo3/backend/storage/persistent.js';

class ContainerToggle {
containerColumnToggle = '.t3js-toggle-container-column';

constructor() {
persistentStorage = null;

storageKey = 'moduleData.list.containerExpanded';

constructor(PersistentStorage) {
this.persistentStorage = PersistentStorage;
this.initializeContainerToggle();
}

Expand All @@ -40,16 +45,16 @@ class ContainerToggle {
// Store collapse state in UC
let storedModuleDataList = {};

if (PersistentStorage.isset('moduleData.list.containerExpanded')) {
storedModuleDataList = PersistentStorage.get('moduleData.list.containerExpanded');
if (this.persistentStorage.isset(this.storageKey)) {
storedModuleDataList = this.persistentStorage.get(this.storageKey);
}

let expandConfig = {};
expandConfig[container] = isExpanded ? "1" : "0";
expandConfig[container] = isExpanded ? '1' : '0';

storedModuleDataList = Object.assign(storedModuleDataList, expandConfig);

PersistentStorage.set('moduleData.list.containerExpanded', storedModuleDataList).then(() => {
this.persistentStorage.set(this.storageKey, storedModuleDataList).then(() => {
if (isExpanded) {
column.closest('td').classList.add('collapsed');
} else {
Expand All @@ -59,5 +64,4 @@ class ContainerToggle {
}
}


export default new ContainerToggle;
2 changes: 1 addition & 1 deletion ext_emconf.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

$EM_CONF['extender'] = [
$EM_CONF['ew_collapsible_container'] = [
'title' => 'Collapsible container',
'description' => '',
'category' => 'misc',
Expand Down

0 comments on commit 2e6a719

Please sign in to comment.