forked from EasyCorp/EasyAdminBundle
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature EasyCorp#1345 Allow actions to define their "target" HTML att…
…ribute (javiereguiluz) This PR was squashed before being merged into the master branch (closes EasyCorp#1345). Discussion ---------- Allow actions to define their "target" HTML attribute This fixes EasyCorp#1121. Commits ------- fcf17de Allow actions to define their "target" HTML attribute
- Loading branch information
Showing
10 changed files
with
161 additions
and
4 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
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
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
24 changes: 24 additions & 0 deletions
24
Tests/Configuration/fixtures/configurations/input/admin_140.yml
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 @@ | ||
# TEST | ||
# actions can define their 'target' HTML attribute | ||
|
||
# CONFIGURATION | ||
easy_admin: | ||
entities: | ||
Category: | ||
class: AppTestBundle\Entity\UnitTests\Category | ||
list: | ||
actions: | ||
- { name: 'edit', target: '_blank' } | ||
- { name: 'custom_action', target: '_parent' } | ||
- { name: 'another_custom_action' } | ||
edit: | ||
actions: | ||
- { name: 'list', target: '_parent' } | ||
show: | ||
actions: | ||
- { name: 'edit', target: '_self' } | ||
- { name: 'list' } | ||
- { name: 'custom_action', target: 'custom_target' } | ||
new: | ||
actions: | ||
- { name: 'list', target: '_top' } |
25 changes: 25 additions & 0 deletions
25
Tests/Configuration/fixtures/configurations/output/config_140.yml
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,25 @@ | ||
easy_admin: | ||
entities: | ||
Category: | ||
class: AppTestBundle\Entity\UnitTests\Category | ||
list: | ||
actions: | ||
edit: { target: '_blank' } | ||
custom_action: { target: '_parent' } | ||
another_custom_action: { target: '_self' } | ||
delete: { target: '_self' } | ||
new: { target: '_self' } | ||
search: { target: '_self' } | ||
edit: | ||
actions: | ||
list: { target: '_parent' } | ||
delete: { target: '_self' } | ||
new: | ||
actions: | ||
list: { target: '_top' } | ||
show: | ||
actions: | ||
edit: { target: '_self' } | ||
list: { target: '_self' } | ||
custom_action: { target: 'custom_target' } | ||
delete: { target: '_self' } |
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,67 @@ | ||
<?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 JavierEguiluz\Bundle\EasyAdminBundle\Tests\Fixtures\AbstractTestCase; | ||
|
||
class ActionTargetTest extends AbstractTestCase | ||
{ | ||
public function setUp() | ||
{ | ||
parent::setUp(); | ||
|
||
$this->initClient(array('environment' => 'action_target')); | ||
} | ||
|
||
public function testListViewActions() | ||
{ | ||
$crawler = $this->requestListView(); | ||
|
||
$this->assertEquals('_top', $crawler->filter('.global-actions form button[type="submit"]')->attr('formtarget')); | ||
$this->assertEquals('custom_target', $crawler->filter('.button-action a:contains("Add Category")')->attr('target')); | ||
|
||
$this->assertEquals('_blank', $crawler->filter('table a:contains("Edit")')->attr('target')); | ||
$this->assertEquals('_parent', $crawler->filter('table a:contains("Custom action")')->attr('target')); | ||
$this->assertEquals('_self', $crawler->filter('table a:contains("Another custom action")')->attr('target')); | ||
$this->assertEquals('_self', $crawler->filter('table a:contains("Delete")')->attr('target')); | ||
$this->assertEquals('_self', $crawler->filter('#modal-delete-button')->attr('formtarget')); | ||
} | ||
|
||
public function testEditViewActions() | ||
{ | ||
$crawler = $this->requestEditView(); | ||
|
||
$this->assertEquals('_parent', $crawler->filter('.form-actions a:contains("Back to listing")')->attr('target')); | ||
$this->assertEquals('_blank', $crawler->filter('.form-actions a:contains("Custom action")')->attr('target')); | ||
$this->assertEquals('_blank', $crawler->filter('.form-actions a:contains("Delete")')->attr('target')); | ||
$this->assertEquals('_blank', $crawler->filter('#modal-delete-button')->attr('formtarget')); | ||
} | ||
|
||
public function testShowViewActions() | ||
{ | ||
$crawler = $this->requestShowView(); | ||
|
||
$this->assertEquals('_self', $crawler->filter('.form-actions a:contains("Edit")')->attr('target')); | ||
$this->assertEquals('_self', $crawler->filter('.form-actions a:contains("Back to listing")')->attr('target')); | ||
$this->assertEquals('custom_target', $crawler->filter('.form-actions a:contains("Custom action")')->attr('target')); | ||
$this->assertEquals('_self', $crawler->filter('.form-actions a:contains("Delete")')->attr('target')); | ||
$this->assertEquals('_self', $crawler->filter('#modal-delete-button')->attr('formtarget')); | ||
} | ||
|
||
public function testNewViewActions() | ||
{ | ||
$crawler = $this->requestNewView(); | ||
|
||
$this->assertEquals('_top', $crawler->filter('.form-actions a:contains("Back to listing")')->attr('target')); | ||
$this->assertEquals('_parent', $crawler->filter('.form-actions a:contains("Custom action")')->attr('target')); | ||
} | ||
} |
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,28 @@ | ||
imports: | ||
- { resource: config.yml } | ||
|
||
easy_admin: | ||
entities: | ||
Category: | ||
class: AppTestBundle\Entity\FunctionalTests\Category | ||
list: | ||
actions: | ||
- { name: 'edit', target: '_blank' } | ||
- { name: 'search', target: '_top' } | ||
- { name: 'new', target: 'custom_target' } | ||
- { name: 'custom_action', target: '_parent' } | ||
- { name: 'another_custom_action' } | ||
edit: | ||
actions: | ||
- { name: 'list', target: '_parent' } | ||
- { name: 'delete', target: '_blank' } | ||
- { name: 'custom_action', target: '_blank' } | ||
show: | ||
actions: | ||
- { name: 'edit', target: '_self' } | ||
- { name: 'list' } | ||
- { name: 'custom_action', target: 'custom_target' } | ||
new: | ||
actions: | ||
- { name: 'list', target: '_top' } | ||
- { name: 'custom_action', target: '_parent' } |