From 2b6b4662a353dab5dd4000186f9b9221e82af11d Mon Sep 17 00:00:00 2001 From: Michael Danielczok <michael@pcsg.de> Date: Sat, 23 Nov 2024 15:07:20 +0100 Subject: [PATCH] fix: show all entries if no limit is set in settings --- bricks.xml | 7 +++++++ locale.xml | 15 ++++++++++++--- site.xml | 15 +++++++++++++++ src/QUI/Timeline/Bricks/Timeline.php | 8 ++++---- src/QUI/Timeline/Controls/Timeline.php | 9 +++++++-- types/timeline.php | 3 ++- 6 files changed, 47 insertions(+), 10 deletions(-) diff --git a/bricks.xml b/bricks.xml index b663572..857184f 100644 --- a/bricks.xml +++ b/bricks.xml @@ -16,6 +16,13 @@ <locale group="quiqqer/timeline" var="brick.timeline.setting.site"/> </setting> + <setting name="site" type="number"> + <locale group="quiqqer/timeline" var="brick.timeline.setting.site"/> + <description> + <locale group="quiqqer/timeline" var="brick.timeline.setting.site"/> + </description> + </setting> + <setting name="imageFillMode" type="select"> <locale group="quiqqer/timeline" var="brick.timeline.setting.imageFillMode"/> diff --git a/locale.xml b/locale.xml index efe4e9c..33f6e7f 100644 --- a/locale.xml +++ b/locale.xml @@ -68,12 +68,12 @@ <locale name="brick.timeline.setting.limit"> - <de><![CDATA[Maximale Anzahl]]></de> + <de><![CDATA[Limit]]></de> <en><![CDATA[Limit]]></en> </locale> <locale name="brick.timeline.setting.limit.desc"> - <de><![CDATA[Legt die maximale Anzahl der Einträge fest.]]></de> - <en><![CDATA[Sets the maximum number of items to display.]]></en> + <de><![CDATA[Mit dieser Einstellung kann die Anzahl der angezeigten Einträge begrenzt werden. Um alle Einträge anzuzeigen, muss das Feld leer bleiben.]]></de> + <en><![CDATA[This setting allows you to limit the number of displayed entries. To show all entries, please leave the field empty.]]></en> </locale> </groups> @@ -85,6 +85,15 @@ <en><![CDATA[Timeline: settings]]></en> </locale> + <locale name="timeline.limit"> + <de><![CDATA[Limit]]></de> + <en><![CDATA[Limit]]></en> + </locale> + <locale name="timeline.limit.desc"> + <de><![CDATA[Mit dieser Einstellung kann die Anzahl der angezeigten Einträge begrenzt werden. Um alle Einträge anzuzeigen, muss das Feld leer bleiben.]]></de> + <en><![CDATA[This setting allows you to limit the number of displayed entries. To show all entries, please leave the field empty.]]></en> + </locale> + <!-- template / display --> <locale name="timeline.display"> <de><![CDATA[Vorlage]]></de> diff --git a/site.xml b/site.xml index 480c246..257db45 100644 --- a/site.xml +++ b/site.xml @@ -11,6 +11,7 @@ <!-- list attributes --> <attributes> + <attribute>quiqqer.timeline.limit</attribute> <attribute default="VerticalBothSides">quiqqer.timeline.display</attribute> <attribute default="0">quiqqer.timeline.showLinks</attribute> <attribute default="cover">quiqqer.timeline.imageFillMode</attribute> @@ -25,6 +26,20 @@ var="timeline.settings.title"/> </title> + <input conf="quiqqer.timeline.limit" type="number"> + <text> + <locale group="quiqqer/timeline" + var="timeline.limit" + /> + </text> + + <description> + <locale group="quiqqer/timeline" + var="timeline.limit.desc" + /> + </description> + </input> + <select conf="quiqqer.timeline.display"> <text> <locale group="quiqqer/timeline" diff --git a/src/QUI/Timeline/Bricks/Timeline.php b/src/QUI/Timeline/Bricks/Timeline.php index b9d053c..ab29123 100644 --- a/src/QUI/Timeline/Bricks/Timeline.php +++ b/src/QUI/Timeline/Bricks/Timeline.php @@ -28,7 +28,7 @@ public function __construct($attributes = []) 'order' => 'c_date ASC', 'showLinks' => true, 'template' => 'VerticalBothSides', - 'limit' => 10 + 'limit' => false ]); parent::__construct($attributes); @@ -47,10 +47,10 @@ public function getBody(): string $Engine = QUI::getTemplateManager()->getEngine(); $Control = new QUI\Timeline\Controls\Timeline(); - $limit = $this->getAttribute('limit'); + $limit = false; - if (!$limit || $limit < 1) { - $limit = 10; + if ($this->getAttribute('limit') >= 1) { + $limit = $this->getAttribute('limit'); } $attributes = [ diff --git a/src/QUI/Timeline/Controls/Timeline.php b/src/QUI/Timeline/Controls/Timeline.php index 226d079..840fdf7 100644 --- a/src/QUI/Timeline/Controls/Timeline.php +++ b/src/QUI/Timeline/Controls/Timeline.php @@ -32,7 +32,7 @@ public function __construct(array $attributes = []) 'parentInputList' => false, //todo später für brick 'showLinks' => true, 'display' => 'VerticalBothSides', - 'limit' => 10, + 'limit' => false, 'imageFillMode' => 'cover', // cover / contain // Custom children template (path to html file); overwrites "display" 'displayTemplate' => false, @@ -62,7 +62,12 @@ public function getBody(): string return ''; } - $limit = $this->getAttribute('limit') ?: 10; + $limit = false; + + if ($this->getAttribute('limit') >= 1) { + $limit = $this->getAttribute('limit'); + } + $parents = $this->getAttribute('parentInputList') ?: $Site->getId(); // only active sites diff --git a/types/timeline.php b/types/timeline.php index 002c452..f0b74da 100644 --- a/types/timeline.php +++ b/types/timeline.php @@ -9,7 +9,8 @@ 'showLinks' => $Site->getAttribute('quiqqer.timeline.showLinks'), 'itemtype' => 'http://schema.org/ItemList', 'child-itemtype' => 'http://schema.org/ListItem', - 'display' => $Site->getAttribute('quiqqer.timeline.display') + 'display' => $Site->getAttribute('quiqqer.timeline.display'), + 'limit' => $Site->getAttribute('quiqqer.timeline.limit') ]); $Engine->assign([ -- GitLab