<commit_before><?php
/**
 * Modal executor for action.
 */

namespace atk4\ui\ActionExecutor;

use atk4\core\HookTrait;
use atk4\data\UserAction\Generic;
use atk4\ui\Button;
use atk4\ui\Exception;
use atk4\ui\Form;
use atk4\ui\jsExpressionable;
use atk4\ui\jsFunction;
use atk4\ui\jsToast;
use atk4\ui\Message;
use atk4\ui\Modal;
use atk4\ui\View;

class UserAction extends Modal implements Interface_, jsInterface_
{
    use HookTrait;

    /**
     * @var jsExpressionable array|callable jsExpression to return if action was successful, e.g "new jsToast('Thank you')"
     */
    public $jsSuccess = null;

    /**
     * @var array Will collect action data while doing action step.
     */
    private $actionData = [];
    protected $actionInitialized = false;

    /**
     * The action to execute.
     *
     * @var Generic
     */
    public $action = null;

    /**
     * The action steps.
     *
     * @var null
     */
    private $steps = null;
    private $step = null;

    /**
     * The action step button.
     *
     * @var null
     */
    private $prevStepBtn = null;
    private $nextStepBtn = null;
    private $execActionBtn = null;
    private $btns = null;

    /**
     * A form for action argument and fields user entry.
     *
     * @var string
     */
    public $form = Form::class;

    /**
     * @var string can be "console", "text", or "html"
     */
    public $previewType = 'html';

    /**
     * View seed for displaying title for each step.
     *
     * @var array
     */
    public $stepTitle = ['args' => null, 'fields' => null, 'preview' => null];

    /**
     * The Loader that will execute all action step.
     *
     * @var null
     */
    public $loader = null;
    public $loaderUi = 'ui basic segment';
    public $loaderShim = [];

    public function init()
    {
        parent::init();
        $this->observeChanges();

        //Add buttons to modal for next and previous.
        $this->btns = (new View())->addStyle(['min-height' => '24px']);
        $this->prevStepBtn = $this->btns->add(new Button(['Prev']))->addStyle(['float' => 'left !important']);
        $this->nextStepBtn = $this->btns->add(new Button(['Next', 'blue']));
        $this->addButtonAction($this->btns);

        $this->loader = $this->add(['Loader', 'ui'   => $this->loaderUi, 'shim' => $this->loaderShim]);
        $this->loader->loadEvent = false;
        $this->loader->addClass('atk-hide-loading-content');
        $this->actionData = $this->loader->jsGetStoreData()['session'];
    }

    /**
     * Will associate executor with the action.
     *
     * @param Generic $action
     *
     * @throws \atk4\core\Exception
     * @throws \atk4\data\Exception
     *
     * @return UserAction
     */
    public function setAction(Generic $action) :View
    {
        $this->action = $action;

        // get necessary step need prior to execute action.
        if ($this->steps = $this->getSteps($action)) {
            $this->title = trim($action->caption . ' ' . $this->action->owner->getModelCaption());

            $this->btns->add($this->execActionBtn = (new Button([$this->action->caption, 'blue'])));<commit_msg>Apply fixes from StyleCI<commit_after><?php
/**
 * Modal executor for action.
 */

namespace atk4\ui\ActionExecutor;

use atk4\core\HookTrait;
use atk4\data\UserAction\Generic;
use atk4\ui\Button;
use atk4\ui\Exception;
use atk4\ui\Form;
use atk4\ui\jsExpressionable;
use atk4\ui\jsFunction;
use atk4\ui\jsToast;
use atk4\ui\Message;
use atk4\ui\Modal;
use atk4\ui\View;

class UserAction extends Modal implements Interface_, jsInterface_
{
    use HookTrait;

    /**
     * @var jsExpressionable array|callable jsExpression to return if action was successful, e.g "new jsToast('Thank you')"
     */
    public $jsSuccess = null;

    /**
     * @var array Will collect action data while doing action step.
     */
    private $actionData = [];
    protected $actionInitialized = false;

    /**
     * The action to execute.
     *
     * @var Generic
     */
    public $action = null;

    /**
     * The action steps.
     *
     * @var null
     */
    private $steps = null;
    private $step = null;

    /**
     * The action step button.
     *
     * @var null
     */
    private $prevStepBtn = null;
    private $nextStepBtn = null;
    private $execActionBtn = null;
    private $btns = null;

    /**
     * A form for action argument and fields user entry.
     *
     * @var string
     */
    public $form = Form::class;

    /**
     * @var string can be "console", "text", or "html"
     */
    public $previewType = 'html';

    /**
     * View seed for displaying title for each step.
     *
     * @var array
     */
    public $stepTitle = ['args' => null, 'fields' => null, 'preview' => null];

    /**
     * The Loader that will execute all action step.
     *
     * @var null
     */
    public $loader = null;
    public $loaderUi = 'ui basic segment';
    public $loaderShim = [];

    public function init()
    {
        parent::init();
        $this->observeChanges();

        //Add buttons to modal for next and previous.
        $this->btns = (new View())->addStyle(['min-height' => '24px']);
        $this->prevStepBtn = $this->btns->add(new Button(['Prev']))->addStyle(['float' => 'left !important']);
        $this->nextStepBtn = $this->btns->add(new Button(['Next', 'blue']));
        $this->addButtonAction($this->btns);

        $this->loader = $this->add(['Loader', 'ui'   => $this->loaderUi, 'shim' => $this->loaderShim]);
        $this->loader->loadEvent = false;
        $this->loader->addClass('atk-hide-loading-content');
        $this->actionData = $this->loader->jsGetStoreData()['session'];
    }

    /**
     * Will associate executor with the action.
     *
     * @param Generic $action
     *
     * @throws \atk4\core\Exception
     * @throws \atk4\data\Exception
     *
     * @return UserAction
     */
    public function setAction(Generic $action) :View
    {
        $this->action = $action;

        // get necessary step need prior to execute action.
        if ($this->steps = $this->getSteps($action)) {
            $this->title = trim($action->caption.' '.$this->action->owner->getModelCaption());

            $this->btns->add($this->execActionBtn = (new Button([$this->action->caption, 'blue'])));
{'fraction_non_alphanumeric': 0.15584005057689268, 'fraction_numerical': 0.005057689268215584, 'mean_word_length': 2.3767342582710778, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 89, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3931922', 'n_tokens_mistral': 2010, 'n_tokens_neox': 1976, 'n_words': 500}