GithubHelp home page GithubHelp logo

mazahaca / sonata-admin-tree-bundle Goto Github PK

View Code? Open in Web Editor NEW
30.0 6.0 19.0 54 KB

This bundle integrates jsTree and Gedmo Nested Set directly to Sonata Admin

License: MIT License

PHP 40.32% HTML 59.68%
symfony sonata-admin tree jstree tree-bundle nested-set

sonata-admin-tree-bundle's Introduction

sonata-admin-tree-bundle

This bundle integrates jsTree and Gedmo Nested Set directly to Sonata Admin.

A tree builds itself in an asynchronous way. Hence, it's quite good for big trees.

Installation

Install requirements

SonataAdminBundle
- the SonataAdminBundle provides an installation article here:
http://symfony.com/doc/current/bundles/SonataAdminBundle/index.html

StofDoctrineExtensionsBundle
- then you need to install StofDoctrineExtensionsBundle
https://symfony.com/doc/master/bundles/StofDoctrineExtensionsBundle/index.html

Enable Tree Extension
- nested behaviour will implement the standard Nested-Set behaviour on your Entity
https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/tree.md

Install TreeBundle

Install it via composer

composer require redcode/tree-bundle

Register the bundle in your app kernel ./app/AppKernel.php

class AppKernel extends Kernel
{
    public function registerBundles()
    {
        $bundles = array(
            ...
            new RedCode\TreeBundle\RedCodeTreeBundle(),
        );
        ...
    }
}

Add the following lines to the routing file ./app/config/routing.yml

redcode_tree:
    resource: "@RedCodeTreeBundle/Resources/config/routing.yml"
    prefix:   /admin

For the entity with enabled Gedmo Nested Set follow these steps:

Extend Admin class from \RedCode\TreeBundle\Admin\AbstractTreeAdmin

class SubjectAdmin extends AbstractTreeAdmin
{
...
}

Extend AdminController from \RedCode\TreeBundle\Controller\TreeAdminController

class SubjectAdminController extends TreeAdminController
{
...
}

When registering the admin as a service, you need to provide a fourth argument - the name of the field that will be shown in the tree.

app.admin.subject:
    class: AppBundle\Admin\SubjectAdmin
    arguments: [~, AppBundle\Entity\Subject, AppBundle:SubjectAdmin, 'word']
    tags:
        - {name: sonata.admin, manager_type: orm, group: Search, label: Subject}

How it looks like

redcode/tree-bundle

sonata-admin-tree-bundle's People

Contributors

kleinast avatar mazahaca avatar mgrajcarek avatar padam87 avatar romainsanchez 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

sonata-admin-tree-bundle's Issues

SQl Error on get_class and dql with config[root] always empty

Hey, nice work here.
After fumbling with the configurations i got everthing to work.

But i needed to change up two things in my own bundle to get it to work. Not sure why though . . might be my own inability but i will describe it either way. Maybe someone can explain what i did wrong?

So after configuring everything for the "StofDoctrineExtensionsBundle" my category entity just would not show a category tree properly. The ajax always returned a SQL Error.

SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: ""
in vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractPostgreSQLDriver.php (line 95)

I followed the error in the code and it seemed like my CategoryAdmin class returned something wrong in the getClass() method.

So i´ve overwritten it and returned the proper entity class since it is used later to get the repository.

Fine, now it works, but always returns an empty array. . .

After looking into it, it seems like the NestedTreeRepository just cant find anything when a root is configured.

if (isset($config['root'])) { $qb->andWhere($qb->expr()->eq('node.'.$config['root'], ':rid')); $qb->setParameter('rid', $wrapped->getPropertyValue($config['root'])); }
Since the root field is always empty in my database, it wont find anything. Dont really know when the root field is written. I cant write it manually ..

So i removed the root configuration in my xml config:
gedmo:tree-root/ <<< removed

Now it properly works, but im not sure if what ive done was ok.

Did someone have similar problems?

Unable to find template

Hi, how can I fix this error?

CRITICAL - Uncaught PHP Exception Twig_Error_Loader: "Unable to find template "SonataAdminBundle:CRUD:list_outer_rows_tree.html.twig" (looked into: /***/***/***/***/app/Resources/views, /***/***/***/***/vendor/symfony/symfony/src/Symfony/Bridge/Twig/Resources/views/Form, /***/***/***/***/vendor/knplabs/knp-menu/src/Knp/Menu/Resources/views) in "SonataAdminBundle:CRUD:base_list.html.twig" at line 94." at /***/***/***/***/vendor/twig/twig/lib/Twig/Loader/Filesystem.php line 226

