Skip to content

Commit

Permalink
see cl
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Kunitzsch committed Sep 27, 2019
1 parent 6d79ccc commit 4b7aa38
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,6 +1,11 @@
# Changelog
All notable changes to this project will be documented in this file.

## [1.8.0] - 2019-09-27

#### Added
- optional jumpTo overview page

## [1.7.2] - 2019-09-24

#### Changed
Expand Down
63 changes: 63 additions & 0 deletions src/Lists/DefaultList.php
Expand Up @@ -9,6 +9,7 @@
namespace HeimrichHannot\ListBundle\Lists;

use Contao\Config;
use Contao\Controller;
use Contao\Database;
use Contao\Date;
use Contao\FrontendTemplate;
Expand Down Expand Up @@ -129,6 +130,18 @@ class DefaultList implements ListInterface, \JsonSerializable
*/
protected $_filterConfig;

/**
* overview page.
*
* @var bool
*/
protected $_addOverview = false;

/**
* @var string
*/
protected $_jumpToOverview;

/**
* Constructor.
*
Expand All @@ -155,6 +168,10 @@ public function parse(string $listTemplate = null, string $itemTemplate = null,
$this->addDataAttributes();
$this->addMasonry();

if($listConfig->addOverview) {
$this->addJumpToOverview($listConfig);
}

if ($listConfig->isTableList) {
$this->setSortingHeader($listConfig->sortingHeader);

Expand Down Expand Up @@ -570,6 +587,20 @@ public function addMasonry()
}
}

/**
* @param ListConfigModel $listConfig
*/
public function addJumpToOverview(ListConfigModel $listConfig): void
{
$this->setAddOverview($listConfig->addOverview);

$pageJumpTo = System::getContainer()->get('huh.utils.url')->getJumpToPageObject($listConfig->jumpToOverview);

if (null !== $pageJumpTo) {
$this->setJumpToOverview($pageJumpTo->getAbsoluteUrl());
}
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -1066,4 +1097,36 @@ public function getFilterConfig(): ?FilterConfig
{
return $this->_filterConfig;
}

/**
* @return string
*/
public function getJumpToOverview(): ?string
{
return $this->_jumpToOverview;
}

/**
* @param string $jumpToOverview
*/
public function setJumpToOverview(string $jumpToOverview): void
{
$this->_jumpToOverview = $jumpToOverview;
}

/**
* @param bool $addOverview
*/
public function setAddOverview(bool $addOverview)
{
$this->_addOverview = $addOverview;
}

/**
* @return bool
*/
public function getAddOverview(): bool
{
return $this->_addOverview;
}
}
25 changes: 25 additions & 0 deletions src/Lists/ListInterface.php
Expand Up @@ -274,4 +274,29 @@ public function getJumpTo(): int;
* @return array
*/
public function getSearchablePages(array $arrPages, int $intRoot = 0, bool $blnIsSitemap = false): array;


/**
* @param bool $addOverview
*/
public function setAddOverview(bool $addOverview);

/**
* @return bool
*/
public function getAddOverview(): bool;

/**
* get jumpTo page for list overview
*
* @return int
*/
public function getJumpToOverview(): ?string;

