-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature #345 Allow to use an empty string as the action name (to disp…
…lay only the icon) (javiereguiluz) This PR was squashed before being merged into the master branch (closes #345). Discussion ---------- Allow to use an empty string as the action name (to display only the icon) This fixes #343 Commits ------- 3bb2970 Allow to use an empty string as the action name (to display only the icon)
- Loading branch information
Showing
7 changed files
with
143 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the EasyAdminBundle. | ||
* | ||
* (c) Javier Eguiluz <javier.eguiluz@gmail.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace JavierEguiluz\Bundle\EasyAdminBundle\Tests\Controller; | ||
|
||
use Symfony\Component\DomCrawler\Crawler; | ||
use JavierEguiluz\Bundle\EasyAdminBundle\Tests\Fixtures\AbstractTestCase; | ||
|
||
class EmptyActionLabelsTest extends AbstractTestCase | ||
{ | ||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->initClient(array('environment' => 'empty_action_labels')); | ||
} | ||
|
||
public function testBuiltInActionLabels() | ||
{ | ||
$crawler = $this->requestListView(); | ||
|
||
// show action | ||
$this->assertEquals('', trim($crawler->filter('#main table tr:first-child td.actions a')->eq(0)->text())); | ||
$this->assertEquals('fa fa-search', trim($crawler->filter('#main table tr:first-child td.actions a i')->eq(0)->attr('class'))); | ||
|
||
// edit action | ||
$this->assertEquals('', trim($crawler->filter('#main table tr:first-child td.actions a')->eq(1)->text())); | ||
$this->assertEquals('fa fa-pencil', trim($crawler->filter('#main table tr:first-child td.actions a i')->eq(1)->attr('class'))); | ||
} | ||
|
||
public function testCustomActionLabels() | ||
{ | ||
$crawler = $this->requestListView(); | ||
|
||
// custom action 1 | ||
$this->assertEquals('', trim($crawler->filter('#main table tr:first-child td.actions a')->eq(2)->text())); | ||
$this->assertEquals('fa fa-icon1', trim($crawler->filter('#main table tr:first-child td.actions a i')->eq(2)->attr('class'))); | ||
|
||
// custom action 2 | ||
$this->assertEquals('', trim($crawler->filter('#main table tr:first-child td.actions a')->eq(3)->text())); | ||
$this->assertEquals('fa fa-icon2', trim($crawler->filter('#main table tr:first-child td.actions a i')->eq(3)->attr('class'))); | ||
} | ||
|
||
public function testFalseActionLabels() | ||
{ | ||
$crawler = $this->requestListView(); | ||
|
||
// custom action with 'false' label used as a string instead of a boolean | ||
$this->assertEquals('false', trim($crawler->filter('#main table tr:first-child td.actions a')->eq(4)->text())); | ||
$this->assertEquals('fa fa-icon3', trim($crawler->filter('#main table tr:first-child td.actions a i')->eq(4)->attr('class'))); | ||
} | ||
|
||
/** | ||
* @return Crawler | ||
*/ | ||
private function requestListView($entityName = 'Category') | ||
{ | ||
return $this->getBackendPage(array( | ||
'action' => 'list', | ||
'entity' => $entityName, | ||
'view' => 'list', | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
imports: | ||
- { resource: config.yml } | ||
|
||
framework: | ||
# This file overrides the EasyAdmin controller | ||
router: { resource: "%kernel.root_dir%/config/routing_override.yml" } | ||
|
||
easy_admin: | ||
entities: | ||
Category: | ||
class: JavierEguiluz\Bundle\EasyAdminBundle\Tests\Fixtures\AppTestBundle\Entity\Category | ||
label: 'Categories' | ||
list: | ||
actions: | ||
# override a built-in action with an empty label | ||
- { name: 'show', label: '', icon: 'search' } | ||
# override a built-in action with a false label | ||
- { name: 'edit', label: false, icon: 'pencil' } | ||
# custom action with an empty label | ||
- { name: 'action1', label: '', icon: 'icon1' } | ||
# custom action with a false label | ||
- { name: 'action2', label: false, icon: 'icon2' } | ||
# if 'false' is used as a string, it should be dispalyed as is | ||
- { name: 'action3', label: 'false', icon: 'icon3' } |