<commit_before><?php

require 'init.php';
require 'database.php';

$country = new Country($db);
$id = $country->tryLoadAny()->get('id');

$app->add(['Button', 'Actions in Grid', 'small right floated basic blue', 'iconRight' => 'right arrow'])
    ->link(['jsactionsgrid']);

$app->add(['Button', 'Action from Js Event', 'small left floated basic blue', 'icon' => 'left arrow'])
    ->link(['jsactions']);
$app->add(['View', 'ui' => 'ui clearing divider']);

$gl = $app->add(['GridLayout', 'rows' => 1, 'columns' => 2]);
$c = $gl->add(['Card', 'useLabel' => true], 'r1c1');
$c->setModel($country, ['name', 'iso', 'iso3', 'phonecode']);

$buttons = $gl->add(['ui'=>'vertical basic buttons'], 'r1c2');


$country->unload();

/*
// For demonstration purpose with add, edit and delete action.

$ac = $country->getAction('add');
$add_button = $buttons->add(['Button', $ac->getDescription()]);
$add_button->on('click', $ac);

$ac = $country->getAction('edit');
$btn = $buttons->add(['Button', $ac->getDescription()]);
$btn->on('click', $ac, ['args' => ['id' => $field->jsInput()->val()]]);

$ac = $country->getAction('delete');
$btn = $buttons->add(['Button', $ac->getDescription()]);
$btn->on('click', $ac, ['confirm' => 'This will delete record. Sure?']);
*/

// clicking button should simply display toast ok with model title
$ac = $country->addAction('callback', ['callback'=> function ($m) {
    return 'ok '.$m->getTitle();
}]);
$btn = $buttons->add(['Button', $ac->getDescription()]);
$btn->on('click', $ac, [$id]);

// clicking button should show preview window wiht OK. If OK is pressed should close window and display toast OK
$ac = $country->addAction('preview', ['preview'=> function ($m) {<commit_msg>Apply fixes from StyleCI<commit_after><?php

require 'init.php';
require 'database.php';

$country = new Country($db);
$id = $country->tryLoadAny()->get('id');

$app->add(['Button', 'Actions in Grid', 'small right floated basic blue', 'iconRight' => 'right arrow'])
    ->link(['jsactionsgrid']);

$app->add(['Button', 'Action from Js Event', 'small left floated basic blue', 'icon' => 'left arrow'])
    ->link(['jsactions']);
$app->add(['View', 'ui' => 'ui clearing divider']);

$gl = $app->add(['GridLayout', 'rows' => 1, 'columns' => 2]);
$c = $gl->add(['Card', 'useLabel' => true], 'r1c1');
$c->setModel($country, ['name', 'iso', 'iso3', 'phonecode']);

$buttons = $gl->add(['ui'=>'vertical basic buttons'], 'r1c2');

$country->unload();

/*
// For demonstration purpose with add, edit and delete action.

$ac = $country->getAction('add');
$add_button = $buttons->add(['Button', $ac->getDescription()]);
$add_button->on('click', $ac);

$ac = $country->getAction('edit');
$btn = $buttons->add(['Button', $ac->getDescription()]);
$btn->on('click', $ac, ['args' => ['id' => $field->jsInput()->val()]]);

$ac = $country->getAction('delete');
$btn = $buttons->add(['Button', $ac->getDescription()]);
$btn->on('click', $ac, ['confirm' => 'This will delete record. Sure?']);
*/

// clicking button should simply display toast ok with model title
$ac = $country->addAction('callback', ['callback'=> function ($m) {
    return 'ok '.$m->getTitle();
}]);
$btn = $buttons->add(['Button', $ac->getDescription()]);
$btn->on('click', $ac, [$id]);

// clicking button should show preview window wiht OK. If OK is pressed should close window and display toast OK
$ac = $country->addAction('preview', ['preview'=> function ($m) {
{'fraction_non_alphanumeric': 0.25759345794392524, 'fraction_numerical': 0.0040887850467289715, 'mean_word_length': 5.728880157170924, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 91, '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': '4078547', 'n_tokens_mistral': 1119, 'n_tokens_neox': 1108, 'n_words': 305}