Skip to content

Commit

Permalink
DEBUG better understand the issue/render tree
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Aug 19, 2021
1 parent 14bc444 commit 0089581
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
10 changes: 0 additions & 10 deletions demos/interactive/modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,6 @@
$stepModal->js(true)->modal('refresh');
});

// Bind next action to modal next button.
$nextAction->on('click', $stepModal->js()->atkReloadView(
['uri' => $stepModal->cb->getJsUrl(), 'uri_options' => ['move' => 'next']]
));

// Bin prev action to modal previous button.
$prevAction->on('click', $stepModal->js()->atkReloadView(
['uri' => $stepModal->cb->getJsUrl(), 'uri_options' => ['move' => 'prev']]
));

// Bind display modal to page display button.
$menuBar = \Atk4\Ui\View::addTo($app, ['ui' => 'buttons']);
$button = \Atk4\Ui\Button::addTo($menuBar)->set('Multi Step Modal');
Expand Down
2 changes: 2 additions & 0 deletions src/Callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ protected function init(): void
public function setUrlTrigger(string $trigger = null)
{
$this->urlTrigger = $trigger ?: $this->name;

// $this->getOwner()->stickyGet(self::URL_QUERY_TRIGGER_PREFIX . $this->urlTrigger);
}

public function getUrlTrigger(): string
Expand Down
21 changes: 20 additions & 1 deletion src/JsReload.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,28 @@ public function __construct($view, $args = [], $afterSuccess = null, $apiConfig
$this->apiConfig = $apiConfig;
$this->includeStorage = $includeStorage;
}


public function dumpRenderTree(View $view, bool $rec = false): void
{
if ($view->issetOwner() && $view->getOwner() instanceof View) {
$this->dumpRenderTree($view->getOwner(), true);
}

echo get_class($view);

echo "\n" . (!$rec ? "\n\n" : '');
}
public function jsRender(): string
{
ini_set('output_buffering', (string) (1024 * 1024));
ob_start();
$this->dumpRenderTree($this->view);
// test URL: /demos/interactive/modal.php?__atk_m=atk_layout_maestro_modal_5&__atk_cbtarget=atk_layout_maestro_modal_5_view_callbacklater&__atk_cb_atk_layout_maestro_modal_5_view_callbacklater=ajax&__atk_json=1
echo 'actual: '; var_dump($this->view->jsUrl(['__atk_reload' => $this->view->name]));
echo 'expected: string(166) "modal.php?__atk_m=atk_layout_maestro_modal_5&__atk_cb_atk_layout_maestro_modal_5_view_callbacklater=ajax&__atk_reload=atk_layout_maestro_modal_5_view_demos_viewtester"' . "\n";
ob_end_flush();
exit;

$final = (new Jquery($this->view))
->atkReloadView(
[
Expand Down
8 changes: 7 additions & 1 deletion src/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,7 @@ public function url($page = [])
protected function getRunningCallbackArgs(bool $isTerminated, array $page): array
{
$args = [];

foreach ($this->elements as $v) {
if ($v instanceof Callback) { // @phpstan-ignore-line
if (($page[Callback::URL_QUERY_TARGET] ?? null) === $v->getUrlTrigger()) {
Expand All @@ -631,8 +632,13 @@ protected function getRunningCallbackArgs(bool $isTerminated, array $page): arra
}
}

$parentRenderView = null;
if ($this->issetOwner() && $this->getOwner() instanceof self) {
$args = array_merge($this->getOwner()->getRunningCallbackArgs($isTerminated, $page), $args);
$parentRenderView = $this->getOwner();
} // else

if ($parentRenderView !== null) {
$args = array_merge($parentRenderView->getRunningCallbackArgs($isTerminated, $page), $args);
}

return $args;
Expand Down

0 comments on commit 0089581

Please sign in to comment.