<?php

namespace External\CykloSpecialityBundle\Admin\Lists;

use KupShop\AdminBundle\AdminList\BaseList;

class ProductsVarLabelsValuesList extends \Admin\Lists\ProductsVarLabelsValuesList
{
    protected $tableDef = [
        'id' => 'pvcv.id',
        'fields' => [
            'sort' => ['translate' => true,  'field' => 'pvcv.sort', 'size' => 0.5, 'render' => 'renderPosition', 'fieldType' => self::TYPE_INT],
            'value' => ['translate' => true, 'field' => 'pvcv.value', 'fieldType' => BaseList::TYPE_STRING],
            'code' => ['translate' => true, 'field' => 'pvcv.code', 'fieldType' => BaseList::TYPE_STRING],
            'filter_url' => ['translate' => true, 'field' => 'pvcv.filter_url', 'fieldType' => BaseList::TYPE_STRING],
            'title' => ['translate' => true, 'field' => 'pvcv.title', 'fieldType' => BaseList::TYPE_STRING],
        ],
    ];

    public function customizeTableDef($tableDef)
    {
        $tableDef = parent::customizeTableDef($tableDef);

        if (in_array($this->getID(), [23, 15, 25, 21])) {
            $tableDef['fields']['Kód barvy'] = [
                'field' => 'colorCode',
                'spec' => 'JSON_VALUE(data, "$.colorCode") as colorCode',
            ];
        }

        $tableDef['fields']['actions'] = ['translate' => true, 'field' => 'pl.id', 'render' => 'renderActions'];

        return $tableDef;
    }
}

return ProductsVarLabelsValuesList::class;
