-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [fix] VirtualPage Fix for #1587 Callable for VirtualPage should be called prior to VirtualPage::getHtml() in order to make sure nested callback (Lookup) can be reach. * cs fix * phpstan * fix test * more fix * Add behat test * fix typo * phpstan * phpstan * fix typo * fixes * fix test * phpstan
- Loading branch information
Showing
8 changed files
with
70 additions
and
84 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* Test for Lookup inside VirtualPage. | ||
*/ | ||
|
||
namespace Atk4\Ui\Demos; | ||
|
||
use Atk4\Ui\Form; | ||
use Atk4\Ui\Grid; | ||
use Atk4\Ui\JsModal; | ||
use Atk4\Ui\JsToast; | ||
use Atk4\Ui\VirtualPage; | ||
|
||
/** @var \Atk4\Ui\App $app */ | ||
require_once __DIR__ . '/../init-app.php'; | ||
|
||
$product = new ProductLock($app->db); | ||
|
||
$vp = VirtualPage::addTo($app); | ||
|
||
$vp->set(function ($page) { | ||
$form = Form::addTo($page); | ||
$form->addControl('category', [Form\Control\Lookup::class, 'model' => new Category($page->getApp()->db)]); | ||
$form->onSubmit(function ($f) { | ||
$category = $f->getControl('category')->model->load($f->model->get('category')); | ||
|
||
return new JsToast($category->getTitle()); | ||
}); | ||
}); | ||
|
||
$g = Grid::addTo($app, ['menu' => ['class' => ['atk-grid-menu']]]); | ||
$g->setModel($product); | ||
|
||
$g->menu->addItem( | ||
['Add Category'], | ||
new JsModal('New Category', $vp) | ||
); |
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
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 |
---|---|---|
@@ -1,12 +1,17 @@ | ||
Feature: Lookup | ||
Testing Lookup control | ||
|
||
Scenario: | ||
Given I am on "_unit-test/lookup.php" | ||
|
||
Scenario: Testing lookup in modal | ||
Given I am on "_unit-test/lookup.php" | ||
Then I press button "Edit" | ||
Then I select value "Dairy" in lookup "atk_fp_product__product_category_id" | ||
Then I select value "Yogourt" in lookup "atk_fp_product__product_sub_category_id" | ||
Then I press button "EditMe" | ||
Then Toast display should contains text 'Dairy - Yogourt' | ||
|
||
Scenario: Testing lookup in VirtualPage | ||
Given I am on "_unit-test/lookup-virtual-page.php" | ||
Then I press menu button "Add Category" using class "atk-grid-menu" | ||
Then I select value "Beverages" in lookup "category" | ||
Then I press Modal button "Save" | ||
Then Toast display should contains text 'Beverages' |
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