pix-digital / pixsortablebehaviorbundle Goto Github PK
View Code? Open in Web Editor NEWOffers a sortable feature for your Symfony2 admin listing
License: MIT License
Offers a sortable feature for your Symfony2 admin listing
License: MIT License
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
I have followed this: http://sonata-project.org/bundles/admin/master/doc/cookbook/recipe_sortable_listing.html
And when click up or down button then show me :
The controller for URI "/admin/xxx/frontend/abc/1/move/down" is not callable.
I don't know Why ?
Here my question :
sonata-project/SonataAdminBundle#1995
http://stackoverflow.com/questions/22323483/position-up-down-in-onfigurelistfields-sonata
This is bug or configuration mistake ?
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.
Caused by
Symfony\Component\Yaml\Exception\ParseException: The reserved indicator "@" cannot start a plain scalar; you need to quote the scalar at lin
e 21 (near "- @pix_sortable_behavior.position").
Use
- "@pix_sortable_behavior.position"
not
- @pix_sortable_behavior.position
You are required method getPosition()
if i use field position
for sorting.
Is not good.
I use DTO in SonataAdminBundle and the position
property is public.
I'm forced to create a public method only for compatibility with your library.
Maybe need use something like PropertyAccess? Or make your own implementation?
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 …}
!! }
!! }
!! }
!! }
I get this error when using the default template. PHP 5.3, Symfony 2.6.5.
Hi,
The order of the list is incorrect when using the "move up" or "move down".
example move id 12 to first position :
the order of the 2nd élèments should start at 1, not 2. (id 11 and 10 has same position)
i use sonata admin and i config with : https://sonata-project.org/bundles/admin/master/doc/cookbook/recipe_sortable_listing.html
Can u help me ?
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.
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.
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?
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
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:
ArticleOne
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?
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 {▶} }
Reason this error in this commit 13b86dd
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
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.
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).
FYI I just noticed this: dlabs@738a497
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"
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
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.
Add support for MongoDB
Currently filed name is hardcoded. Users should be able to define field name for sortable behaviour.
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?
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
}
public static function getClass($object)
{
return self::getRealClass(get_class($object));
}
public static function getParentClass($className)
{
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 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"
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');
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).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.