Browse Source

Correctif backoffice

master
Fab 4 years ago
parent
commit
9fc6c71f97
3 changed files with 7 additions and 9 deletions
  1. +1
    -1
      ShopBundle/Controller/Admin/AdminController.php
  2. +5
    -5
      ShopBundle/Model/SortableTrait.php
  3. +1
    -3
      ShopBundle/Resources/public/js/backend/script/default/init-sort.js

+ 1
- 1
ShopBundle/Controller/Admin/AdminController.php View File



$fields = $this->entity['list']['fields']; $fields = $this->entity['list']['fields'];
$paginator = $this->findAll($this->entity['class'], $this->request->query->get('page', 1), 500, $this->request->query->get('sortField'), $this->request->query->get('sortDirection'), $this->entity['list']['dql_filter']); $paginator = $this->findAll($this->entity['class'], $this->request->query->get('page', 1), 500, $this->request->query->get('sortField'), $this->request->query->get('sortDirection'), $this->entity['list']['dql_filter']);
dump($paginator->getCurrentPageResults());
$this->dispatch(EasyAdminEvents::POST_LIST, ['paginator' => $paginator]); $this->dispatch(EasyAdminEvents::POST_LIST, ['paginator' => $paginator]);


$positionForm = $this->createFormBuilder(array('entities', $paginator->getCurrentPageResults())) $positionForm = $this->createFormBuilder(array('entities', $paginator->getCurrentPageResults()))

+ 5
- 5
ShopBundle/Model/SortableTrait.php View File

{ {
/** /**
* @var string * @var string
* @ORM\Column(type="integer")
* @ORM\Column(type="float")
*/ */
protected $position = 0; protected $position = 0;


/** /**
* @return int
* @return float
*/ */
public function getPosition(): int
public function getPosition(): float
{ {
return $this->position; return $this->position;
} }


/** /**
* @param int $position
* @param float $position
* @return $this * @return $this
*/ */
public function setPosition(int $position): self
public function setPosition(float $position): self
{ {
$this->position = $position; $this->position = $position;
return $this; return $this;

+ 1
- 3
ShopBundle/Resources/public/js/backend/script/default/init-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 ($('.lc-sortable').data('parent-position') !== '') val = $('.lc-sortable').data('parent-position') + '_' + index
if ($('.lc-sortable').data('parent-position') !== '') val = $('.lc-sortable').data('parent-position') + '.' + index
else val = index; else val = index;


log($(li).find('#form_entities_' + index + '_position'));

$(li).find('#form_entities_' + index + '_position').val(val); $(li).find('#form_entities_' + index + '_position').val(val);
}); });



Loading…
Cancel
Save