Git Product home page Git Product logo

pixsortablebehaviorbundle's People

Contributors

1ed avatar aitboudad avatar baurelien avatar benjamin-hubert avatar bghosts avatar bordeux avatar ceesvanegmond avatar jordisala1991 avatar kunicmarko20 avatar lexxpavlov avatar nataliaaznar avatar nicolasricci avatar nilov avatar oskarstark avatar peter-gribanov avatar sc0rp10 avatar siciarek avatar tatai avatar terox avatar themao avatar tofandel avatar trasher avatar vvh-empora avatar vviippola avatar zeliard91 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

pixsortablebehaviorbundle's Issues

Wrong position when remove item

Hi, thanks for your work.
I have an issue when i delete an item (with or without group position).
The new positions are completly broken.
Do you a trick for that ?

Regards

Service "pix_sortable_behavior.position.orm" not found

Service "pix_sortable_behavior.position.orm" not found: even though it exists in the app's container, the container inside "Pix\SortableBehaviorBundle\Controller\SortableAdminController" is a smaller service locator that only knows about the "doctrine", "form.factory", "http_kernel", "logger", "parameter_bag", "request_stack", "router", "security.authorization_checker", "security.csrf.token_manager", "security.token_storage", "serializer", "session", "sonata.admin.audit.manager", "sonata.admin.object.manipulator.acl.admin", "sonata.admin.pool", "sonata.admin.request.fetcher", "translator" and "twig" services. Try using dependency injection instead.

Too few arguments to function Symfony\Component\Config\Definition\Builder\TreeBuilder::__construct()

With symfony/config v5.4.11 such error happens:

