Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] gray badge #125

Open
wants to merge 9 commits into
base: feature/show-maxitems-in-pagemodule
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions Classes/ViewHelpers/GetVersionViewHelper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace IchHabRecht\ContentDefender\ViewHelpers;

use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;

class GetVersionViewHelper extends AbstractViewHelper
{
use CompileWithRenderStatic;

public function initializeArguments()
{
parent::initializeArguments();
}

public static function renderStatic(
array $arguments,
\Closure $renderChildrenClosure,
RenderingContextInterface $renderingContext
) {
return (new Typo3Version())->getMajorVersion();
}
}
2 changes: 1 addition & 1 deletion Configuration/TSconfig/Page/maxitems.tsconfig
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

templates.typo3/cms-backend.100 = ichhabrecht/content-defender:Resources/Private/
templates.typo3/cms-backend.100 = ichhabrecht/content-defender:Resources/Private/Backend/
6 changes: 3 additions & 3 deletions Configuration/TypoScript/constants.typoscript
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module.tx_contentdefender {
view {
# cat=plugin.tx_contentdefender/file; type=string; label=Path to template root
templateRootPath = EXT:content_defender/Resources/Private/Templates/Backend/
templateRootPath = EXT:content_defender/Resources/Private/Backend/Templates/
# cat=plugin.tx_contentdefender/file; type=string; label=Path to template partials
partialRootPath = EXT:content_defender/Resources/Private/Partials/Backend/
partialRootPath = EXT:content_defender/Resources/Private/Backend/Partials/
# cat=plugin.tx_contentdefender/file; type=string; label=Path to template layouts
layoutRootPath = EXT:content_defender/Resources/Private/Layouts/Backend/
layoutRootPath = EXT:content_defender/Resources/Private/Backend/Layouts/
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<html xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
xmlns:cd="http://typo3.org/ns/IchHabRecht/ContentDefender/ViewHelpers"
data-namespace-typo3-fluid="true">

<f:be.pageRenderer includeCssFiles="{0: 'EXT:content_defender/Resources/Public/Css/backend.css'}" />

<f:if condition="{cd:getVersion()} == 12">
<f:be.pageRenderer includeCssFiles="{1: 'EXT:content_defender/Resources/Public/Css/backend_v12.css'}" />
</f:if>


<cd:extendPartial>
<f:alias map="{maxitems: '{cd:maxitems(column: column)}'}">

<f:variable name="length" value="1"/>

<f:if condition="{maxitems} > 9">
<f:variable name="length" value="2"/>
</f:if>

<f:if condition="{maxitems} > 99">
<f:variable name="length" value="3"/>
</f:if>

<div class="t3-cd-badge-container t3-cd-badge-container-length-{length}" data-maxitems="{maxitems}">
<f:if condition="{maxitems} >= 0">
<span class="badge t3-cd-badge">
{f:if(condition: '{maxitems} > 99', then: '&#43;99', else: '{maxitems}')}
</span>
</f:if>
<f:render partial="PageLayout/Grid/ColumnHeader" arguments="{_all}" />
</div>
</f:alias>
</cd:extendPartial>

</html>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,18 @@
data-namespace-typo3-fluid="true">
<cd:extendPartial>
<f:alias map="{maxitems: '{cd:maxitems(column: column)}'}">
<div class="t3-cd-badge-container" data-maxitems="{maxitems}">

<f:variable name="length" value="1"/>

<f:if condition="{maxitems} > 9">
<f:variable name="length" value="2"/>
</f:if>

<f:if condition="{maxitems} > 99">
<f:variable name="length" value="3"/>
</f:if>

<div class="t3-cd-badge-container t3-cd-badge-container-length-{length}" data-maxitems="{maxitems}">
<f:render partial="PageLayout/Record" arguments="{_all}" />
</div>
</f:alias>
Expand Down

This file was deleted.

45 changes: 24 additions & 21 deletions Resources/Public/Css/backend.css
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
@charset "UTF-8";

.t3-cd-badge-container {
position: relative;
.t3js-page-column .t3-cd-badge-container[data-maxitems="0"] .t3-page-ce .t3js-page-new-ce,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand the CSS correctly for a full column there wouldn't be any badge anymore. But one of the main purposes is to tell the editor that there is a limit and it is reached.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the Line 3-12 just removes the «new content-element» Button not the badge.
Line 8-12 is a fix, to prevent the shifting of the Drop area if the button is hidden.

The badge is always visible. We just hide it if there is no maxitems property in the backendlayout configuration.

.t3js-page-column .t3-cd-badge-container[data-maxitems="0"] .t3-page-ce .t3-page-ce-dropzone {
display: none;
}

.t3-cd-badge-container[data-maxitems="0"] .t3-page-ce .t3js-page-new-ce,
.t3-cd-badge-container[data-maxitems="0"] .t3-page-ce .t3-page-ce-dropzone {
display: none;
body[style="cursor: move;"] .t3js-page-column .t3-cd-badge-container[data-maxitems="0"] .t3-page-ce .t3js-page-new-ce,
body[style="cursor: move;"].t3js-page-column .t3-cd-badge-container[data-maxitems="0"] .t3-page-ce .t3-page-ce-dropzone {
display: block;
visibility: hidden;
}

.t3-cd-badge {
position: absolute;
left: 0;
top: 0;
transform: translate(-50%, 0);
background-color: #ff0000;
z-index: 100;
.t3-cd-badge-container:not([data-maxitems="-1"]).t3-cd-badge-container-length-1 .t3-page-column-header {
padding-left: 25px;
}

.t3-cd-badge.text-bg-success {
background-color: #107c10;
color: #ffffff;
.t3-cd-badge-container:not([data-maxitems="-1"]).t3-cd-badge-container-length-2 .t3-page-column-header {
padding-left: 30px;
}

.t3-cd-badge.text-bg-warning {
background-color: #e8a33d;
color: #ffffff;
.t3-cd-badge-container:not([data-maxitems="-1"]).t3-cd-badge-container-length-3 .t3-page-column-header {
padding-left: 40px;
}

.t3-cd-badge.text-bg-danger {
background-color: #ff0000;
color: #ffffff;
.t3-cd-badge-container {
position: relative;
}

.t3-cd-badge {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you tested the layout in all TYPO3 versions yet?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i say it in German – "verdammt – da war noch was 😳"

I keep you updated after testing

position: absolute;
z-index: 1;
left: 0;
top: 21px;
background-color: #eaeaea;
color: #000000;
}
5 changes: 5 additions & 0 deletions Resources/Public/Css/backend_v12.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.t3-cd-badge-container .t3-cd-badge{
background-color: #c6bebe;
left: 1rem;
top: 0;
}