<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<form 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">new_category_form.new_category_form_data_source</item>
            <item name="namespace" xsi:type="string">new_category_form</item>
        </item>
        <item name="template" xsi:type="string">templates/form/collapsible</item>
    </argument>
    <settings>
        <buttons>
            <button name="save" class="Magento\Catalog\Block\Adminhtml\Product\Edit\Button\CreateCategory"/>
        </buttons>
        <ajaxSaveType>simple</ajaxSaveType>
        <deps>
            <dep>new_category_form.new_category_form_data_source</dep>
        </deps>
    </settings>
    <dataSource name="new_category_form_data_source">
        <argument name="data" xsi:type="array">
            <item name="js_config" xsi:type="array">
                <item name="component" xsi:type="string">Magento_Ui/js/form/provider</item>
            </item>
        </argument>
        <settings>
            <submitUrl path="catalog/category/save"/>
        </settings>
        <dataProvider class="Magento\Catalog\Ui\DataProvider\Product\Form\NewCategoryDataProvider" name="new_category_form_data_source">
            <settings>
                <requestFieldName>id</requestFieldName>
                <primaryFieldName>entity_id</primaryFieldName>
            </settings>
        </dataProvider>
    </dataSource>
    <fieldset name="data">
        <settings>
            <collapsible>false</collapsible>
            <label/>
        </settings>
        <container name="messages" component="Magento_Catalog/js/components/messages">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="label" xsi:type="string"/>
                </item>
            </argument>
        </container>
        <field name="name" sortOrder="10" formElement="input">
            <settings>
                <required>true</required>
                <validation>
                    <rule name="required-entry" xsi:type="boolean">true</rule>
                </validation>
                <dataType>string</dataType>
                <label translate="true">Category Name</label>
                <dataScope>data.name</dataScope>
                <componentType>field</componentType>
            </settings>
        </field>
        <field name="parent" component="Magento_Catalog/js/components/new-category" sortOrder="20" formElement="select">
            <argument name="data" xsi:type="array">
                <item name="config" xsi:type="array">
                    <item name="filterOptions" xsi:type="boolean">true</item>
                    <item name="multiple" xsi:type="boolean">false</item>
                    <item name="showCheckbox" xsi:type="boolean">false</item>
                    <item name="disableLabel" xsi:type="boolean">true</item>
                    <item name="levelsVisibility" xsi:type="number">1</item>
                </item>
            </argument>
            <settings>
                <required>true</required>
                <validation>
                    <rule name="required-entry" xsi:type="boolean">true</rule>
                </validation>
                <elementTmpl>ui/grid/filters/elements/ui-select</elementTmpl>
                <label translate="true">Parent Category</label>
                <dataScope>data.parent</dataScope>
                <componentType>field</componentType>
                <listens>
                    <link name="${ $.namespace }.${ $.namespace }:responseData">setParsed</link>
                </listens>
            </settings>
            <formElements>
                <select>
                    <settings>
                        <options class="Magento\Catalog\Ui\Component\Product\Form\Categories\Options"/>
                    </settings>
                </select>
            </formElements>
        </field>
    </fieldset>
</form>