It happens when I pressing the tree-view button on show table view in admin

Error on twig template 'RedCodeTreeBundle:CRUD:tree.html.twig'

Hello,

I use the dev-master bundle with sonata admin 3.16

I override this sonata admin config:

sonata_admin:
templates:
outer_list_rows_tree: 'RedCodeTreeBundle:CRUD:tree.html.twig'

For use the bundle template for tree instead of not existing sonata one. But I get this error:
Variable "_sonata_admin" does not exist.

Is it a bug or did I do something wrong ?

Thanks

Can't install package from Composer

After fresh symfony3 project creating, i've ran:
composer require redcode/tree-bundle

  [InvalidArgumentException]
  Could not find package redcode/tree-bundle at any version for your minimum-stability (stable).
  Check the package spelling or your minimum-stability

Sonata navbar with filters and view modes missing

we work on a projekt with symfony 4 and sonata. we are using the SonataAdminTreeBundle to manage our Categories.

symfony packages:

  • symfony/apache-pack v1.0.1 A pack for Apache support in Symfony
  • symfony/asset v4.4.7 Symfony Asset Component
  • symfony/browser-kit v4.4.7 Symfony BrowserKit Component
  • symfony/cache v4.4.7 Symfony Cache component with PSR-6, PSR-16, and tags
  • symfony/cache-contracts v2.0.1 Generic abstractions related to caching
  • symfony/config v4.4.7 Symfony Config Component
  • symfony/console v4.4.7 Symfony Console Component
  • symfony/css-selector v4.4.7 Symfony CssSelector Component
  • symfony/debug v4.4.7 Symfony Debug Component
  • symfony/debug-bundle v4.4.7 Symfony DebugBundle
  • symfony/debug-pack v1.0.8 A debug pack for Symfony projects
  • symfony/dependency-injection v4.4.7 Symfony DependencyInjection Component
  • symfony/doctrine-bridge v4.4.7 Symfony Doctrine Bridge
  • symfony/dom-crawler v4.4.7 Symfony DomCrawler Component
  • symfony/dotenv v4.4.7 Registers environment variables from a .env file
  • symfony/error-handler v4.4.7 Symfony ErrorHandler Component
  • symfony/event-dispatcher v4.4.7 Symfony EventDispatcher Component
  • symfony/event-dispatcher-contracts v1.1.7 Generic abstractions related to dispatching event
  • symfony/expression-language v4.4.7 Symfony ExpressionLanguage Component
  • symfony/filesystem v4.4.7 Symfony Filesystem Component
  • symfony/finder v4.4.7 Symfony Finder Component
  • symfony/flex v1.6.2 Composer plugin for Symfony
  • symfony/form v4.4.7 Symfony Form Component
  • symfony/framework-bundle v4.4.7 Symfony FrameworkBundle
  • symfony/http-client v4.4.7 Symfony HttpClient component
  • symfony/http-client-contracts v2.0.1 Generic abstractions related to HTTP clients
  • symfony/http-foundation v4.4.7 Symfony HttpFoundation Component
  • symfony/http-kernel v4.4.7 Symfony HttpKernel Component
  • symfony/inflector v4.4.7 Symfony Inflector Component
  • symfony/intl v4.4.7 A PHP replacement layer for the C intl extension that includes additional data from the ICU library.
  • symfony/mailer v4.4.7 Symfony Mailer Component
  • symfony/maker-bundle v1.15.1 Symfony Maker helps you create empty commands, controllers, form classes, tests and more so you can forget about writing boilerplate code.
  • symfony/mime v4.4.7 A library to manipulate MIME messages
  • symfony/monolog-bridge v4.4.7 Symfony Monolog Bridge
  • symfony/monolog-bundle v3.5.0 Symfony MonologBundle
  • symfony/options-resolver v4.4.7 Symfony OptionsResolver Component
  • symfony/orm-pack v1.0.8 A pack for the Doctrine ORM
  • symfony/phpunit-bridge v5.0.7 Symfony PHPUnit Bridge
  • symfony/polyfill-intl-grapheme v1.15.0 Symfony polyfill for intl's grapheme_* functions
  • symfony/polyfill-intl-icu v1.15.0 Symfony polyfill for intl's ICU-related data and classes
  • symfony/polyfill-intl-idn v1.15.0 Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions
  • symfony/polyfill-intl-normalizer v1.15.0 Symfony polyfill for intl's Normalizer class and related functions
  • symfony/polyfill-mbstring v1.15.0 Symfony polyfill for the Mbstring extension
  • symfony/polyfill-php72 v1.15.0 Symfony polyfill backporting some PHP 7.2+ features to lower PHP versions
  • symfony/polyfill-php73 v1.15.0 Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
  • symfony/process v4.4.7 Symfony Process Component
  • symfony/profiler-pack v1.0.4 A pack for the Symfony web profiler
  • symfony/property-access v4.4.7 Symfony PropertyAccess Component
  • symfony/property-info v4.4.7 Symfony Property Info Component
  • symfony/routing v4.4.7 Symfony Routing Component
  • symfony/security-acl v3.0.4 Symfony Security Component - ACL (Access Control List)
  • symfony/security-bundle v4.4.7 Symfony SecurityBundle
  • symfony/security-core v4.4.7 Symfony Security Component - Core Library
  • symfony/security-csrf v4.4.7 Symfony Security Component - CSRF Library
  • symfony/security-guard v4.4.7 Symfony Security Component - Guard
  • symfony/security-http v4.4.7 Symfony Security Component - HTTP Integration
  • symfony/serializer v4.4.7 Symfony Serializer Component
  • symfony/serializer-pack v1.0.3 A pack for the Symfony serializer
  • symfony/service-contracts v2.0.1 Generic abstractions related to writing services
  • symfony/stopwatch v4.4.7 Symfony Stopwatch Component
  • symfony/string v5.0.7 Symfony String component
  • symfony/templating v4.4.7 Symfony Templating Component
  • symfony/test-pack v1.0.6 A pack for functional and end-to-end testing within a Symfony app
  • symfony/translation v4.4.7 Symfony Translation Component
  • symfony/translation-contracts v2.0.1 Generic abstractions related to translation
  • symfony/twig-bridge v4.4.7 Symfony Twig Bridge
  • symfony/twig-bundle v4.4.7 Symfony TwigBundle
  • symfony/twig-pack v1.0.0 A Twig pack for Symfony projects
  • symfony/validator v4.4.7 Symfony Validator Component
  • symfony/var-dumper v4.4.7 Symfony mechanism for exploring and dumping PHP variables
  • symfony/var-exporter v4.4.7 A blend of var_export() + serialize() to turn any serializable data structure to plain PHP code
  • symfony/web-link v4.4.7 Symfony WebLink Component
  • symfony/web-profiler-bundle v4.4.7 Symfony WebProfilerBundle
  • symfony/yaml v4.4.7 Symfony Yaml Component
  • symfonycasts/reset-password-bundle v1.1.1 Symfony bundle that adds password reset functionality.

