From 88ac5e8f5001da8683637944e60109f9fe77bcd9 Mon Sep 17 00:00:00 2001 From: Alain Belair Date: Mon, 27 Jan 2020 14:03:51 -0500 Subject: [PATCH 1/2] Fix/UserAction Validation error Properly catch Data Validation error in UserAction executor. --- src/ActionExecutor/UserAction.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/ActionExecutor/UserAction.php b/src/ActionExecutor/UserAction.php index 90d66955e1..eadf318d4f 100644 --- a/src/ActionExecutor/UserAction.php +++ b/src/ActionExecutor/UserAction.php @@ -7,6 +7,7 @@ use atk4\core\HookTrait; use atk4\data\UserAction\Generic; +use atk4\data\ValidationException; use atk4\ui\Button; use atk4\ui\Exception; use atk4\ui\Form; @@ -543,19 +544,22 @@ protected function jsStepSubmit(string $step) if ($this->isLastStep($step)) { // collect argument and execute action. $return = $this->action->execute(...$this->_getActionArgs($this->actionData['args'] ?? [])); - $js = $this->jsGetExecute($return, $this->action->owner->id); - } else { + $js = $this->jsGetExecute($return, $this->action->owner->id); + } + else { // store data and setup reload. $js = [ $this->loader->jsAddStoreData($this->actionData, true), $this->loader->jsload([ - 'step' => $this->getNextStep($step), - $this->name => $this->action->owner->get('id'), - ], ['method' => 'post'], $this->loader->name), + 'step' => $this->getNextStep($step), + $this->name => $this->action->owner->get('id'), + ], ['method' => 'post'], $this->loader->name), ]; } return $js; + } catch (ValidationException $e) { + throw $e; } catch (\Exception $e) { $m = new Message('Error executing '.$this->action->caption, 'red'); $m->init(); From 6e0b2ff57aa30995191a44522d8fddfe067a1124 Mon Sep 17 00:00:00 2001 From: Alain Belair Date: Mon, 27 Jan 2020 19:04:13 +0000 Subject: [PATCH 2/2] Apply fixes from StyleCI --- src/ActionExecutor/UserAction.php | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/ActionExecutor/UserAction.php b/src/ActionExecutor/UserAction.php index eadf318d4f..4eaeb9dfc4 100644 --- a/src/ActionExecutor/UserAction.php +++ b/src/ActionExecutor/UserAction.php @@ -544,16 +544,15 @@ protected function jsStepSubmit(string $step) if ($this->isLastStep($step)) { // collect argument and execute action. $return = $this->action->execute(...$this->_getActionArgs($this->actionData['args'] ?? [])); - $js = $this->jsGetExecute($return, $this->action->owner->id); - } - else { + $js = $this->jsGetExecute($return, $this->action->owner->id); + } else { // store data and setup reload. $js = [ $this->loader->jsAddStoreData($this->actionData, true), $this->loader->jsload([ - 'step' => $this->getNextStep($step), - $this->name => $this->action->owner->get('id'), - ], ['method' => 'post'], $this->loader->name), + 'step' => $this->getNextStep($step), + $this->name => $this->action->owner->get('id'), + ], ['method' => 'post'], $this->loader->name), ]; }