!!  ArgumentCountError {#16254
!!    #message: "Too few arguments to function Symfony\Component\Config\Definition\Builder\TreeBuilder::__construct(), 0 passed in vendor/pixassociates/sortable-behavior-bundle/Pix/SortableBehaviorBundle/DependencyInjection/Configuration.php on line 30 and at least 1 expected"
!!    #code: 0
!!    #file: "./vendor/symfony/config/Definition/Builder/TreeBuilder.php"
!!    #line: 26
!!    trace: {
!!      ./vendor/symfony/config/Definition/Builder/TreeBuilder.php:26 { …}
!!      ./vendor/pixassociates/sortable-behavior-bundle/Pix/SortableBehaviorBundle/DependencyInjection/Configuration.php:30 { …}
!!      ./vendor/symfony/config/Definition/Processor.php:46 { …}
!!      ./vendor/symfony/dependency-injection/Extension/Extension.php:111 { …}
!!      ./vendor/pixassociates/sortable-behavior-bundle/Pix/SortableBehaviorBundle/DependencyInjection/PixSortableBehaviorExtension.php:32 { …}
!!      ./vendor/symfony/dependency-injection/Compiler/MergeExtensionConfigurationPass.php:76 { …}
!!      ./vendor/symfony/http-kernel/DependencyInjection/MergeExtensionConfigurationPass.php:42 { …}
!!      ./vendor/symfony/dependency-injection/Compiler/Compiler.php:82 { …}
!!      ./vendor/symfony/dependency-injection/ContainerBuilder.php:757 { …}
!!      ./vendor/symfony/http-kernel/Kernel.php:546 { …}
!!      ./vendor/symfony/http-kernel/Kernel.php:787 { …}
!!      ./vendor/symfony/http-kernel/Kernel.php:128 { …}
!!      ./vendor/symfony/framework-bundle/Console/Application.php:168 { …}
!!      ./vendor/symfony/framework-bundle/Console/Application.php:74 { …}
!!      ./vendor/symfony/console/Application.php:171 { …}
!!      ./bin/console:43 {
!!        › $application = new SignalableApplication($kernel); // TODO: Remove once migrated to Symfony 5.2
!!        › $application->run($input);
!!        › 
!!        arguments: {
!!          $input: Symfony\Component\Console\Input\ArgvInput {#4 …}
!!        }
!!      }
!!    }
!!  }

Position field not found on MappedSuperclass

Hi,

If we use a MappedSuperclass as base class for our sortable entity, we encounter a DQL error saying there's no position field mapped on the parent class entity.

This come from the PositionORMHandler service wich does the following since commit 126204c:

while ($parentEntityClass)
{
    $parentEntityClass = ClassUtils::getParentClass($entityClass);
    if ($parentEntityClass)
        $entityClass = $parentEntityClass;
}

It may be necessary to check if parent class is not a MappedSuperclass.

Release visibility

This is an absolute minor issue.
You probably want to mark v1.3 on the Release page as the latest. Currently, it displays the 2-years old v0.2 as the most recent, which can be slightly misleading on first look.

Filter parameters issue

When moving the record up/down, all selected filters should also apply, according to this line https://github.com/pix-digital/pixSortableBehaviorBundle/blob/master/Controller/SortableAdminController.php#L34

In fact, they don't, because $this->admin->getFilterParameters() returns an array like "return $params['filter']" and not like "return $params". That's why my suggestion is to fix this line:

return new RedirectResponse($this->admin->generateUrl('list', [ 'filter' => $this->admin->getFilterParameters() ]));

In my project, I've got this fixed, the question is - can you reproduce this behavior and should it be fixed and PR created?

Extending SortableAdminController, problem with constructor

Hi. I create custom controller for class PromoPageAdmin and set it in the settings in admin.yaml

App\Admin\Action\Content\PromoPageAdmin:
        arguments: [ ~, App\Cms\Entity\Content\PromoPage, App\Cms\Controller\Content\PromoPageController ]
        calls:
            - setTranslationDomain: [ 'promo_page' ]
        tags:
            - { name: sonata.admin, manager_type: orm, label: promo_page_list }

And in controller

class PromoPageController extends SortableAdminController
{
    protected UploadHandler $uploadHandler;

    protected SerializerInterface $serializer;

    protected LoggerInterface $logger;

    protected EntityManagerInterface $entityManager;

public function __construct(
        PropertyAccessorInterface $accessor,
        PositionHandlerInterface $positionHandler,
        UploadHandler $uploadHandler, SerializerInterface $serializer, LoggerInterface $logger, EntityManagerInterface $entityManager
    )
    {
        $this->uploadHandler = $uploadHandler;
        $this->serializer = $serializer;
        $this->logger = $logger;
        $this->entityManager = $entityManager;

        parent::__construct($accessor, $positionHandler);
    }
}

But I got this error
Cannot autowire service "App\Cms\Controller\Content\PromoPageController": argument "$positionHandler" of method "__construct()" references interface "Runroom\SortableBehaviorBundle\Service\PositionHandlerInterface" but no such service exists. You should maybe alias this interface to one of these existing services: "Runroom\SortableBehaviorBundle\Service\ORMPositionHandler", "Runroom\SortableBehaviorBundle\Service\GedmoPositionHandler".

I tried add in service.yaml:
Runroom\SortableBehaviorBundle\Service\PositionHandlerInterface:

but next error:
Cannot instantiate interface Runroom\SortableBehaviorBundle\Service\PositionHandlerInterface

how to sort multiple Admin with same entity

Hey, This package is really awesome! and thanks your work!

I have a article Entity with multiple Admin class:

in src/Admin/ZCLL:

final class ArticleOne extends AbstractAdmin
{
	protected $baseRouteName = 'zcll-agaj';
	protected $baseRoutePattern = 'zcll-agaj';
}

final class ArticleTwo extends AbstractAdmin
{
	protected $baseRouteName = 'zcll-pxjm';
	protected $baseRoutePattern = 'zcll-pxjm';
}
final class ArticleThree extends AbstractAdmin
{
	protected $baseRouteName = 'zcll-zcfg';
	protected $baseRoutePattern = 'zcll-zcfg';
}

above three class are all using one Article Entity, I wanna to sort them in their own scope, without affect others, for example:

  1. I sort some rows in ArticleOne
  2. will generate SQL UPDATE articles SET position = position - 1 WHERE position >= 2 AND position < 4 [] []

this SQL will update ArticleTwo and ArticleThree that rows match the query condition.

I wanna only generate that sql: UPDATE articles SET position = position - 1 WHERE position >= 2 AND position < 4 [] [] and article_type='ArticleOne'

Is it possible?

Deprecations in configuration classes

Hi, I am using the newest version, currently v1.5, and I am getting two deprecating messages:

A tree builder without a root node is deprecated since Symfony 4.2 and will not be supported anymore in 5.0.
Show context    Hide trace
{▼
  /var/www/vendor/symfony/config/Definition/Builder/TreeBuilder.php:30 {▶}
  /var/www/vendor/pixassociates/sortable-behavior-bundle/Pix/SortableBehaviorBundle/DependencyInjection/Configuration.php:30 {▶}
}

and

The "Symfony\Component\Config\Definition\Builder\TreeBuilder::root()" method called for the "pix_sortable_behavior" configuration is deprecated since Symfony 4.3, pass the root name to the constructor instead.
Show context   Hide trace {▼
/var/www/vendor/symfony/config/Definition/Builder/TreeBuilder.php:51 {▶}
/var/www/vendor/pixassociates/sortable-behavior-bundle/Pix/SortableBehaviorBundle/DependencyInjection/Configuration.php:31 {▶} }

Error in the new symfony/config

Please change it in the Configuration.php file

Pix\SortableBehaviorBundle\DependencyInjection\Configuration

        $treeBuilder = new TreeBuilder('pix_sortable_behavior');
        if (method_exists($treeBuilder, 'getRootNode')) {
            $rootNode = $treeBuilder->getRootNode();
        } else {
            // BC layer for symfony/config 4.1 and older
            $rootNode = $treeBuilder->root('pix_sortable_behavior');
        }

Without we will et an error:
Too few arguments to function Symfony\Component\Config\Definition\Builder\TreeBuilder::__construct(), 0 passed in /app/vendor/pixassociates/sortable-behavior-bundle/Pix/SortableBehaviorBundle/DependencyInjection/Configuration.php on line 30 and at least 1 expected

Discriminator with Class table inheritance not working correctly for getLastPosition

Hello,
I have this problem where I am using the setup with discriminator in Doctrine and the Class table inheritance and the field is actually on the main Entity rather than each individual Entity, because I want to sort them all on 1 place.
But this causes the problem that getLastPossition creates query for the child entity class rather than the main. And so I see them all in 1 page, but the buttons are all wrong, because of that.
Meaning that imageOnSide records are only 2 and that's why the getLastPossition returns 2, but it should count all elements in parent entity.

screen shot 2017-04-06 at 10 07 53

Enable Drag'n drop feature

Hello,

Maybe it's an idea to enable Drag'n Drop like feature? Instead of the up, down, top, bottom methods, it could be handy to say something like:

Post with ID X to position X, instead of up, down etc.

Is that an idea that we could implement and you will accept?

We could also offer another template with one action that enables drag'n drop (Maybe even include jQuery UI Sortable).

Problem with position_field in config

The default position_field is mandatory in configuration:

pix_sortable_behavior:
    position_field:
        default: position

Otherwise you get:

ContextErrorException in PixSortableBehaviorExtension.php line 37: Notice: Undefined index: position_field

With composer:

        "php": ">=5.3.9",
        "symfony/symfony": "2.7.*",
        "doctrine/orm": "^2.4.8",
        "doctrine/doctrine-bundle": "~1.4",
        "symfony/assetic-bundle": "~2.3",
        "symfony/swiftmailer-bundle": "~2.3",
        "symfony/monolog-bundle": "~2.4",
        "sensio/distribution-bundle": "~4.0",
        "sensio/framework-extra-bundle": "^3.0.2",
        "incenteev/composer-parameter-handler": "~2.0",
        "sonata-project/core-bundle": "~2.2@dev",
        "twig/extensions": "^1.3",
        "sonata-project/intl-bundle": "^2.2",
        "sonata-project/easy-extends-bundle": "^2.1",
        "sonata-project/admin-bundle": "^2.3",
        "sonata-project/doctrine-orm-admin-bundle": "^2.3",
        "knplabs/knp-menu-bundle": "~2",
        "sonata-project/classification-bundle": "^2.2",
        "sonata-project/media-bundle": "^2.3",
        "symfony-cmf/core-bundle": "^1.2",
        "sonata-project/block-bundle": "~2.2",
        "sonata-project/formatter-bundle": "dev-master",
        "pixassociates/sortable-behavior-bundle": "^0.2.0",
        "stof/doctrine-extensions-bundle": "^1.2"

totally incorrect reordering

After playing with this bundle for a bit I ended up with the following picture:

image

Here is how it looks in the DB:
image

Initially all items were ordered from 0 to 10. I clicked double arrows couple of times and now I have 3 items with order 10.

Sonata Admin CUSTOM ADMIN ACTION problem

As per Soanta Admin doc for SORTABLE BEHAVIOR IN ADMIN LISTING at link

services:
    app.admin.client:
        class: AppBundle\Admin\ClientAdmin
        tags:
            - { name: sonata.admin, manager_type: orm, label: "Clients" }
        arguments:
            - ~
            - AppBundle\Entity\Client
            - 'PixSortableBehaviorBundle:SortableAdmin' # define the new controller via the third argument

And for creating CREATING A CUSTOM ADMIN ACTION at Sonata Admin

services:
    acme.demo.admin.car:
        class: Acme\DemoBundle\Admin\CarAdmin
        tags:
            - { name: sonata.admin, manager_type: orm, group: Demo, label: Car }
        arguments:
            - null
            - Acme\DemoBundle\Entity\Car
            - AcmeDemoBundle:CRUD

In both cases THIRD ARGUMENTS is used. How to overcome this issue

Wrong sortableGroups entity keys classname format

Observed in PositionHandler::getSortableGroupsFieldByEntity() for 1.5 when providing object.

$entity = ClassUtils::getClass($entity);
return App\Entity\ClassName

And $this->sortableGroups['entities'] keys are like :
App/Entity/ClassName

Leading to an empty result array.

I had to provide classname with $class = str_replace('\', '/', ClassUtils::getClass($object)); as a workaround.

Sorry, no time to investigate more.

Starting count for position

I've noticed another strange behavior of this bundle: it uses counter that starts from 0, while SonataAdminBundle's javascript, which is used by 'sonata_type_collection' (admin that's embedded inside another admin) starts counting from 1. In the end it makes collisions: items are ordered like 1,2,3 - so the top position is never reached.

I've made a workaround for this in my current project, but I think it would be handy to provide a generic solution: make a config parameter like 'counter_start' which will be an integer and will indicate where to start counting from.

What do you think about this extension?

Warning: get_class() expects parameter 1 to be object, string given

I follow tutorial SORTABLE BEHAVIOR IN ADMIN LISTING but after Symfony update stopped working and throws an error.

Warning: get_class() expects parameter 1 to be object, string given
500 Internal Server Error - ContextErrorException
  1. in app/cache/dev/classes.php at line 6835
}
public static function getClass($object)
{
return self::getRealClass(get_class($object));
}
public static function getParentClass($className)
{
  1. at ErrorHandler ->handleError ('2', 'get_class() expects parameter 1 to be object, string given', '/var/www/virtual/domain.es/dev/htdocs/app/cache/dev/classes.php', '6835', array('object' => 'AppBundle\Entity\RedesSociales'))
  2. at get_class ('AppBundle\Entity\RedesSociales') in app/cache/dev/classes.php at line 6835 +
  3. at ClassUtils ::getClass ('AppBundle\Entity\RedesSociales') in vendor/pixassociates/sortable-behavior-bundle/Pix/SortableBehaviorBundle/Services/PositionORMHandler.php at line 48 +
  4. at PositionORMHandler ->getLastPosition ('AppBundle\Entity\RedesSociales') in src/AppBundle/Admin/RedesSocialesAdmin.php at line 79 +
  5. at RedesSocialesAdmin ->configureListFields (object(ListMapper)) in app/cache/dev/classes.php at line 9832 +
  6. at Admin ->buildList () in app/cache/dev/classes.php at line 10420 +
  7. at Admin ->hasListFieldDescription ('sort') in app/cache/dev/classes.php at line 9878 +
  8. at Admin ->buildDatagrid () in app/cache/dev/classes.php at line 10201 +
  9. at Admin ->getDatagrid () in vendor/sonata-project/admin-bundle/Controller/CRUDController.php at line 216 +
  10. at CRUDController ->listAction ()
  11. at call_user_func_array (array(object(SortableAdminController), 'listAction'), array()) in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php at line 144 +
  12. at HttpKernel ->handleRaw (object(Request), '1') in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/HttpKernel.php at line 64 +
  13. at HttpKernel ->handle (object(Request), '1', true) in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/DependencyInjection/ContainerAwareHttpKernel.php at line 69 +
  14. at ContainerAwareHttpKernel ->handle (object(Request), '1', true) in vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php at line 185 +
  15. at Kernel ->handle (object(Request)) in web/app_dev.php at line 30

Symfony packages

symfony/assetic-bundle v2.8.1 Integrates Assetic into Symfony2
symfony/monolog-bundle v2.12.1 Symfony MonologBundle
symfony/phpunit-bridge v2.8.16 Symfony PHPUnit Bridge
symfony/polyfill-apcu v1.3.0 Symfony polyfill backporting apcu_* functions to lower PHP versions
symfony/polyfill-intl-icu v1.3.0 Symfony polyfill for intl's ICU-related data and classes
symfony/polyfill-mbstring v1.3.0 Symfony polyfill for the Mbstring extension
symfony/polyfill-php54 v1.3.0 Symfony polyfill backporting some PHP 5.4+ features to lower PHP versions
symfony/polyfill-php55 v1.3.0 Symfony polyfill backporting some PHP 5.5+ features to lower PHP versions
symfony/polyfill-php56 v1.3.0 Symfony polyfill backporting some PHP 5.6+ features to lower PHP versions
symfony/polyfill-php70 v1.3.0 Symfony polyfill backporting some PHP 7.0+ features to lower PHP versions
symfony/polyfill-util v1.3.0 Symfony utilities for portability of PHP codes
symfony/security-acl v2.8.0 Symfony Security Component - ACL (Access Control List)
symfony/swiftmailer-bundle v2.4.2 Symfony SwiftmailerBundle
symfony/symfony v2.8.16 The Symfony PHP framework

PHP version

PHP 5.4.45-0+deb7u2 (cli) (built: Oct 17 2015 08:26:31)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies

Dumping here:

dump($this->getRoot()->getClass());
$this->last_position = $this->positionService->getLastPosition($this->getRoot()->getClass());

I get:

"AppBundle\Entity\RedesSociales"

setFlash() does not exists in Symfony >= 2.1

In the SortableAdminController, there is a call to the setFlash method that no longer exists in Symfony >= 2.1:

$this->get('session')->setFlash('sonata_flash_info', 'Position mise à jour');

You should replace this line with (what I've done for Symfony 2.3.6):

$this->get('session')->getFlashBag()->set('sonata_flash_info', 'Position mise à jour');

Other rows positions

When I change position for one entry in the list, the "position" column in the database is updated accordingly, but the other are not changed.

So, I've multiple rows with same position.

I did not see anything in the code that take care of other rows position, have I missed something?

I do not really know how to handle that, or if AdminBundle can help in any way (I've not been able yet to find out where that is done for sortables collections in SonataAdminBundle).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.