<?xml version="1.0"?>
<!--
/**
 * @author 1902 Software
 * @copyright Copyright © 2023 1902 Software (https://1902software.com/magento/)
 * @package WriteTextAI_WriteTextAI
 */
-->

<listing xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Ui:etc/ui_configuration.xsd">
    <argument name="data" xsi:type="array">
        <item name="js_config" xsi:type="array">
            <item name="provider" xsi:type="string">wtai_categories_grid_listing.wtai_categories_grid_listing_data_source</item>
            <item name="deps" xsi:type="string">wtai_categories_grid_listing.wtai_categories_grid_listing_data_source</item>
        </item>
        <item name="spinner" xsi:type="string">categories_columns</item>
    </argument>
    <dataSource name="wtai_categories_grid_listing_data_source" component="WriteTextAI_WriteTextAI/js/magento/grid/provider">
        <argument name="dataProvider" xsi:type="configurableObject">
            <argument name="class" xsi:type="string">WriteTextAI\WriteTextAI\Ui\DataProvider\Categories\ListingDataProvider</argument>
            <argument name="name" xsi:type="string">wtai_categories_grid_listing_data_source</argument>
            <argument name="primaryFieldName" xsi:type="string">entity_id</argument>
            <argument name="requestFieldName" xsi:type="string">entity_id</argument>
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="update_url" xsi:type="url" path="mui/index/render" />
                    <item name="storageConfig" xsi:type="array">
                        <item name="indexField" xsi:type="string">entity_id</item>
                        <item name="cacheRequests" xsi:type="boolean">false</item>
                    </item>
                </item>
            </argument>
        </argument>
        <argument name="data" xsi:type="array">
            <item name="js_config" xsi:type="array">
                <item name="component" xsi:type="string">Magento_Ui/js/grid/provider</item>
            </item>
        </argument>
    </dataSource>
    <listingToolbar name="listing_top" component="WriteTextAI_WriteTextAI/js/magento/grid/toolbar">
        <settings>
            <sticky>true</sticky>
        </settings>
        <bookmark name="bookmarks" />
        <columnsControls name="columns_controls" />
        <filters name="listing_filters" component="WriteTextAI_WriteTextAI/js/categories/grid/filters/filters">
            <argument name="data" xsi:type="array">                
                <item name="config" xsi:type="array">                   
                    <item name="templates" xsi:type="array">                    
                        <item name="filters" xsi:type="array">
                            <item name="select" xsi:type="array">
                                <item name="component" xsi:type="string">Magento_Ui/js/form/element/ui-select</item>
                                <item name="template" xsi:type="string">ui/grid/filters/elements/ui-select</item>
                            </item>
                        </item>
                    </item>
                </item>
            </argument>
            <settings>
                <imports>
                    <link name="errorMessage">${ $.provider}:data.error_message</link>
                </imports>
            </settings>
            <filterSelect name="store_id" provider="${ $.parentName }" component="WriteTextAI_WriteTextAI/js/form/element/store">
                <settings>
                    <options class="WriteTextAI\WriteTextAI\Model\OptionSource\Filter\Stores"/>
                    <caption translate="true">All store views</caption>
                    <label translate="true">Store view</label>
                    <dataScope>store_id</dataScope>
                </settings>
            </filterSelect>
            <filterSelect name="writetextai_status" component="WriteTextAI_WriteTextAI/js/categories/form/element/status" template="WriteTextAI_WriteTextAI/categories/grid/filters/elements/status">
                <argument name="optionsProvider" xsi:type="configurableObject">
                    <argument name="class" xsi:type="string">WriteTextAI\WriteTextAI\Model\Categories\OptionSource\Filter\AiStatus</argument>
                </argument>
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="provider" xsi:type="string">${ $.parentName }</item>
                        <item name="dataScope" xsi:type="string">writetextai_status</item>
                        <item name="label" xsi:type="string" translate="true">WriteText.ai status</item>
                        <item name="caption" xsi:type="string" translate="true">Filter by WriteText.ai status</item>
                    </item>
                </argument>
            </filterSelect>
            <filterInput name="record_ids">
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="dataScope" xsi:type="string">record_ids</item>
                        <item name="label" xsi:type="string">ID</item>
                        <item name="caption" xsi:type="string">Comma separated list of record ids</item>
                        <item name="visible" xsi:type="boolean">false</item>
                    </item>
                </argument>
            </filterInput>
            <filterInput name="request_id">
                <argument name="data" xsi:type="array">
                    <item name="config" xsi:type="array">
                        <item name="dataScope" xsi:type="string">request_id</item>
                        <item name="label" xsi:type="string">Bulk request results</item>
                        <item name="caption" xsi:type="string">Comma separated list of request ids</item>
                        <item name="visible" xsi:type="boolean">false</item>
                    </item>
                </argument>
            </filterInput>
        </filters>
        <paging name="listing_paging">
            <settings>
                <options>
                    <option name="20" xsi:type="array">
                        <item name="value" xsi:type="number">20</item>
                        <item name="label" xsi:type="string">20</item>
                    </option>
                    <option name="30" xsi:type="array">
                        <item name="value" xsi:type="number">30</item>
                        <item name="label" xsi:type="string">30</item>
                    </option>
                    <option name="50" xsi:type="array">
                        <item name="value" xsi:type="number">50</item>
                        <item name="label" xsi:type="string">50</item>
                    </option>
                    <option name="100" xsi:type="array">
                        <item name="value" xsi:type="number">100</item>
                        <item name="label" xsi:type="string">100</item>
                    </option>
                </options>
            </settings>
        </paging>
        <button name="setting_button">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="displayArea" xsi:type="string">dataGridActions</item>
                    <item name="component" xsi:type="string">WriteTextAI_WriteTextAI/js/grid/settings</item>
                    <item name="template" xsi:type="string">WriteTextAI_WriteTextAI/grid/settings</item>
                </item>
            </argument>
            <settings>
                <title><![CDATA[Save]]></title>
                <imports>
                    <link name="enableComparisonPopup">${ $.provider}:data.grid_settings.enable_comparison_popup</link>
                    <link name="originalValue">${ $.provider}:data.grid_settings.enable_comparison_popup</link>
                    <link name="entityType">${ $.provider}:data.grid_settings.entity_type</link>
                    <link name="saveUrl">${ $.provider}:data.grid_settings.url</link>
                </imports>
            </settings>
        </button>
    </listingToolbar>
    <columns name="categories_columns">
        <argument name="data" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="component" xsi:type="string">WriteTextAI_WriteTextAI/js/categories/grid/listing</item>
                <item name="template" xsi:type="string">WriteTextAI_WriteTextAI/categories/grid/listing</item>
            </item>
        </argument>
         <column name="entity_id">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="filter" xsi:type="string">textRange</item>
                    <item name="sortOrder" xsi:type="number">10</item>
                    <item name="label" xsi:type="string" translate="true">ID</item>
                    <item name="draggable" xsi:type="boolean">false</item>
                </item>
            </argument>
        </column>
        <column name="thumbnail" class="Magento\Catalog\Ui\Component\Listing\Columns\Thumbnail">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="label" xsi:type="string" translate="true">Category image</item>
                    <item name="bodyTmpl" xsi:type="string">WriteTextAI_WriteTextAI/categories/grid/cells/thumbnail</item>
                    <item name="component" xsi:type="string">WriteTextAI_WriteTextAI/js/categories/grid/columns/thumbnail</item>
                    <item name="sortOrder" xsi:type="number">15</item>
                    <item name="draggable" xsi:type="boolean">false</item>
                    <item name="sortable" xsi:type="boolean">false</item>
                    <item name="has_preview" xsi:type="boolean">true</item>
                </item>
            </argument>
        </column>
        <column name="name">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="filter" xsi:type="string">text</item>
                    <item name="bodyTmpl" xsi:type="string">WriteTextAI_WriteTextAI/categories/grid/cells/html/name</item>
                    <item name="label" xsi:type="string" translate="true">Category Name</item>
                    <item name="sortOrder" xsi:type="number">20</item>
                    <item name="draggable" xsi:type="boolean">false</item>
                    <item name="component" xsi:type="string">WriteTextAI_WriteTextAI/js/categories/grid/columns/column</item>
                    <item name="fieldClass" xsi:type="string">wtai-col-product_name</item>
                </item>
            </argument>
        </column>
        <actionsColumn name="actions" class="WriteTextAI\WriteTextAI\Ui\Components\Categories\Listing\Column\Actions">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="label" xsi:type="string" translate="true">Actions</item>
                    <item name="resizeEnabled" xsi:type="boolean">false</item>
                    <item name="resizeDefaultWidth" xsi:type="string">107</item>
                    <item name="indexField" xsi:type="string">entity_id</item>
                    <item name="sortOrder" xsi:type="number">30</item>
                    <item name="fieldClass" xsi:type="string">wtai-col-actions</item>
                    <item name="draggable" xsi:type="boolean">false</item>
                    <item name="component" xsi:type="string">WriteTextAI_WriteTextAI/js/categories/grid/columns/actions</item>
                    <item name="bodyTmpl" xsi:type="string">WriteTextAI_WriteTextAI/grid/cells/actions</item>
                    <item name="imports" xsi:type="array">
                        <item name="ids" xsi:type="string">${$.provider}:data.ids</item>
                        <item name="users" xsi:type="string">${$.provider}:data.users</item>
                        <item name="currentUser" xsi:type="string">${$.provider}:data.current_user</item>
                    </item>
                </item>
            </argument>
        </actionsColumn>
        <column name="traffic_potential">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="label" xsi:type="string" translate="true">Traffic potential</item>
                    <item name="component" xsi:type="string">WriteTextAI_WriteTextAI/js/magento/grid/columns/column/traffic-potential</item>
                    <item name="sortable" xsi:type="boolean">false</item>
                    <item name="sortOrder" xsi:type="number">40</item>
                    <item name="fieldClass" xsi:type="string">wtai-col-traffic_potential</item>
                    <item name="draggable" xsi:type="boolean">false</item>
                </item>
            </argument>
        </column>
        <column name="target_keywords">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="label" xsi:type="string" translate="true">Target keywords</item>
                    <item name="component" xsi:type="string">WriteTextAI_WriteTextAI/js/magento/grid/columns/column/target-keywords</item>
                    <item name="sortable" xsi:type="boolean">false</item>
                    <item name="sortOrder" xsi:type="number">45</item>
                    <item name="fieldClass" xsi:type="string">wtai-col-target_keywords</item>
                    <item name="draggable" xsi:type="boolean">false</item>
                </item>
            </argument>
        </column>
        <column name="status">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="component" xsi:type="string">Magento_Ui/js/grid/columns/select</item>
                    <item name="filter" xsi:type="string">select</item>
                    <item name="dataType" xsi:type="string">select</item>
                    <item name="label" xsi:type="string" translate="true">Status</item>
                    <item name="sortOrder" xsi:type="number">50</item>
                    <item name="draggable" xsi:type="boolean">false</item>
                </item>
            </argument>
            <settings>
                <options class="Magento\Catalog\Model\Product\Attribute\Source\Status"/>
            </settings>
        </column>
        <column name="ai_page_title">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="label" xsi:type="string" translate="true">WriteText.ai meta title</item>
                    <item name="bodyTmpl" xsi:type="string">WriteTextAI_WriteTextAI/grid/cells/html</item>
                    <item name="component" xsi:type="string">WriteTextAI_WriteTextAI/js/magento/grid/columns/column</item>
                    <item name="fieldClass" xsi:type="string">wtai-col-ai</item>
                    <item name="sortable" xsi:type="boolean">false</item>
                    <item name="draggable" xsi:type="boolean">false</item>
                    <item name="sortOrder" xsi:type="number">60</item>
                </item>
            </argument>
            <settings>
                <imports>
                    <link name="enableComparisonPopup">${ $.provider}:data.grid_settings.enable_comparison_popup</link>
                </imports>
            </settings>
        </column>
        <column name="mg_page_title">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="filter" xsi:type="string">text</item>
                    <item name="label" xsi:type="string" translate="true">Magento meta title</item>
                    <item name="bodyTmpl" xsi:type="string">WriteTextAI_WriteTextAI/grid/cells/html</item>
                    <item name="component" xsi:type="string">WriteTextAI_WriteTextAI/js/magento/grid/columns/column</item>
                    <item name="fieldClass" xsi:type="string">wtai-col-mg</item>
                    <item name="draggable" xsi:type="boolean">false</item>
                    <item name="sortOrder" xsi:type="number">70</item>
                </item>
            </argument>
            <settings>
                <imports>
                    <link name="enableComparisonPopup">${ $.provider}:data.grid_settings.enable_comparison_popup</link>
                </imports>
            </settings>
        </column>
        <column name="ai_page_description">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="label" xsi:type="string" translate="true">WriteText.ai meta description</item>
                    <item name="bodyTmpl" xsi:type="string">WriteTextAI_WriteTextAI/grid/cells/html</item>
                    <item name="component" xsi:type="string">WriteTextAI_WriteTextAI/js/magento/grid/columns/column</item>
                    <item name="fieldClass" xsi:type="string">wtai-col-ai</item>
                    <item name="sortable" xsi:type="boolean">false</item>
                    <item name="sortOrder" xsi:type="number">80</item>
                    <item name="draggable" xsi:type="boolean">false</item>
                </item>
            </argument>
            <settings>
                <imports>
                    <link name="enableComparisonPopup">${ $.provider}:data.grid_settings.enable_comparison_popup</link>
                </imports>
            </settings>
        </column>
        <column name="mg_page_description">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="filter" xsi:type="string">text</item>
                    <item name="label" xsi:type="string" translate="true">Magento meta description</item>
                    <item name="bodyTmpl" xsi:type="string">WriteTextAI_WriteTextAI/grid/cells/html</item>
                    <item name="component" xsi:type="string">WriteTextAI_WriteTextAI/js/magento/grid/columns/column</item>
                    <item name="fieldClass" xsi:type="string">wtai-col-mg</item>
                    <item name="draggable" xsi:type="boolean">false</item>
                    <item name="sortOrder" xsi:type="number">90</item>
                </item>
            </argument>
            <settings>
                <imports>
                    <link name="enableComparisonPopup">${ $.provider}:data.grid_settings.enable_comparison_popup</link>
                </imports>
            </settings>
        </column>
        <column name="ai_category_description">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="label" xsi:type="string" translate="true">WriteText.ai description</item>
                    <item name="bodyTmpl" xsi:type="string">WriteTextAI_WriteTextAI/grid/cells/html</item>
                    <item name="component" xsi:type="string">WriteTextAI_WriteTextAI/js/magento/grid/columns/column</item>
                    <item name="fieldClass" xsi:type="string">wtai-col-ai</item>
                    <item name="sortable" xsi:type="boolean">false</item>
                    <item name="draggable" xsi:type="boolean">false</item>
                    <item name="sortOrder" xsi:type="number">100</item>
                </item>
            </argument>
            <settings>
                <imports>
                    <link name="enableComparisonPopup">${ $.provider}:data.grid_settings.enable_comparison_popup</link>
                </imports>
            </settings>
        </column>
        <column name="mg_category_description">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="filter" xsi:type="string">text</item>
                    <item name="label" xsi:type="string" translate="true">Magento description</item>
                    <item name="bodyTmpl" xsi:type="string">WriteTextAI_WriteTextAI/grid/cells/html</item>
                    <item name="component" xsi:type="string">WriteTextAI_WriteTextAI/js/magento/grid/columns/column</item>
                    <item name="fieldClass" xsi:type="string">wtai-col-mg</item>
                    <item name="draggable" xsi:type="boolean">false</item>
                    <item name="sortOrder" xsi:type="number">105</item>
                </item>
            </argument>
            <settings>
                <imports>
                    <link name="enableComparisonPopup">${ $.provider}:data.grid_settings.enable_comparison_popup</link>
                </imports>
            </settings>
        </column>
        <column name="edited_at">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="label" xsi:type="string" translate="true">Last edited in WriteText.ai</item>
                    <item name="fieldClass" xsi:type="string">wtai-col-date</item>
                    <item name="draggable" xsi:type="boolean">false</item>
                    <item name="sortOrder" xsi:type="number">115</item>
                </item>
            </argument>
        </column>
        <column name="transferred_at">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="label" xsi:type="string" translate="true">Last transferred to Magento</item>
                    <item name="fieldClass" xsi:type="string">wtai-col-date</item>
                    <item name="draggable" xsi:type="boolean">false</item>
                    <item name="sortOrder" xsi:type="number">120</item>
                </item>
            </argument>
        </column>
    </columns>
</listing>
