Skip to content

Commit ecdca18

Browse files
Merge pull request #53 from xima-media/feature/internal-news-backend-ui
feat: redesign internal news backend UI and add news list modal
2 parents b9dd606 + 780c461 commit ecdca18

20 files changed

Lines changed: 403 additions & 114 deletions

File tree

Classes/Controller/DateController.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,20 @@ public function notifiesAction(): ResponseInterface
5555
]);
5656
}
5757

58+
public function listAction(): JsonResponse
59+
{
60+
return new JsonResponse(
61+
[
62+
'result' => ViewFactoryHelper::renderView(
63+
'Default/List.html',
64+
[
65+
'records' => $this->newsRepository->findAllByCurrentUser() ?? [],
66+
],
67+
),
68+
],
69+
);
70+
}
71+
5872
public function newsAction(): ResponseInterface
5973
{
6074
$queryParams = $GLOBALS['TYPO3_REQUEST']->getQueryParams();

Classes/Widgets/Provider/ListInternalNewsButtonProvider.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
namespace Xima\XimaTypo3InternalNews\Widgets\Provider;
1515

1616
use TYPO3\CMS\Backend\Routing\UriBuilder;
17+
use TYPO3\CMS\Core\Information\Typo3Version;
1718
use TYPO3\CMS\Core\Utility\GeneralUtility;
1819
use TYPO3\CMS\Dashboard\Widgets\{ButtonProviderInterface, ElementAttributesInterface};
1920

@@ -35,13 +36,20 @@ public function getTitle(): string
3536
public function getLink(): string
3637
{
3738
$uriBuilder = GeneralUtility::makeInstance(UriBuilder::class);
39+
40+
// TYPO3 v14 renamed the record list module to "records"; "web_list" only remains
41+
// as an alias. UriBuilder generates the CSRF token for the passed route name, while
42+
// RouteDispatcher validates it against the resolved identifier — passing the alias
43+
// causes a token mismatch and bounces the user back to the start module (dashboard).
44+
$listModuleIdentifier = (new Typo3Version())->getMajorVersion() >= 14 ? 'records' : 'web_list';
45+
3846
$params = [
3947
'id' => 0,
4048
'table' => 'tx_ximatypo3internalnews_domain_model_news',
4149
'returnUrl' => (string) $uriBuilder->buildUriFromRoute('dashboard'),
4250
];
4351

44-
return (string) $uriBuilder->buildUriFromRoute('web_list', $params);
52+
return (string) $uriBuilder->buildUriFromRoute($listModuleIdentifier, $params);
4553
}
4654

4755
public function getTarget(): string

Configuration/Backend/AjaxRoutes.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,8 @@
2020
'path' => '/internal-news/detail',
2121
'target' => Xima\XimaTypo3InternalNews\Controller\DateController::class.'::newsAction',
2222
],
23+
'internal_news_list' => [
24+
'path' => '/internal-news/list',
25+
'target' => Xima\XimaTypo3InternalNews\Controller\DateController::class.'::listAction',
26+
],
2327
];

Configuration/TCA/tx_ximatypo3internalnews_domain_model_news.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@
8686
'enableRichtext' => true,
8787
'rows' => 8,
8888
'cols' => 40,
89-
'max' => 2000,
9089
'eval' => 'trim',
9190
],
9291
],

Resources/Private/Language/de.locallang.xlf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@
2929
</trans-unit>
3030
<trans-unit id="toolbaritem.description">
3131
<source />
32-
<target><![CDATA[Hier finden Sie die neuesten internen Nachrichten. Alle Neuigkeiten finden Sie im internen News-Widget auf Ihrem <a href="%s">Dashboard</a>.]]></target>
32+
<target>Hier finden Sie die neuesten internen Nachrichten. Über "Alle News anzeigen" sehen Sie die vollständige Liste.</target>
33+
</trans-unit>
34+
<trans-unit id="toolbaritem.showAll">
35+
<source />
36+
<target>Alle News anzeigen</target>
3337
</trans-unit>
3438
<trans-unit id="empty">
3539
<source />

Resources/Private/Language/locallang.xlf

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@
2222
<source>Internal News</source>
2323
</trans-unit>
2424
<trans-unit id="toolbaritem.description">
25-
<source><![CDATA[Here you can find the latest internal news. Find all news within the internal news widget on your <a href="%s">dashboard</a>.]]></source>
25+
<source>Here you can find the latest internal news. Use "Show all news" to view the complete list.</source>
26+
</trans-unit>
27+
<trans-unit id="toolbaritem.showAll">
28+
<source>Show all news</source>
2629
</trans-unit>
2730
<trans-unit id="empty">
2831
<source>No internal news available</source>

Resources/Private/Partials/Detail.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
xmlns:be="http://typo3.org/ns/TYPO3/CMS/Backend/ViewHelpers"
33
xmlns:xin="http://typo3.org/ns/Xima/XimaTypo3InternalNews/ViewHelpers">
44

