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

fix segments list order #10938

Merged
merged 2 commits into from Mar 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions app/bundles/LeadBundle/Controller/ListController.php
Expand Up @@ -68,7 +68,7 @@ public function indexAction($page = 1)
$this->setListFilters();

//set limits
$limit = $session->get('mautic.segment.limit', $this->coreParametersHelper->get('default_pagelimit'));
$limit = $session->get('mautic.lead.list.limit', $this->coreParametersHelper->get('default_pagelimit'));
$start = (1 === $page) ? 0 : (($page - 1) * $limit);
if ($start < 0) {
$start = 0;
Expand All @@ -78,8 +78,8 @@ public function indexAction($page = 1)
$session->set('mautic.segment.filter', $search);

//do some default filtering
$orderBy = $session->get('mautic.segment.orderby', 'l.dateModified');
$orderByDir = $session->get('mautic.segment.orderbydir', 'DESC');
$orderBy = $session->get('mautic.lead.list.orderby', 'l.dateModified');
$orderByDir = $session->get('mautic.lead.list.orderbydir', $this->getDefaultOrderDirection());

$filter = [
'string' => $search,
Expand Down Expand Up @@ -997,4 +997,9 @@ public function contactsAction($objectId, $page = 1)
$listFilters
);
}

protected function getDefaultOrderDirection()
{
return 'DESC';
}
}
26 changes: 26 additions & 0 deletions app/bundles/LeadBundle/Tests/Controller/ListControllerTest.php
Expand Up @@ -3,10 +3,33 @@
namespace Mautic\LeadBundle\Tests\Controller;

use Mautic\CoreBundle\Test\MauticMysqlTestCase;
use Mautic\CoreBundle\Tests\Traits\ControllerTrait;
use Mautic\LeadBundle\Entity\LeadList;

class ListControllerTest extends MauticMysqlTestCase
{
use ControllerTrait;

/**
* Index action should return status code 200.
*/
public function testIndexAction(): void
{
$list = $this->createList();

$this->em->persist($list);
$this->em->flush();
$this->em->clear();

$urlAlias = 'segments';
$routeAlias = 'leadlist';
$column = 'dateModified';
$column2 = 'name';
$tableAlias = 'l.';

$this->getControllerColumnTests($urlAlias, $routeAlias, $column, $tableAlias, $column2);
}

/**
* Check if list contains correct values.
*/
Expand Down Expand Up @@ -48,6 +71,9 @@ private function createList(string $suffix = 'A'): LeadList
$list->setName("Segment $suffix");
$list->setPublicName("Segment $suffix");
$list->setAlias("segment-$suffix");
$list->setDateAdded(new \DateTime('2020-02-07 20:29:02'));
$list->setDateModified(new \DateTime('2020-03-21 20:29:02'));
$list->setCreatedByUser('Test User');

return $list;
}
Expand Down
14 changes: 7 additions & 7 deletions app/bundles/LeadBundle/Views/List/list.html.php
Expand Up @@ -41,7 +41,7 @@
echo $view->render(
'MauticCoreBundle:Helper:tableheader.html.php',
[
'sessionVar' => 'segment',
'sessionVar' => 'lead.list',
'orderBy' => 'l.name',
'text' => 'mautic.core.name',
'class' => 'col-leadlist-name',
Expand All @@ -51,7 +51,7 @@
echo $view->render(
'MauticCoreBundle:Helper:tableheader.html.php',
[
'sessionVar' => 'segment',
'sessionVar' => 'lead.list',
'text' => 'mautic.lead.list.thead.leadcount',
'class' => 'visible-md visible-lg col-leadlist-leadcount',
]
Expand All @@ -60,7 +60,7 @@
echo $view->render(
'MauticCoreBundle:Helper:tableheader.html.php',
[
'sessionVar' => 'segment',
'sessionVar' => 'lead.list',
'orderBy' => 'l.dateAdded',
'text' => 'mautic.lead.import.label.dateAdded',
'class' => 'visible-md visible-lg col-leadlist-dateAdded',
Expand All @@ -70,7 +70,7 @@
echo $view->render(
'MauticCoreBundle:Helper:tableheader.html.php',
[
'sessionVar' => 'segment',
'sessionVar' => 'lead.list',
'orderBy' => 'l.dateModified',
'text' => 'mautic.lead.import.label.dateModified',
'class' => 'visible-md visible-lg col-leadlist-dateModified',
Expand All @@ -81,7 +81,7 @@
echo $view->render(
'MauticCoreBundle:Helper:tableheader.html.php',
[
'sessionVar' => 'segment',
'sessionVar' => 'lead.list',
'orderBy' => 'l.createdByUser',
'text' => 'mautic.core.createdby',
'class' => 'visible-md visible-lg col-leadlist-createdByUser',
Expand All @@ -91,7 +91,7 @@
echo $view->render(
'MauticCoreBundle:Helper:tableheader.html.php',
[
'sessionVar' => 'segment',
'sessionVar' => 'lead.list',
'orderBy' => 'l.id',
'text' => 'mautic.core.id',
'class' => 'visible-md visible-lg col-leadlist-id',
Expand Down Expand Up @@ -214,7 +214,7 @@
'page' => $page,
'limit' => $limit,
'baseUrl' => $view['router']->path('mautic_segment_index'),
'sessionVar' => 'segment',
'sessionVar' => 'lead.list',
]
); ?>
</div>
Expand Down