Browse Source

Tri catégories bug

master
Fab 4 years ago
parent
commit
f4f380106e
2 changed files with 10 additions and 4 deletions
  1. +2
    -1
      ShopBundle/Controller/Backend/AdminController.php
  2. +8
    -3
      ShopBundle/Resources/public/js/backend/script/default/init-sort.js

+ 2
- 1
ShopBundle/Controller/Backend/AdminController.php View File

foreach ($positionForm->get('entities')->getData() as $elm) { foreach ($positionForm->get('entities')->getData() as $elm) {
$this->dispatch(EasyAdminEvents::PRE_UPDATE, ['entity' => $entity]); $this->dispatch(EasyAdminEvents::PRE_UPDATE, ['entity' => $entity]);
$entity = $repo->find($elm['id']); $entity = $repo->find($elm['id']);

$entity->setPosition($elm['position']); $entity->setPosition($elm['position']);
$this->em->persist($entity); $this->em->persist($entity);
$this->dispatch(EasyAdminEvents::POST_UPDATE, ['entity' => $entity]); $this->dispatch(EasyAdminEvents::POST_UPDATE, ['entity' => $entity]);
$latsPos = $elm['position']; $latsPos = $elm['position'];

} }


//die();
//die(); //die();
//to do récupérer les élements hors ligne et incrémenter position //to do récupérer les élements hors ligne et incrémenter position
/*foreach ($repo->findBy(array('status'=> false)) as $offlineEntity) { /*foreach ($repo->findBy(array('status'=> false)) as $offlineEntity) {

+ 8
- 3
ShopBundle/Resources/public/js/backend/script/default/init-sort.js View File

prototype = $('#form_entities').data('prototype'); prototype = $('#form_entities').data('prototype');


$('.lc-sortable tr.lc-draggable').each(function (index, li) { $('.lc-sortable tr.lc-draggable').each(function (index, li) {

// instead be a number based on how many items we have // instead be a number based on how many items we have
var newForm = prototype.replace(/__name__/g, index); var newForm = prototype.replace(/__name__/g, index);




$(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 ($('.lc-sortable').data('parent-position') !== '') val = $('.lc-sortable').data('parent-position') + '.' + index
else val = index;

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



Loading…
Cancel
Save