Skip to content

Add possibility to change position (increase/decrease) of elements at CRUD lists

License

Notifications You must be signed in to change notification settings

bartekgruszka/admin-positionable-bundle

 
 

Repository files navigation

FSiAdminPositionableBundle

This bundle provides way to change position of item on the list gradually. This mean that position will be changed by 1.

FSiAdminPositionableBundle works with conjunction with Sortable behavior extension for Doctrine2

Usage

Add to AppKernel.php:

new FSi\Bundle\AdminPositionableBundle\FSiAdminPositionableBundle(),

Add routes to /app/config/routing.yml:

_fsi_positionable:
    resource: "@FSiAdminPositionableBundle/Resources/config/routing.xml"
    prefix:   /

Sample entity:

use use FSi\Bundle\AdminPositionableBundle\Model\PositionableInterface;

class Promotion implements PositionableInterface
{
    /**
     * {@inheritdoc}
     */
    public function increasePosition()
    {
        $this->position++;
    }

    /**
     * {@inheritdoc}
     */
    public function decreasePosition()
    {
        $this->position--;
    }
}

Note: that PositionableInterface implementation is required

Sample datagrid definition:

columns:
  title:
    type: text
    options:
      display_order: 1
      label: "backend.promotions.datagrid.title.label"
  actions:
    type: action
    options:
      display_order: 2
      label: "backend.promotions.datagrid.actions.label"
      field_mapping: [ id ]
      actions:
        move_up:
          route_name: "fsi_admin_positionable_decrease_position"
          additional_parameters: { element: "promotions" }
          parameters_field_mapping: { id: id }
          content: <span class="glyphicon glyphicon-arrow-up icon-white"></span>
          url_attr: { class: "btn btn-warning btn-sm" }
        move_down:
          route_name: "fsi_admin_positionable_increase_position"
          additional_parameters: { element: "promotions" }
          parameters_field_mapping: { id: id }
          content: <span class="glyphicon glyphicon-arrow-down icon-white"></span>
          url_attr: { class: "btn btn-warning btn-sm" }

About

Add possibility to change position (increase/decrease) of elements at CRUD lists

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages