<commit_before><?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\data\ArrayDataProvider;
use yii\jui\Sortable;
use frontend\assets\BanTheCanAsset;

BanTheCanAsset::register($this);
/* @var $this yii\web\View */
$this->params['breadcrumbs'][] = $this->title;
?>

<div class="site-kanbanboard">
    <h1><?= Html::encode($boardTitle) ?></h1>
    <small><em><?= Html::encode($boardDescription) ?></em></small>
    <div id="info"></div>

    <?php
    // Create HTML Div Element for each Ticket using $columnId as an index to the column
    // Tickets are appended to one another and wrapped by a sortable div element
    // This dive then becomes the contents of one table cell
    // They need to be appended to one another as they are evaluated in the loop

    //initialize gridRow array
    foreach ($columnData as $column) {
        $gridRow[$column['attribute']] = [];
    }

    //fill grid row array with tickets
    foreach ($ticketData as $ticketRecord) {
        $widgetId = 'ticketwidget_'. $ticketRecord['ticketId'];
        $gridRow[$ticketRecord['columnId']][] = [
            'content' => $this->render('../ticket/_ticketBlock', ['ticketRecord' => $ticketRecord]),
            'options' => [
                'id' => $widgetId,
                'tag' => 'div',
                'class' => 'ticket-widget',
            ],
        ];
    }

    // Wrap gridRow column contents into a sortable div element.
    foreach ($columnData as $column) {
        $cIndex = $column['attribute'];
        $gridRow[$cIndex] = Sortable::widget([
            'items' => $gridRow[$cIndex],
            'options' => ['id' => 'boardColumn_' . $cIndex, 'tag' => 'div', 'class' => 'board-column'],
            'clientOptions' => [
                'cursor' => 'move',
                'connectWith' => ($cIndex != 6 ? '#boardColumn_' . ($cIndex + 1) : '#boardColumn_1'),
            ],
            'clientEvents' => [
                'receive' => 'function (event, ui) {
                    columnTicketOrder(event, ui, this);
                }',
                'update' => 'function (event, ui) {
                    columnTicketOrder(event, ui, this);
                }',
            ],
        ]);
    }

    $dataProvider = new ArrayDataProvider([
        'allModels' => [$gridRow],
        'sort' => false,
        'pagination' => false,
    ]);

    // create Column Data array compatible for consumption by GridView
    // column data and ticket data are related but processed separately
    foreach ($columnData as $column) {
        $gridColumn[] = [<commit_msg>Sortable with Ajax update on Server, jquery events coordinated<commit_after><?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\data\ArrayDataProvider;
use yii\jui\Sortable;
use frontend\assets\BanTheCanAsset;

BanTheCanAsset::register($this);
/* @var $this yii\web\View */
$this->params['breadcrumbs'][] = $this->title;
?>

<div class="site-kanbanboard">
    <h1><?= Html::encode($boardTitle) ?></h1>
    <small><em><?= Html::encode($boardDescription) ?></em></small>
    <div id="info"></div>

    <?php
    // Create HTML Div Element for each Ticket using $columnId as an index to the column
    // Tickets are appended to one another and wrapped by a sortable div element
    // This dive then becomes the contents of one table cell
    // They need to be appended to one another as they are evaluated in the loop

    //initialize gridRow array
    foreach ($columnData as $column) {
        $gridRow[$column['attribute']] = [];
    }

    //fill grid row array with tickets
    foreach ($ticketData as $ticketRecord) {
        $widgetId = 'ticketwidget_'. $ticketRecord['ticketId'];
        $gridRow[$ticketRecord['columnId']][] = [
            'content' => $this->render('../ticket/_ticketBlock', ['ticketRecord' => $ticketRecord]),
            'options' => [
                'id' => $widgetId,
                'tag' => 'div',
                'class' => 'ticket-widget',
            ],
        ];
    }

    // Wrap gridRow column contents into a sortable div element.
    // see http://stackoverflow.com/questions/5586558/jquery-ui-sortable-disable-update-function-before-receive
    // for info about triggering the events
    foreach ($columnData as $column) {
        $cIndex = $column['attribute'];
        $gridRow[$cIndex] = Sortable::widget([
            'items' => $gridRow[$cIndex],
            'options' => ['id' => 'boardColumn_' . $cIndex, 'tag' => 'div', 'class' => 'board-column'],
            'clientOptions' => [
                'cursor' => 'move',
                'connectWith' => ($cIndex != 6 ? '#boardColumn_' . ($cIndex + 1) : '#boardColumn_1'),
            ],
            'clientEvents' => [
                'receive' => 'function (event, ui) {
                    columnTicketOrder(event, ui, this);
                }',
                'update' => 'function (event, ui) {
                    if (!ui.sender && this === ui.item.parent()[0]) {
                       columnTicketOrder(event, ui, this);
                    }
                }',
            ],
        ]);
    }

    $dataProvider = new ArrayDataProvider([
        'allModels' => [$gridRow],
        'sort' => false,
        'pagination' => false,
    ]);

    // create Column Data array compatible for consumption by GridView
    // column data and ticket data are related but processed separately
    foreach ($columnData as $column) {
        $gridColumn[] = [
{'fraction_non_alphanumeric': 0.15384615384615385, 'fraction_numerical': 0.003312476996687523, 'mean_word_length': 2.2312722948870394, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 73, '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': '3851681', 'n_tokens_mistral': 1605, 'n_tokens_neox': 1529, 'n_words': 418}