Skip to content

Commit

Permalink
hack CardDeck to honor reload when string is returned from UA execute
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Feb 22, 2023
1 parent 8a32036 commit 93beb6d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/CardDeck.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,11 @@ protected function initActionExecutor(Model\UserAction $action): ExecutorInterfa
protected function jsExecute($return, Model\UserAction $action): JsBlock
{
if (is_string($return)) {
// hack to test reload with read only demos
if (str_ends_with($return, 'was executed. In demo mode all changes are reverved.')) {
return $this->jsModelReturn($action, $return);
}

return $this->jsCreateNotifier($action, $return);
} elseif ($return instanceof JsExpressionable) {
return new JsBlock([$return]);
Expand Down Expand Up @@ -259,7 +264,7 @@ protected function jsModelReturn(Model\UserAction $action, string $msg = 'Done!'
{
$res = new JsBlock();
$res->addStatement($this->jsCreateNotifier($action, $msg));
$card = $action->getEntity()->isLoaded() ? $this->findCard($action->getEntity()) : null;
$card = $action->isOwnerEntity() && $action->getEntity()->isLoaded() ? $this->findCard($action->getEntity()) : null;
if ($card !== null) {
$res->addStatement($card->jsReload($this->getReloadArgs()));
} else {
Expand Down

0 comments on commit 93beb6d

Please sign in to comment.