/**
* set jumpTo page for list overview
*
* @param string $jumpToOverview
*/
public function setJumpToOverview(string $jumpToOverview);
}
22 changes: 21 additions & 1 deletion src/Resources/contao/dca/tl_list_config.php
Expand Up @@ -86,8 +86,9 @@
'addShare',
'addAjaxPagination',
'addMasonry',
'addOverview'
],
'default' => '{general_legend},title,parentListConfig;'.'{filter_legend},filter;'.'{config_legend},manager,list,item,numberOfItems,perPage,skipFirst,doNotRenderEmpty,showItemCount,showNoItemsText,showInitialResults,limitFormattedFields,isTableList;'.'{sorting_legend},sortingMode;'.'{jumpto_legend},useAlias,addDetails,addShare;'.'{action_legend},addHashToAction,removeAutoItemFromAction;'.'{misc_legend},addAjaxPagination,addMasonry,addDcMultilingualSupport;'.'{search_legend},noSearch,doNotIndexItems;'.'{template_legend},listTemplate,itemTemplate,itemChoiceTemplate;',
'default' => '{general_legend},title,parentListConfig;'.'{filter_legend},filter;'.'{config_legend},manager,list,item,numberOfItems,perPage,skipFirst,doNotRenderEmpty,showItemCount,showNoItemsText,showInitialResults,limitFormattedFields,isTableList;'.'{sorting_legend},sortingMode;'.'{jumpto_legend},useAlias,addDetails,addShare,addOverview;'.'{action_legend},addHashToAction,removeAutoItemFromAction;'.'{misc_legend},addAjaxPagination,addMasonry,addDcMultilingualSupport;'.'{search_legend},noSearch,doNotIndexItems;'.'{template_legend},listTemplate,itemTemplate,itemChoiceTemplate;',
],
'subpalettes' => [
'showItemCount' => 'itemCountText',
Expand All @@ -102,6 +103,7 @@
'addShare' => 'jumpToShare,shareAutoItem',
'addAjaxPagination' => 'ajaxPaginationTemplate,addInfiniteScroll',
'addMasonry' => 'masonryStampContentElements',
'addOverview' => 'jumpToOverview'
],
'fields' => [
'id' => [
Expand Down Expand Up @@ -515,6 +517,24 @@
'eval' => ['tl_class' => 'w50'],
'sql' => "char(1) NOT NULL default ''",
],
'addOverview' => [
'label' => &$GLOBALS['TL_LANG']['tl_list_config']['addOverview'],
'exclude' => true,
'inputType' => 'checkbox',
'search' => true,
'default' => true,
'eval' => ['tl_class' => 'w50', 'submitOnChange' => true],
'sql' => "char(1) NOT NULL default ''",
],
'jumpToOverview' => [
'label' => &$GLOBALS['TL_LANG']['tl_list_config']['jumpToOverview'],
'exclude' => true,
'inputType' => 'pageTree',
'foreignKey' => 'tl_page.title',
'eval' => ['fieldType' => 'radio', 'tl_class' => 'clr', 'mandatory' => true],
'sql' => "int(10) unsigned NOT NULL default '0'",
'relation' => ['type' => 'hasOne', 'load' => 'eager'],
],
],
];

Expand Down
4 changes: 4 additions & 0 deletions src/Resources/contao/languages/de/tl_list_config.php
Expand Up @@ -77,6 +77,10 @@
$lang['jumpToShare'][1] = 'Wählen Sie hier die Seite aus, zu der weitergeleitet wird, wenn ein Inhalt geteilt wurde.';
$lang['shareAutoItem'][0] = 'Auto-Item für den Teilen-Link verwenden';
$lang['shareAutoItem'][1] = 'Wählen Sie diese Option aus, um das Share Token als auto_item auszugeben.';
$lang['addOverview'][0] = 'Link zur Übersichtsseite hinzufügen';
$lang['addOverview'][1] = 'Wählen Sie diese Option aus, um der Liste einen Link zur Übersichtsseite hinzuzufügen.';
$lang['jumpToOverview'][0] = 'Übersichtsseite';
$lang['jumpToOverview'][1] = '';

// misc
$lang['addAjaxPagination'][0] = 'Ajax-Paginierung hinzufügen';
Expand Down
1 change: 1 addition & 0 deletions src/Resources/translations/messages.de.yml
@@ -1,5 +1,6 @@
# labels
huh.list.labels.ajaxPaginationNext: Mehr laden
huh.list.labels.overview: zur Übersicht

# misc
huh.list.misc.detailsTitle: Details
Expand Down
6 changes: 6 additions & 0 deletions src/Resources/views/list/list_default.html.twig
Expand Up @@ -13,5 +13,11 @@
{% elseif showNoItemsText %}
<p class="no-items">{{ noItemsText|raw }}</p>
{% endif %}

{% if addOverview|default %}
<div class="overview">
<a href="{{ jumpToOverview }}" role="button">{{ 'huh.list.labels.overview'|trans }}</a>
</div>
{% endif %}
{% endif %}
</div>
5 changes: 5 additions & 0 deletions src/Resources/views/list/list_table_default.html.twig
Expand Up @@ -40,5 +40,10 @@
{% elseif showNoItemsText %}
<p class="no-items">{{ noItemsText|raw }}</p>
{% endif %}
{% if addOverview|default %}
<div class="overview">
<a href="{{ jumpToOverview }}" role="button">{{ 'huh.list.labels.overview'|trans }}</a>
</div>
{% endif %}
{% endif %}
</div>

0 comments on commit 4b7aa38

Please sign in to comment.