5+
<div class="internal-news-detail">
56
<h2>{record.title}</h2>
67
<f:if condition="{record.top}">
78
<span class="badge badge-danger internal-news--top">
@@ -27,16 +28,16 @@ <h2>{record.title}</h2>
2728
<div class="internal-news--media">
2829
<f:if condition="{record.media.originalResource.originalFile.properties.mime_type} == 'image/gif'">
2930
<f:then>
30-
<img src="{record.media.originalResource.publicUrl}" alt="{record.title}" width="760px"/>
31+
<img src="{record.media.originalResource.publicUrl}" alt="{record.title}"/>
3132
</f:then>
3233
<f:else if="{record.media.originalResource.originalFile.properties.mime_type} == 'video/mp4' || {record.media.originalResource.originalFile.properties.mime_type} == 'video/webm' || {record.media.originalResource.originalFile.properties.mime_type} == 'video/ogg'">
33-
<video controls width="760px">
34+
<video controls>
3435
<source src="{record.media.originalResource.publicUrl}" type="{record.media.originalResource.originalFile.properties.mime_type}">
3536
Your browser does not support the video tag.
3637
</video>
3738
</f:else>
3839
<f:else>
39-
<f:image image="{record.media}" alt="{record.title}" width="760px"/>
40+
<f:image image="{record.media}" alt="{record.title}" width="720"/>
4041
</f:else>
4142
</f:if>
4243
</div>
@@ -65,3 +66,4 @@ <h4>
6566
</f:for>
6667
</div>
6768
</f:if>
69+
</div>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<html data-namespace-typo3-fluid="true"
2+
xmlns:xin="http://typo3.org/ns/Xima/XimaTypo3InternalNews/ViewHelpers">
3+
4+
<ul class="{wrapperClass}">
5+
<f:for each="{records}" as="record">
6+
<f:render partial="Item" arguments="{record: record, top: '{xin:isTopAndNew(news: record)}'}"/>
7+
</f:for>
8+
</ul>
Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
<html data-namespace-typo3-fluid="true"
2-
xmlns:be="http://typo3.org/ns/TYPO3/CMS/Backend/ViewHelpers"
3-
xmlns:xin="http://typo3.org/ns/Xima/XimaTypo3InternalNews/ViewHelpers">
1+
<html data-namespace-typo3-fluid="true">
42

53
<p class="h3 dropdown-headline">
64
<span class="internal-news--icon-round">
@@ -9,24 +7,23 @@
97
<f:translate key="toolbaritem.title" extensionName="XimaTypo3InternalNews"/>
108
</p>
119
<p class="dropdown-item-text">
12-
<f:format.raw>
13-
<f:translate key="toolbaritem.description" extensionName="XimaTypo3InternalNews"
14-
arguments="{0: '{be:moduleLink(route:\'dashboard\')}'}"/>
15-
</f:format.raw>
10+
<f:translate key="toolbaritem.description" extensionName="XimaTypo3InternalNews"/>
1611
</p>
17-
<ul class="dropdown-list internal-news--toolbar">
18-
<f:if condition="{data}">
19-
<f:then>
20-
<f:for each="{data}" as="record">
21-
<f:render partial="Item" arguments="{record: record, top: '{xin:isTopAndNew(news: record)}'}"/>
22-
</f:for>
23-
</f:then>
24-
<f:else>
25-
<div class="internal-news--empty">
26-
<p>
27-
<f:translate key="empty" extensionName="XimaTypo3InternalNews"/>
28-
</p>
29-
</div>
30-
</f:else>
31-
</f:if>
32-
</ul>
12+
<f:if condition="{data}">
13+
<f:then>
14+
<f:render partial="NewsList" arguments="{records: data, wrapperClass: 'dropdown-list internal-news--toolbar'}"/>
15+
</f:then>
16+
<f:else>
17+
<div class="internal-news--empty">
18+
<p>
19+
<f:translate key="empty" extensionName="XimaTypo3InternalNews"/>
20+
</p>
21+
</div>
22+
</f:else>
23+
</f:if>
24+
<div class="internal-news--dropdown-footer">
25+
<button type="button" class="btn btn-default btn-sm internal-news--show-all">
26+
<core:icon identifier="actions-list-alternative" size="small" alternativeMarkupIdentifier="inline"/>
27+
<f:translate key="toolbaritem.showAll" extensionName="XimaTypo3InternalNews"/>
28+
</button>
29+
</div>

Resources/Private/Templates/Backend/Widgets/List.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@
1313
style="--mask: linear-gradient(to bottom, rgba(0, 0, 0, 1) 0, rgba(0, 0, 0, 1) 90%, rgba(0, 0, 0, 0) 95%, rgba(0, 0, 0, 0) 0) 100% 90% / 100% 100% repeat-x;-webkit-mask: var(--mask);mask: var(--mask);">
1414
<f:if condition="{records}">
1515
<f:then>
16-
<ul class="internal-news--wrapper">
17-
<f:for each="{records}" as="record">
18-
<f:render partial="Item" arguments="{record: record}"/>
19-
</f:for>
20-
</ul>
16+
<f:render partial="NewsList" arguments="{records: records, wrapperClass: 'internal-news--wrapper'}"/>
2117
</f:then>
2218
<f:else>
2319
<div class="row widget-no-items-found">

0 commit comments

Comments
 (0)