<div class="card">
	<div class="card-header">
		<h3 class="card-title">
			<i class="fas fa-sort"></i>
			Gestion du menu
		</h3>
	</div>
	<div class="card-body">
		<div id="tree1" data-url="{{ route('Shop.Categories.getTree') }}"></div>
	</div>
</div>

@include('load.form.tree')

@push('js')
	<script>
		$(function() {

		    var $tree = $('#tree1').tree({
			  	dragAndDrop: true,
			  	autoOpen: 0
			});

			$tree.on('tree.move', function(e) {
			    var position = e.move_info.position;
			    var target_node = e.move_info.target_node;
			    var moved_node = e.move_info.moved_node;

			    $.ajax({
  				    method: "POST",
  				    url: "{{ route('Admin.Shop.Categories.moveTree') }}",
  				    data: {
  				        node_id: moved_node.id,
  				        type: position,
  				        target_id: target_node.id
  				    }
			    });
			});

		});
	</script>
@endpush

