Browse Source

Correctif sortable with tree

develop
Fab 3 years ago
parent
commit
82f3e2485b
3 changed files with 11 additions and 5 deletions
  1. +6
    -0
      Doctrine/Extension/SortableTrait.php
  2. +3
    -3
      Resources/assets/app/adminlte/sort/sort.js
  3. +2
    -2
      Resources/views/adminlte/crud/sort.html.twig

+ 6
- 0
Doctrine/Extension/SortableTrait.php View File

$this->position = $position; $this->position = $position;
return $this; return $this;
} }

public function clearPosition(): self
{
$this->position = null;
return $this;
}
} }

+ 3
- 3
Resources/assets/app/adminlte/sort/sort.js View File



$(li).append(newForm); $(li).append(newForm);
$(li).find('#form_entities_' + index + '_id').val($(li).data('id')); $(li).find('#form_entities_' + index + '_id').val($(li).data('id'));
if ($('.sov-sortable').data('parent-position') !== '') {
/* if ($('.sov-sortable').data('parent-position') !== '') {
//Ajout d'un 0 initial pour les nuémros <10 //Ajout d'un 0 initial pour les nuémros <10
indexAsString = index.toString().padStart(2, '0'); indexAsString = index.toString().padStart(2, '0');
val = $('.sov-sortable').data('parent-position') + '.' + indexAsString val = $('.sov-sortable').data('parent-position') + '.' + indexAsString
} else {
} else {*/
val = index; val = index;
}
//}
$(li).find('#form_entities_' + index + '_position').val(val); $(li).find('#form_entities_' + index + '_position').val(val);
}); });



+ 2
- 2
Resources/views/adminlte/crud/sort.html.twig View File

{% block body %} {% block body %}


<div class="table-responsive"> <div class="table-responsive">
<table class="table table-bordered table-hover table-striped sov-sortable"
data-parent-position="{{ ea.entity is defined and ea.entity.instance is not null ? ea.entity.instance.position : '' }}">
<table class="table table-bordered table-hover table-striped sov-sortable">
{# data-parent-position="{{ ea.entity is defined and ea.entity.instance is not null ? ea.entity.instance.position : '' }}" #}
<thead> <thead>
{% block table_head %} {% block table_head %}
<tr> <tr>

Loading…
Cancel
Save