<commit_before>{#

This file is part of the Sonata package.

(c) <NAME> <<EMAIL>>

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.

#}

{% set routing_default_values = {} %}
{% for default in routing_defaults %}
    {% if 'locale' == default %}
        {% set routing_default_values = routing_default_values|merge({'_locale': app.request.locale}) %}
    {% elseif 'format' == default %}
        {% set routing_default_values = routing_default_values|merge({'_format': app.request.format}) %}
    {% else %}
        {% set routing_default_values = routing_default_values|merge({default: app.request.attributes.get(default)}) %}
    {% endif %}
{% endfor %}

{% include 'CmfTreeBrowserBundle:Base:tree.html.twig' %}
<script type="text/javascript">
    jQuery(function($) {
        $('#tree').cmfTree({
            request: {
                load: function (nodePath) {
                    return {
                        url: '{{ path('_cmf_get_resource', {
                            repositoryName: repository_name,
                            root_node: root_node,
                            path: '__path__'
                        }|merge(routing_default_values)) }}'.replace('__path__', nodePath)
                    };
                }
            },
            actions: {
                'edit': {
                    url: { data: '?link.edit.html' },
                    label: "{{ 'create_item'|trans({}, 'SonataDoctrinePhpcrAdminBundle') }}",
                    icon: 'fa fa-pencil'
                },
                'delete': {
                    url: { data: '?link.remove.html' },
                    label: "{{ 'delete_item'|trans({}, 'SonataDoctrinePhpcrAdminBundle') }}",
                    icon: 'fa fa-trash-o'
                }
            }
        });
    });
</script>

<div id="tree"></div><commit_msg>add move function on request option for tree<commit_after>{#

This file is part of the Sonata package.

(c) <NAME> <<EMAIL>>

For the full copyright and license information, please view the LICENSE
file that was distributed with this source code.

#}

{% set routing_default_values = {} %}
{% for default in routing_defaults %}
    {% if 'locale' == default %}
        {% set routing_default_values = routing_default_values|merge({'_locale': app.request.locale}) %}
    {% elseif 'format' == default %}
        {% set routing_default_values = routing_default_values|merge({'_format': app.request.format}) %}
    {% else %}
        {% set routing_default_values = routing_default_values|merge({default: app.request.attributes.get(default)}) %}
    {% endif %}
{% endfor %}

{% include 'CmfTreeBrowserBundle:Base:tree.html.twig' %}
<script type="text/javascript">
    var apiUrlTemplate = '{{ path('_cmf_get_resource', {
        repositoryName: repository_name,
        root_node: root_node,
        path: '__path__'
    }|merge(routing_default_values)) }}';
    jQuery(function($) {
        $('#tree').cmfTree({
            request: {
                load: function (nodePath) {
                    return {
                        url: apiUrlTemplate.replace('__path__', nodePath)
                    };
                },
                move: function (sourcePath, destinationPath) {
                    var body = [{"operation": "move", "target": destinationPath}];

                    return $.ajax(
                      apiUrlTemplate.replace('__path__', sourcePath),
                      {data: body, method: 'PATCH', dataType: 'json', contentType: 'application/json'}
                    );
                }
            },
            actions: {
                'edit': {
                    url: { data: '?link.edit.html' },
                    label: "{{ 'create_item'|trans({}, 'SonataDoctrinePhpcrAdminBundle') }}",
                    icon: 'fa fa-pencil'
                },
                'delete': {
                    url: { data: '?link.remove.html' },
                    label: "{{ 'delete_item'|trans({}, 'SonataDoctrinePhpcrAdminBundle') }}",
                    icon: 'fa fa-trash-o'
                }
            }
        });
    });
</script>

<div id="tree"></div>
{'fraction_non_alphanumeric': 0.14139490597476792, 'fraction_numerical': 0.0, 'mean_word_length': 1.8430311231393774, 'pattern_counts': {'":': 2, '<': 17, '<?xml version=': 0, '>': 17, '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': '2118708', 'n_tokens_mistral': 1224, 'n_tokens_neox': 1122, 'n_words': 238}