Add ability to turn the sorting off for a clicked column in GridView with multisort (#18826)

* Add ability to turn the sorting off for a clicked column in GridView with multisort

* Update Sort.php

* Fix SortTest

* Update CHANGELOG.md

Co-authored-by: Bizley <pawel@positive.codes>
This commit is contained in:
Andrew
2021-08-11 14:37:37 +03:00
committed by GitHub
parent c94d7049c5
commit 463a67bc73
3 changed files with 38 additions and 3 deletions

View File

@@ -163,8 +163,30 @@ class SortTest extends TestCase
'route' => 'site/index',
]);
$sort->params = ['sort' => 'age,-name'];
$sort->getAttributeOrders(true);
$this->assertEquals('-age,-name', $sort->createSortParam('age'));
$this->assertEquals('age', $sort->createSortParam('name'));
$sort->params = ['sort' => 'age'];
$sort->getAttributeOrders(true);
$this->assertEquals('-age', $sort->createSortParam('age'));
$sort->params = ['sort' => '-age'];
$sort->getAttributeOrders(true);
$this->assertEquals('', $sort->createSortParam('age'));
$sort->params = ['sort' => 'age'];
$sort->getAttributeOrders(true);
$this->assertEquals('name,age', $sort->createSortParam('name'));
$sort->params = ['sort' => 'name,age'];
$sort->getAttributeOrders(true);
$this->assertEquals('-name,age', $sort->createSortParam('name'));
$sort->params = ['sort' => '-name,age'];
$sort->getAttributeOrders(true);
$this->assertEquals('age', $sort->createSortParam('name'));
}
public function testCreateUrl()
@@ -192,7 +214,7 @@ class SortTest extends TestCase
]);
$this->assertEquals('/index.php?r=site%2Findex&sort=-age%2C-name', $sort->createUrl('age'));
$this->assertEquals('/index.php?r=site%2Findex&sort=name%2Cage', $sort->createUrl('name'));
$this->assertEquals('/index.php?r=site%2Findex&sort=age', $sort->createUrl('name'));
}
/**