sonata packages:

  • sonata-project/admin-bundle 3.65.0 The missing Symfony Admin Generator
  • sonata-project/block-bundle 3.18.4 Symfony SonataBlockBundle
  • sonata-project/cache 2.0.1 Cache library
  • sonata-project/core-bundle 3.18.0 Symfony SonataCoreBundle (abandoned)
  • sonata-project/datagrid-bundle 2.5.0 Symfony SonataDatagridBundle
  • sonata-project/doctrine-extensions 1.6.0 Doctrine2 behavioral extensions
  • sonata-project/doctrine-orm-admin-bundle 3.17.1 Symfony Sonata / Integrate Doctrine ORM into the SonataAdminBundle
  • sonata-project/exporter 2.2.0 Lightweight Exporter library

basically everything works fine - but the menu from sonata were the datagrid filters are located (aka navbar) is not showing up. in that menu you can usually switch the view modes (grid, list, tree) and set up some filters. it worked at the start but once i tried the tree view for the first time, everything was gone and did not show up again.

so what we basically do is: src/Admin/CategoryAdmin:

namespace App\Admin;

use RedCode\TreeBundle\Admin\AbstractTreeAdmin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Symfony\Component\Form\Extension\Core\Type\TextType;

final class CategoryAdmin extends AbstractTreeAdmin
{

    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper->add('name', TextType::class);
    }

    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper->add('name');
        $datagridMapper->add('product_id');
    }

    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper->addIdentifier('name');
    }
}

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.